Commit 308fff45 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

closes #5171, don't reference cachefile or fd in flush_callback when calling...

closes #5171, don't reference cachefile or fd in flush_callback when calling cachetable_free_pair, fix cachetable-test2 and toku_rollback_flush_callback to take this into account

git-svn-id: file:///svn/toku/tokudb@45100 c7de825b-a66e-492c-adef-691d508d4ae1
parent 23f9000a
...@@ -1014,7 +1014,6 @@ static void cachetable_remove_pair (CACHETABLE ct, PAIR p) { ...@@ -1014,7 +1014,6 @@ static void cachetable_remove_pair (CACHETABLE ct, PAIR p) {
static void cachetable_free_pair(CACHETABLE ct, PAIR p) { static void cachetable_free_pair(CACHETABLE ct, PAIR p) {
// helgrind // helgrind
CACHETABLE_FLUSH_CALLBACK flush_callback = p->flush_callback; CACHETABLE_FLUSH_CALLBACK flush_callback = p->flush_callback;
CACHEFILE cachefile = p->cachefile;
CACHEKEY key = p->key; CACHEKEY key = p->key;
void *value = p->value_data; void *value = p->value_data;
void* disk_data = p->disk_data; void* disk_data = p->disk_data;
...@@ -1026,7 +1025,11 @@ static void cachetable_free_pair(CACHETABLE ct, PAIR p) { ...@@ -1026,7 +1025,11 @@ static void cachetable_free_pair(CACHETABLE ct, PAIR p) {
PAIR_ATTR new_attr = p->attr; PAIR_ATTR new_attr = p->attr;
// Note that flush_callback is called with write_me FALSE, so the only purpose of this // Note that flush_callback is called with write_me FALSE, so the only purpose of this
// call is to tell the brt layer to evict the node (keep_me is FALSE). // call is to tell the brt layer to evict the node (keep_me is FALSE).
flush_callback(cachefile, cachefile->fd, key, value, &disk_data, write_extraargs, old_attr, &new_attr, FALSE, FALSE, TRUE, FALSE); // Also, because we have already removed the PAIR from the cachetable in
// cachetable_remove_pair, we cannot pass in p->cachefile and p->cachefile->fd
// for the first two parameters, as these may be invalid (#5171), so, we
// pass in NULL and -1, dummy values
flush_callback(NULL, -1, key, value, &disk_data, write_extraargs, old_attr, &new_attr, FALSE, FALSE, TRUE, FALSE);
cachetable_lock(ct); cachetable_lock(ct);
......
...@@ -31,11 +31,10 @@ void toku_rollback_flush_callback (CACHEFILE cachefile, int fd, BLOCKNUM logname ...@@ -31,11 +31,10 @@ void toku_rollback_flush_callback (CACHEFILE cachefile, int fd, BLOCKNUM logname
ROLLBACK_LOG_NODE log = rollback_v; ROLLBACK_LOG_NODE log = rollback_v;
FT h = extraargs; FT h = extraargs;
assert(h->cf == cachefile);
assert(log->blocknum.b==logname.b); assert(log->blocknum.b==logname.b);
if (write_me && !h->panic) { if (write_me && !h->panic) {
int n_workitems, n_threads; int n_workitems, n_threads;
assert(h->cf == cachefile);
toku_cachefile_get_workqueue_load(cachefile, &n_workitems, &n_threads); toku_cachefile_get_workqueue_load(cachefile, &n_workitems, &n_threads);
r = toku_serialize_rollback_log_to(fd, log->blocknum, log, h, n_workitems, n_threads, for_checkpoint); r = toku_serialize_rollback_log_to(fd, log->blocknum, log, h, n_workitems, n_threads, for_checkpoint);
......
...@@ -36,7 +36,8 @@ static const int test_object_size = 1; ...@@ -36,7 +36,8 @@ static const int test_object_size = 1;
static CACHETABLE ct; static CACHETABLE ct;
enum { N_PRESENT_LIMIT = 4, TRIALS=20000, N_FILES=2 }; // increasing N_FILES may break test
enum { N_PRESENT_LIMIT = 4, TRIALS=20000, N_FILES=1 };
static int n_present=0; static int n_present=0;
static struct present_items { static struct present_items {
CACHEKEY key; CACHEKEY key;
...@@ -71,7 +72,7 @@ static void item_becomes_not_present(CACHEFILE cf, CACHEKEY key) { ...@@ -71,7 +72,7 @@ static void item_becomes_not_present(CACHEFILE cf, CACHEKEY key) {
test_mutex_lock(); test_mutex_lock();
assert(n_present<=N_PRESENT_LIMIT); assert(n_present<=N_PRESENT_LIMIT);
for (i=0; i<n_present; i++) { for (i=0; i<n_present; i++) {
if (present_items[i].cf==cf && present_items[i].key.b==key.b) { if (present_items[i].key.b==key.b) {
present_items[i]=present_items[n_present-1]; present_items[i]=present_items[n_present-1];
n_present--; n_present--;
test_mutex_unlock(); test_mutex_unlock();
......
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