Commit beff378e authored by Yoni Fogel's avatar Yoni Fogel

Addresses #2164 refs[t:2164] Remove race condition from accessing live/zombie lists.

git-svn-id: file:///svn/toku/tokudb@15877 c7de825b-a66e-492c-adef-691d508d4ae1
parent 1bd33df0
...@@ -3293,6 +3293,7 @@ brtheader_note_pin_by_checkpoint (CACHEFILE UU(cachefile), void *header_v) ...@@ -3293,6 +3293,7 @@ brtheader_note_pin_by_checkpoint (CACHEFILE UU(cachefile), void *header_v)
//Only one can be pinned (only one checkpoint at a time), but not worth verifying. //Only one can be pinned (only one checkpoint at a time), but not worth verifying.
struct brt_header *h = header_v; struct brt_header *h = header_v;
BRT brt_to_pin; BRT brt_to_pin;
toku_brtheader_lock(h);
if (!toku_list_empty(&h->live_brts)) { if (!toku_list_empty(&h->live_brts)) {
brt_to_pin = toku_list_struct(toku_list_head(&h->live_brts), struct brt, live_brt_link); brt_to_pin = toku_list_struct(toku_list_head(&h->live_brts), struct brt, live_brt_link);
} }
...@@ -3301,6 +3302,7 @@ brtheader_note_pin_by_checkpoint (CACHEFILE UU(cachefile), void *header_v) ...@@ -3301,6 +3302,7 @@ brtheader_note_pin_by_checkpoint (CACHEFILE UU(cachefile), void *header_v)
assert(!toku_list_empty(&h->zombie_brts)); assert(!toku_list_empty(&h->zombie_brts));
brt_to_pin = toku_list_struct(toku_list_head(&h->zombie_brts), struct brt, zombie_brt_link); brt_to_pin = toku_list_struct(toku_list_head(&h->zombie_brts), struct brt, zombie_brt_link);
} }
toku_brtheader_unlock(h);
assert(!brt_to_pin->pinned_by_checkpoint); assert(!brt_to_pin->pinned_by_checkpoint);
brt_to_pin->pinned_by_checkpoint = 1; brt_to_pin->pinned_by_checkpoint = 1;
...@@ -3319,6 +3321,7 @@ brtheader_note_unpin_by_checkpoint (CACHEFILE UU(cachefile), void *header_v) ...@@ -3319,6 +3321,7 @@ brtheader_note_unpin_by_checkpoint (CACHEFILE UU(cachefile), void *header_v)
struct brt_header *h = header_v; struct brt_header *h = header_v;
BRT brt_to_unpin = NULL; BRT brt_to_unpin = NULL;
toku_brtheader_lock(h);
if (!toku_list_empty(&h->live_brts)) { if (!toku_list_empty(&h->live_brts)) {
struct toku_list *list; struct toku_list *list;
for (list = h->live_brts.next; list != &h->live_brts; list = list->next) { for (list = h->live_brts.next; list != &h->live_brts; list = list->next) {
...@@ -3343,6 +3346,7 @@ brtheader_note_unpin_by_checkpoint (CACHEFILE UU(cachefile), void *header_v) ...@@ -3343,6 +3346,7 @@ brtheader_note_unpin_by_checkpoint (CACHEFILE UU(cachefile), void *header_v)
} }
} }
} }
toku_brtheader_unlock(h);
assert(brt_to_unpin); assert(brt_to_unpin);
assert(brt_to_unpin->pinned_by_checkpoint); assert(brt_to_unpin->pinned_by_checkpoint);
brt_to_unpin->pinned_by_checkpoint = 0; //Unpin brt_to_unpin->pinned_by_checkpoint = 0; //Unpin
...@@ -3519,6 +3523,7 @@ toku_brt_db_delay_closed (BRT zombie, DB* db, int (*close_db)(DB*, u_int32_t), u ...@@ -3519,6 +3523,7 @@ toku_brt_db_delay_closed (BRT zombie, DB* db, int (*close_db)(DB*, u_int32_t), u
int toku_close_brt_lsn (BRT brt, char **error_string, BOOL oplsn_valid, LSN oplsn) { int toku_close_brt_lsn (BRT brt, char **error_string, BOOL oplsn_valid, LSN oplsn) {
assert(!toku_brt_zombie_needed(brt)); assert(!toku_brt_zombie_needed(brt));
assert(!brt->pinned_by_checkpoint);
int r; int r;
while (!toku_list_empty(&brt->cursors)) { while (!toku_list_empty(&brt->cursors)) {
BRT_CURSOR c = toku_list_struct(toku_list_pop(&brt->cursors), struct brt_cursor, cursors_link); BRT_CURSOR c = toku_list_struct(toku_list_pop(&brt->cursors), struct brt_cursor, cursors_link);
......
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