Commit ddacebb1 authored by John Esmet's avatar John Esmet

fixes #187 Add a paranoid invariant that left endpoints are <= right

endpoints on acquire and release.
parent 7a5f8ba8
...@@ -412,6 +412,9 @@ int locktree::acquire_lock(bool is_write_request, TXNID txnid, ...@@ -412,6 +412,9 @@ int locktree::acquire_lock(bool is_write_request, TXNID txnid,
int locktree::try_acquire_lock(bool is_write_request, TXNID txnid, int locktree::try_acquire_lock(bool is_write_request, TXNID txnid,
const DBT *left_key, const DBT *right_key, txnid_set *conflicts, bool big_txn) { const DBT *left_key, const DBT *right_key, txnid_set *conflicts, bool big_txn) {
// All ranges in the locktree must have left endpoints <= right endpoints.
// Range comparisons rely on this fact, so we make a paranoid invariant here.
paranoid_invariant(m_cmp->compare(left_key, right_key) <= 0);
int r = m_mgr->check_current_lock_constraints(big_txn); int r = m_mgr->check_current_lock_constraints(big_txn);
if (r == 0) { if (r == 0) {
r = acquire_lock(is_write_request, txnid, left_key, right_key, conflicts); r = acquire_lock(is_write_request, txnid, left_key, right_key, conflicts);
...@@ -551,6 +554,9 @@ void locktree::release_locks(TXNID txnid, const range_buffer *ranges) { ...@@ -551,6 +554,9 @@ void locktree::release_locks(TXNID txnid, const range_buffer *ranges) {
while (iter.current(&rec)) { while (iter.current(&rec)) {
const DBT *left_key = rec.get_left_key(); const DBT *left_key = rec.get_left_key();
const DBT *right_key = rec.get_right_key(); const DBT *right_key = rec.get_right_key();
// All ranges in the locktree must have left endpoints <= right endpoints.
// Range comparisons rely on this fact, so we make a paranoid invariant here.
paranoid_invariant(m_cmp->compare(left_key, right_key) <= 0);
remove_overlapping_locks_for_txnid(txnid, left_key, right_key); remove_overlapping_locks_for_txnid(txnid, left_key, right_key);
iter.next(); iter.next();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment