Commit ba1bd129 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Can recover after 10 insertions. Addresses #27.

git-svn-id: file:///svn/tokudb@945 c7de825b-a66e-492c-adef-691d508d4ae1
parent a5424332
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# GCOV_FLAGS = -fprofile-arcs -ftest-coverage # GCOV_FLAGS = -fprofile-arcs -ftest-coverage
# PROF_FLAGS = -pg # PROF_FLAGS = -pg
# OPTFLAGS = -O2 OPTFLAGS = -O2
ifeq ($(CYGWIN),cygwin) ifeq ($(CYGWIN),cygwin)
else else
......
...@@ -100,6 +100,7 @@ void toku_serialize_brtnode_to(int fd, DISKOFF off, DISKOFF size, BRTNODE node) ...@@ -100,6 +100,7 @@ void toku_serialize_brtnode_to(int fd, DISKOFF off, DISKOFF size, BRTNODE node)
unsigned int calculated_size = toku_serialize_brtnode_size(node); unsigned int calculated_size = toku_serialize_brtnode_size(node);
//char buf[size]; //char buf[size];
char *MALLOC_N(size,buf); char *MALLOC_N(size,buf);
toku_verify_counts(node);
assert(size>0); assert(size>0);
wbuf_init(&w, buf, size); wbuf_init(&w, buf, size);
//printf("%s:%d serializing %lld w height=%d p0=%p\n", __FILE__, __LINE__, off, node->height, node->mdicts[0]); //printf("%s:%d serializing %lld w height=%d p0=%p\n", __FILE__, __LINE__, off, node->height, node->mdicts[0]);
......
...@@ -1675,7 +1675,7 @@ int toku_pma_move_indices (PMA pma, INTPAIRARRAY fromto) { ...@@ -1675,7 +1675,7 @@ int toku_pma_move_indices (PMA pma, INTPAIRARRAY fromto) {
// We must slide things to the right. // We must slide things to the right.
// Find the next index that does want to go to the left // Find the next index that does want to go to the left
u_int32_t j; u_int32_t j;
for (j=i+1; j<fromto.size && fromto.array[j].b <= fromto.array[j].a; j++) { for (j=i+1; j<fromto.size && fromto.array[j].a < fromto.array[j].b; j++) {
/*nothing */ /*nothing */
} }
// everything from i (inclusive) to j (exclusive) wants to slide to the right. // everything from i (inclusive) to j (exclusive) wants to slide to the right.
......
...@@ -107,6 +107,9 @@ static void toku_recover_newbrtnode (struct logtype_newbrtnode *c) { ...@@ -107,6 +107,9 @@ static void toku_recover_newbrtnode (struct logtype_newbrtnode *c) {
} }
// Now put it in the cachetable // Now put it in the cachetable
toku_cachetable_put(cf, c->diskoff, n, toku_serialize_brtnode_size(n), toku_brtnode_flush_callback, toku_brtnode_fetch_callback, 0); toku_cachetable_put(cf, c->diskoff, n, toku_serialize_brtnode_size(n), toku_brtnode_flush_callback, toku_brtnode_fetch_callback, 0);
toku_verify_counts(n);
r = toku_cachetable_unpin(cf, c->diskoff, 1, toku_serialize_brtnode_size(n)); r = toku_cachetable_unpin(cf, c->diskoff, 1, toku_serialize_brtnode_size(n));
assert(r==0); assert(r==0);
} }
...@@ -144,11 +147,15 @@ static void toku_recover_insertinleaf (struct logtype_insertinleaf *c) { ...@@ -144,11 +147,15 @@ static void toku_recover_insertinleaf (struct logtype_insertinleaf *c) {
assert(r==0); assert(r==0);
BRTNODE node = node_v; BRTNODE node = node_v;
assert(node->height==0); assert(node->height==0);
toku_verify_counts(node);
DBT key,data; DBT key,data;
r = toku_pma_set_at_index(node->u.l.buffer, c->pmaidx, toku_fill_dbt(&key, c->key.data, c->key.len), toku_fill_dbt(&data, c->data.data, c->data.len)); r = toku_pma_set_at_index(node->u.l.buffer, c->pmaidx, toku_fill_dbt(&key, c->key.data, c->key.len), toku_fill_dbt(&data, c->data.data, c->data.len));
assert(r==0); assert(r==0);
node->local_fingerprint += node->rand4fingerprint*toku_calccrc32_kvpair(c->key.data, c->key.len,c->data.data, c->data.len); node->local_fingerprint += node->rand4fingerprint*toku_calccrc32_kvpair(c->key.data, c->key.len,c->data.data, c->data.len);
node->u.l.n_bytes_in_buffer += KEY_VALUE_OVERHEAD + c->key.len + c->data.len; node->u.l.n_bytes_in_buffer += PMA_ITEM_OVERHEAD + KEY_VALUE_OVERHEAD + c->key.len + c->data.len;
toku_verify_counts(node);
r = toku_cachetable_unpin(cf, c->diskoff, 1, toku_serialize_brtnode_size(node)); r = toku_cachetable_unpin(cf, c->diskoff, 1, toku_serialize_brtnode_size(node));
assert(r==0); assert(r==0);
} }
...@@ -166,6 +173,8 @@ static void toku_recover_resizepma (struct logtype_resizepma *c) { ...@@ -166,6 +173,8 @@ static void toku_recover_resizepma (struct logtype_resizepma *c) {
r = toku_resize_pma_exactly (node->u.l.buffer, c->oldsize, c->newsize); r = toku_resize_pma_exactly (node->u.l.buffer, c->oldsize, c->newsize);
assert(r==0); assert(r==0);
toku_verify_counts(node);
r = toku_cachetable_unpin(cf, c->diskoff, 1, toku_serialize_brtnode_size(node)); r = toku_cachetable_unpin(cf, c->diskoff, 1, toku_serialize_brtnode_size(node));
assert(r==0); assert(r==0);
} }
...@@ -190,6 +199,8 @@ static void toku_recover_pmadistribute (struct logtype_pmadistribute *c) { ...@@ -190,6 +199,8 @@ static void toku_recover_pmadistribute (struct logtype_pmadistribute *c) {
r = toku_pma_move_indices (node->u.l.buffer, c->fromto); r = toku_pma_move_indices (node->u.l.buffer, c->fromto);
// The bytes in bufer and fingerprint shouldn't change // The bytes in bufer and fingerprint shouldn't change
toku_verify_counts(node);
r = toku_cachetable_unpin(cf, c->diskoff, 1, toku_serialize_brtnode_size(node)); r = toku_cachetable_unpin(cf, c->diskoff, 1, toku_serialize_brtnode_size(node));
assert(r==0); assert(r==0);
} }
...@@ -213,7 +224,7 @@ int main (int argc, char *argv[]) { ...@@ -213,7 +224,7 @@ int main (int argc, char *argv[]) {
r=toku_read_and_print_logmagic(f, &version); r=toku_read_and_print_logmagic(f, &version);
assert(r==0 && version==0); assert(r==0 && version==0);
while ((r = toku_log_fread(f, &le))==0) { while ((r = toku_log_fread(f, &le))==0) {
printf("Got cmd %c\n", le.cmd); printf("%lld: Got cmd %c\n", le.u.commit.lsn.lsn, le.cmd);
logtype_dispatch(le, toku_recover_); logtype_dispatch(le, toku_recover_);
} }
if (r!=EOF) { if (r!=EOF) {
......
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