Commit 73ea67b0 authored by marko's avatar marko

branches/zip: lock_move_reorganize_page(): Clean up the code a little,

and implement UNIV_DEBUG diagnostics for orphaned locks.
parent 63055ee0
...@@ -2585,11 +2585,6 @@ lock_move_reorganize_page( ...@@ -2585,11 +2585,6 @@ lock_move_reorganize_page(
reorganized page */ reorganized page */
{ {
lock_t* lock; lock_t* lock;
lock_t* old_lock;
page_cur_t cur1;
page_cur_t cur2;
ulint old_heap_no;
ulint new_heap_no;
UT_LIST_BASE_NODE_T(lock_t) old_locks; UT_LIST_BASE_NODE_T(lock_t) old_locks;
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
ulint comp; ulint comp;
...@@ -2612,10 +2607,9 @@ lock_move_reorganize_page( ...@@ -2612,10 +2607,9 @@ lock_move_reorganize_page(
UT_LIST_INIT(old_locks); UT_LIST_INIT(old_locks);
while (lock != NULL) { do {
/* Make a copy of the lock */ /* Make a copy of the lock */
old_lock = lock_rec_copy(lock, heap); lock_t* old_lock = lock_rec_copy(lock, heap);
UT_LIST_ADD_LAST(trx_locks, old_locks, old_lock); UT_LIST_ADD_LAST(trx_locks, old_locks, old_lock);
...@@ -2627,24 +2621,28 @@ lock_move_reorganize_page( ...@@ -2627,24 +2621,28 @@ lock_move_reorganize_page(
} }
lock = lock_rec_get_next_on_page(lock); lock = lock_rec_get_next_on_page(lock);
} } while (lock != NULL);
lock = UT_LIST_GET_FIRST(old_locks);
comp = page_is_comp(block->frame); comp = page_is_comp(block->frame);
ut_ad(comp == page_is_comp(oblock->frame)); ut_ad(comp == page_is_comp(oblock->frame));
while (lock) { for (lock = UT_LIST_GET_FIRST(old_locks); lock;
lock = UT_LIST_GET_NEXT(trx_locks, lock)) {
/* NOTE: we copy also the locks set on the infimum and /* NOTE: we copy also the locks set on the infimum and
supremum of the page; the infimum may carry locks if an supremum of the page; the infimum may carry locks if an
update of a record is occurring on the page, and its locks update of a record is occurring on the page, and its locks
were temporarily stored on the infimum */ were temporarily stored on the infimum */
page_cur_t cur1;
page_cur_t cur2;
page_cur_set_before_first((buf_block_t*) block, &cur1); page_cur_set_before_first((buf_block_t*) block, &cur1);
page_cur_set_before_first((buf_block_t*) oblock, &cur2); page_cur_set_before_first((buf_block_t*) oblock, &cur2);
/* Set locks according to old locks */ /* Set locks according to old locks */
for (;;) { for (;;) {
ulint old_heap_no;
ulint new_heap_no;
ut_ad(comp || !memcmp(page_cur_get_rec(&cur1), ut_ad(comp || !memcmp(page_cur_get_rec(&cur1),
page_cur_get_rec(&cur2), page_cur_get_rec(&cur2),
rec_get_data_size_old( rec_get_data_size_old(
...@@ -2664,6 +2662,10 @@ lock_move_reorganize_page( ...@@ -2664,6 +2662,10 @@ lock_move_reorganize_page(
if (lock_rec_get_nth_bit(lock, old_heap_no)) { if (lock_rec_get_nth_bit(lock, old_heap_no)) {
/* Clear the bit in old_lock. */
ut_d(lock_rec_reset_nth_bit(lock,
old_heap_no));
/* NOTE that the old lock bitmap could be too /* NOTE that the old lock bitmap could be too
small for the new heap number! */ small for the new heap number! */
...@@ -2682,16 +2684,28 @@ lock_move_reorganize_page( ...@@ -2682,16 +2684,28 @@ lock_move_reorganize_page(
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(new_heap_no == PAGE_HEAP_NO_SUPREMUM)) { (new_heap_no == PAGE_HEAP_NO_SUPREMUM)) {
ut_ad(old_heap_no == PAGE_HEAP_NO_SUPREMUM);
break; break;
} }
page_cur_move_to_next(&cur1); page_cur_move_to_next(&cur1);
page_cur_move_to_next(&cur2); page_cur_move_to_next(&cur2);
}
/* Remember that we chained old locks on the trx_locks field */
lock = UT_LIST_GET_NEXT(trx_locks, lock); #ifdef UNIV_DEBUG
{
ulint i = lock_rec_find_set_bit(lock);
/* Check that all locks were moved. */
if (UNIV_UNLIKELY(i != ULINT_UNDEFINED)) {
fprintf(stderr,
"lock_move_reorganize_page():"
" %lu not moved in %p\n",
(ulong) i, (void*) lock);
ut_error;
}
}
#endif /* UNIV_DEBUG */
}
} }
lock_mutex_exit_kernel(); lock_mutex_exit_kernel();
......
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