Commit 82a43c14 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#3129 fix recover of insert multiple and delete multiple with a valid source filenum closes[t:3129]

git-svn-id: file:///svn/toku/tokudb@26506 c7de825b-a66e-492c-adef-691d508d4ae1
parent 1e068378
...@@ -839,38 +839,42 @@ static int toku_recover_enq_insert_multiple (struct logtype_enq_insert_multiple ...@@ -839,38 +839,42 @@ static int toku_recover_enq_insert_multiple (struct logtype_enq_insert_multiple
if (r == 0) if (r == 0)
src_db = tuple->brt->db; src_db = tuple->brt->db;
else else
do_inserts = FALSE; // src file was probably deleted do_inserts = FALSE; // src file was probably deleted, #3129
} }
} }
DBT src_key, src_val, dest_key, dest_val;
toku_fill_dbt(&src_key, l->src_key.data, l->src_key.len); if (do_inserts) {
toku_fill_dbt(&src_val, l->src_val.data, l->src_val.len); DBT src_key, src_val, dest_key, dest_val;
toku_init_dbt_flags(&dest_key, DB_DBT_REALLOC); toku_fill_dbt(&src_key, l->src_key.data, l->src_key.len);
toku_init_dbt_flags(&dest_val, DB_DBT_REALLOC); toku_fill_dbt(&src_val, l->src_val.data, l->src_val.len);
toku_init_dbt_flags(&dest_key, DB_DBT_REALLOC);
for (uint32_t file = 0; do_inserts && file < l->dest_filenums.num; file++) { toku_init_dbt_flags(&dest_val, DB_DBT_REALLOC);
struct file_map_tuple *tuple = NULL;
r = file_map_find(&renv->fmap, l->dest_filenums.filenums[file], &tuple); for (uint32_t file = 0; file < l->dest_filenums.num; file++) {
if (r==0) { struct file_map_tuple *tuple = NULL;
// We found the cachefile. (maybe) Do the insert. r = file_map_find(&renv->fmap, l->dest_filenums.filenums[file], &tuple);
DB *db = tuple->brt->db; if (r==0) {
r = renv->generate_row_for_put(db, src_db, &dest_key, &dest_val, &src_key, &src_val); // We found the cachefile. (maybe) Do the insert.
assert(r==0); DB *db = tuple->brt->db;
r = toku_brt_maybe_insert(tuple->brt, &dest_key, &dest_val, txn, TRUE, l->lsn, FALSE, BRT_INSERT); r = renv->generate_row_for_put(db, src_db, &dest_key, &dest_val, &src_key, &src_val);
assert(r == 0); assert(r==0);
r = toku_brt_maybe_insert(tuple->brt, &dest_key, &dest_val, txn, TRUE, l->lsn, FALSE, BRT_INSERT);
assert(r == 0);
//flags==0 means generate_row_for_put callback changed it //flags==0 means generate_row_for_put callback changed it
//(and freed any memory necessary to do so) so that values are now stored //(and freed any memory necessary to do so) so that values are now stored
//in temporary memory that does not need to be freed. We need to continue //in temporary memory that does not need to be freed. We need to continue
//using DB_DBT_REALLOC however. //using DB_DBT_REALLOC however.
if (dest_key.flags == 0) if (dest_key.flags == 0)
toku_init_dbt_flags(&dest_key, DB_DBT_REALLOC); toku_init_dbt_flags(&dest_key, DB_DBT_REALLOC);
if (dest_val.flags == 0) if (dest_val.flags == 0)
toku_init_dbt_flags(&dest_val, DB_DBT_REALLOC); toku_init_dbt_flags(&dest_val, DB_DBT_REALLOC);
}
} }
if (dest_key.data) toku_free(dest_key.data); //TODO: #2321 May need windows hack
if (dest_val.data) toku_free(dest_val.data); //TODO: #2321 May need windows hack
} }
if (dest_key.data) toku_free(dest_key.data); //TODO: #2321 May need windows hack
if (dest_val.data) toku_free(dest_val.data); //TODO: #2321 May need windows hack
return 0; return 0;
} }
...@@ -897,33 +901,36 @@ static int toku_recover_enq_delete_multiple (struct logtype_enq_delete_multiple ...@@ -897,33 +901,36 @@ static int toku_recover_enq_delete_multiple (struct logtype_enq_delete_multiple
if (r == 0) if (r == 0)
src_db = tuple->brt->db; src_db = tuple->brt->db;
else else
do_deletes = FALSE; // src file was probably deleted do_deletes = FALSE; // src file was probably deleted, #3129
} }
} }
DBT src_key, src_val, dest_key; if (do_deletes) {
toku_fill_dbt(&src_key, l->src_key.data, l->src_key.len); DBT src_key, src_val, dest_key;
toku_fill_dbt(&src_val, l->src_val.data, l->src_val.len); toku_fill_dbt(&src_key, l->src_key.data, l->src_key.len);
toku_init_dbt_flags(&dest_key, DB_DBT_REALLOC); toku_fill_dbt(&src_val, l->src_val.data, l->src_val.len);
toku_init_dbt_flags(&dest_key, DB_DBT_REALLOC);
for (uint32_t file = 0; do_deletes && file < l->dest_filenums.num; file++) {
struct file_map_tuple *tuple = NULL; for (uint32_t file = 0; file < l->dest_filenums.num; file++) {
r = file_map_find(&renv->fmap, l->dest_filenums.filenums[file], &tuple); struct file_map_tuple *tuple = NULL;
if (r==0) { r = file_map_find(&renv->fmap, l->dest_filenums.filenums[file], &tuple);
// We found the cachefile. (maybe) Do the delete. if (r==0) {
DB *db = tuple->brt->db; // We found the cachefile. (maybe) Do the delete.
r = renv->generate_row_for_del(db, src_db, &dest_key, &src_key, &src_val); DB *db = tuple->brt->db;
assert(r==0); r = renv->generate_row_for_del(db, src_db, &dest_key, &src_key, &src_val);
r = toku_brt_maybe_delete(tuple->brt, &dest_key, txn, TRUE, l->lsn, FALSE); assert(r==0);
assert(r == 0); r = toku_brt_maybe_delete(tuple->brt, &dest_key, txn, TRUE, l->lsn, FALSE);
assert(r == 0);
//flags==0 indicates the return values are stored in temporary memory that does //flags==0 indicates the return values are stored in temporary memory that does
//not need to be freed. We need to continue using DB_DBT_REALLOC however. //not need to be freed. We need to continue using DB_DBT_REALLOC however.
if (dest_key.flags == 0) if (dest_key.flags == 0)
toku_init_dbt_flags(&dest_key, DB_DBT_REALLOC); toku_init_dbt_flags(&dest_key, DB_DBT_REALLOC);
}
} }
if (dest_key.flags & DB_DBT_REALLOC && dest_key.data) toku_free(dest_key.data); //TODO: #2321 May need windows hack
} }
if (dest_key.flags & DB_DBT_REALLOC && dest_key.data) toku_free(dest_key.data); //TODO: #2321 May need windows hack
return 0; return 0;
} }
......
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