Commit bb3aebd0 authored by Barry Perlman's avatar Barry Perlman Committed by Yoni Fogel

[t:3982] #3982 Fix some broken upgrade mechanisms. Fix misnamed field in...

[t:3982] #3982 Fix some broken upgrade mechanisms.  Fix misnamed field in ydb.c.  Replace brt header field num_blocks_to_upgrade with explicit num_blocks_to_upgrade_13 and num_blocks_to_upgrade_14.  Add some TODO comments.

git-svn-id: file:///svn/toku/tokudb@35836 c7de825b-a66e-492c-adef-691d508d4ae1
parent e788915e
...@@ -330,6 +330,8 @@ struct brtnode { ...@@ -330,6 +330,8 @@ struct brtnode {
int height; /* height is always >= 0. 0 for leaf, >0 for nonleaf. */ int height; /* height is always >= 0. 0 for leaf, >0 for nonleaf. */
int dirty; int dirty;
u_int32_t fullhash; u_int32_t fullhash;
// TODO 3982
// uint32_t optimized_for_upgrade; // version number to which this leaf has been optimized, zero if never optimized for upgrade
int n_children; //for internal nodes, if n_children==TREE_FANOUT+1 then the tree needs to be rebalanced. int n_children; //for internal nodes, if n_children==TREE_FANOUT+1 then the tree needs to be rebalanced.
// for leaf nodes, represents number of basement nodes // for leaf nodes, represents number of basement nodes
unsigned int totalchildkeylens; unsigned int totalchildkeylens;
...@@ -460,7 +462,8 @@ struct brt_header { ...@@ -460,7 +462,8 @@ struct brt_header {
uint64_t time_of_creation; // time this tree was created uint64_t time_of_creation; // time this tree was created
uint64_t time_of_last_modification; // last time this header was serialized to disk (read from disk, overwritten when written to disk) uint64_t time_of_last_modification; // last time this header was serialized to disk (read from disk, overwritten when written to disk)
BOOL upgrade_brt_performed; // initially FALSE, set TRUE when brt has been fully updated (even though nodes may not have been) BOOL upgrade_brt_performed; // initially FALSE, set TRUE when brt has been fully updated (even though nodes may not have been)
int64_t num_blocks_to_upgrade; // Number of v13 blocks still not newest version. When we release layout 15 we may need to turn this to an array or add more variables. int64_t num_blocks_to_upgrade_13; // Number of v13 blocks still not newest version.
int64_t num_blocks_to_upgrade_14; // Number of v14 blocks still not newest version.
unsigned int nodesize; unsigned int nodesize;
unsigned int basementnodesize; unsigned int basementnodesize;
BLOCKNUM root; // roots of the dictionary BLOCKNUM root; // roots of the dictionary
......
...@@ -383,6 +383,7 @@ serialize_brtnode_info_size(BRTNODE node) ...@@ -383,6 +383,7 @@ serialize_brtnode_info_size(BRTNODE node)
retval += 4; // nodesize retval += 4; // nodesize
retval += 4; // flags retval += 4; // flags
retval += 4; // height; retval += 4; // height;
// retval += 4; // optimized_for_upgrade TODO 3982
retval += (3*8+1)*node->n_children; // subtree estimates for each child retval += (3*8+1)*node->n_children; // subtree estimates for each child
retval += node->totalchildkeylens; // total length of pivots retval += node->totalchildkeylens; // total length of pivots
retval += (node->n_children-1)*4; // encode length of each pivot retval += (node->n_children-1)*4; // encode length of each pivot
...@@ -408,6 +409,7 @@ static void serialize_brtnode_info(BRTNODE node, ...@@ -408,6 +409,7 @@ static void serialize_brtnode_info(BRTNODE node,
wbuf_nocrc_uint(&wb, node->nodesize); wbuf_nocrc_uint(&wb, node->nodesize);
wbuf_nocrc_uint(&wb, node->flags); wbuf_nocrc_uint(&wb, node->flags);
wbuf_nocrc_int (&wb, node->height); wbuf_nocrc_int (&wb, node->height);
// TODO 3982 wbuf_nocrc_int (&wb, node->optimized_for_upgrade);
// subtree estimates of each child // subtree estimates of each child
for (int i = 0; i < node->n_children; i++) { for (int i = 0; i < node->n_children; i++) {
wbuf_nocrc_ulonglong(&wb, BP_SUBTREE_EST(node,i).nkeys); wbuf_nocrc_ulonglong(&wb, BP_SUBTREE_EST(node,i).nkeys);
...@@ -1105,6 +1107,7 @@ deserialize_brtnode_info( ...@@ -1105,6 +1107,7 @@ deserialize_brtnode_info(
node->nodesize = rbuf_int(&rb); node->nodesize = rbuf_int(&rb);
node->flags = rbuf_int(&rb); node->flags = rbuf_int(&rb);
node->height = rbuf_int(&rb); node->height = rbuf_int(&rb);
// node->optimized_for_upgrade = rbuf_int(&rb); TODO 3982
// now create the basement nodes or childinfos, depending on whether this is a // now create the basement nodes or childinfos, depending on whether this is a
// leaf node or internal node // leaf node or internal node
...@@ -1602,6 +1605,7 @@ serialize_brt_header_min_size (u_int32_t version) { ...@@ -1602,6 +1605,7 @@ serialize_brt_header_min_size (u_int32_t version) {
switch(version) { switch(version) {
case BRT_LAYOUT_VERSION_15: case BRT_LAYOUT_VERSION_15:
size += 4; // basement node size size += 4; // basement node size
size += 8; // num_blocks_to_upgrade_14 (previously num_blocks_to_upgrade, now one int each for upgrade from 13, 14
case BRT_LAYOUT_VERSION_14: case BRT_LAYOUT_VERSION_14:
size += 8; //TXNID that created size += 8; //TXNID that created
case BRT_LAYOUT_VERSION_13: case BRT_LAYOUT_VERSION_13:
...@@ -1663,7 +1667,8 @@ int toku_serialize_brt_header_to_wbuf (struct wbuf *wbuf, struct brt_header *h, ...@@ -1663,7 +1667,8 @@ int toku_serialize_brt_header_to_wbuf (struct wbuf *wbuf, struct brt_header *h,
wbuf_int(wbuf, h->build_id_original); wbuf_int(wbuf, h->build_id_original);
wbuf_ulonglong(wbuf, h->time_of_creation); wbuf_ulonglong(wbuf, h->time_of_creation);
wbuf_ulonglong(wbuf, h->time_of_last_modification); wbuf_ulonglong(wbuf, h->time_of_last_modification);
wbuf_ulonglong(wbuf, h->num_blocks_to_upgrade); wbuf_ulonglong(wbuf, h->num_blocks_to_upgrade_13);
wbuf_ulonglong(wbuf, h->num_blocks_to_upgrade_14);
wbuf_TXNID(wbuf, h->root_xid_that_created); wbuf_TXNID(wbuf, h->root_xid_that_created);
wbuf_int(wbuf, h->basementnodesize); wbuf_int(wbuf, h->basementnodesize);
u_int32_t checksum = x1764_finish(&wbuf->checksum); u_int32_t checksum = x1764_finish(&wbuf->checksum);
...@@ -1925,7 +1930,8 @@ deserialize_brtheader (int fd, struct rbuf *rb, struct brt_header **brth) { ...@@ -1925,7 +1930,8 @@ deserialize_brtheader (int fd, struct rbuf *rb, struct brt_header **brth) {
h->build_id_original = rbuf_int(&rc); h->build_id_original = rbuf_int(&rc);
h->time_of_creation = rbuf_ulonglong(&rc); h->time_of_creation = rbuf_ulonglong(&rc);
h->time_of_last_modification = rbuf_ulonglong(&rc); h->time_of_last_modification = rbuf_ulonglong(&rc);
h->num_blocks_to_upgrade = rbuf_ulonglong(&rc); h->num_blocks_to_upgrade_13 = rbuf_ulonglong(&rc);
h->num_blocks_to_upgrade_14 = rbuf_ulonglong(&rc);
if (h->layout_version >= BRT_LAYOUT_VERSION_14) { if (h->layout_version >= BRT_LAYOUT_VERSION_14) {
// at this layer, this new field is the only difference between versions 13 and 14 // at this layer, this new field is the only difference between versions 13 and 14
...@@ -1991,7 +1997,7 @@ deserialize_brtheader_versioned (int fd, struct rbuf *rb, struct brt_header **br ...@@ -1991,7 +1997,7 @@ deserialize_brtheader_versioned (int fd, struct rbuf *rb, struct brt_header **br
h->upgrade_brt_performed = FALSE; h->upgrade_brt_performed = FALSE;
if (upgrade) { if (upgrade) {
toku_brtheader_lock(h); toku_brtheader_lock(h);
h->num_blocks_to_upgrade = toku_block_get_blocks_in_use_unlocked(h->blocktable); //Total number of blocks h->num_blocks_to_upgrade_13 = toku_block_get_blocks_in_use_unlocked(h->blocktable); //Total number of blocks
if (version == BRT_LAYOUT_VERSION_13) { if (version == BRT_LAYOUT_VERSION_13) {
// write upgraded descriptor to disk if descriptor upgraded from version 13 // write upgraded descriptor to disk if descriptor upgraded from version 13
rval = write_descriptor_to_disk_unlocked(h, &(h->descriptor), fd); rval = write_descriptor_to_disk_unlocked(h, &(h->descriptor), fd);
......
...@@ -1199,6 +1199,8 @@ toku_initialize_empty_brtnode (BRTNODE n, BLOCKNUM nodename, int height, int num ...@@ -1199,6 +1199,8 @@ toku_initialize_empty_brtnode (BRTNODE n, BLOCKNUM nodename, int height, int num
n->layout_version_original = layout_version; n->layout_version_original = layout_version;
n->layout_version_read_from_disk = layout_version; n->layout_version_read_from_disk = layout_version;
n->height = height; n->height = height;
// TODO 3982
// n->optimized_for_upgrade = 0;
n->dirty = 1; n->dirty = 1;
n->totalchildkeylens = 0; n->totalchildkeylens = 0;
n->childkeys = 0; n->childkeys = 0;
...@@ -2315,7 +2317,8 @@ brt_leaf_put_cmd ( ...@@ -2315,7 +2317,8 @@ brt_leaf_put_cmd (
} }
case BRT_OPTIMIZE_FOR_UPGRADE: case BRT_OPTIMIZE_FOR_UPGRADE:
*made_change = 1; *made_change = 1;
bn->optimized_for_upgrade = *((uint32_t*)(cmd->u.id.val->data)); // record version of software that sent the optimize_for_upgrade message // TODO 4053: Record version of software that sent the optimize_for_upgrade message, but that goes in the
// node's optimize_for_upgrade field, not in the basement.
// fall through so that optimize_for_upgrade performs rest of the optimize logic // fall through so that optimize_for_upgrade performs rest of the optimize logic
case BRT_COMMIT_BROADCAST_ALL: case BRT_COMMIT_BROADCAST_ALL:
case BRT_OPTIMIZE: case BRT_OPTIMIZE:
...@@ -4147,7 +4150,8 @@ brt_init_header_partial (BRT t, TOKUTXN txn) { ...@@ -4147,7 +4150,8 @@ brt_init_header_partial (BRT t, TOKUTXN txn) {
t->h->cf = t->cf; t->h->cf = t->cf;
t->h->nodesize=t->nodesize; t->h->nodesize=t->nodesize;
t->h->basementnodesize=t->basementnodesize; t->h->basementnodesize=t->basementnodesize;
t->h->num_blocks_to_upgrade = 0; t->h->num_blocks_to_upgrade_13 = 0;
t->h->num_blocks_to_upgrade_14 = 0;
t->h->root_xid_that_created = txn ? txn->ancestor_txnid64 : TXNID_NONE; t->h->root_xid_that_created = txn ? txn->ancestor_txnid64 : TXNID_NONE;
compute_and_fill_remembered_hash(t); compute_and_fill_remembered_hash(t);
......
...@@ -2229,7 +2229,7 @@ env_get_engine_status_text(DB_ENV * env, char * buff, int bufsiz) { ...@@ -2229,7 +2229,7 @@ env_get_engine_status_text(DB_ENV * env, char * buff, int bufsiz) {
n += snprintf(buff + n, bufsiz - n, "upgrade_header %"PRIu64"\n", engstat.upgrade_header); n += snprintf(buff + n, bufsiz - n, "upgrade_header %"PRIu64"\n", engstat.upgrade_header);
n += snprintf(buff + n, bufsiz - n, "upgrade_nonleaf %"PRIu64"\n", engstat.upgrade_nonleaf); n += snprintf(buff + n, bufsiz - n, "upgrade_nonleaf %"PRIu64"\n", engstat.upgrade_nonleaf);
n += snprintf(buff + n, bufsiz - n, "upgrade_leaf %"PRIu64"\n", engstat.upgrade_leaf); n += snprintf(buff + n, bufsiz - n, "upgrade_leaf %"PRIu64"\n", engstat.upgrade_leaf);
n += snprintf(buff + n, bufsiz - n, "optimized_for_upgrade_14 %"PRIu64"\n", engstat.optimized_for_upgrade); n += snprintf(buff + n, bufsiz - n, "optimized_for_upgrade %"PRIu64"\n", engstat.optimized_for_upgrade);
n += snprintf(buff + n, bufsiz - n, "original_ver %"PRIu64"\n", engstat.original_ver); n += snprintf(buff + n, bufsiz - n, "original_ver %"PRIu64"\n", engstat.original_ver);
n += snprintf(buff + n, bufsiz - n, "ver_at_startup %"PRIu64"\n", engstat.ver_at_startup); n += snprintf(buff + n, bufsiz - n, "ver_at_startup %"PRIu64"\n", engstat.ver_at_startup);
n += snprintf(buff + n, bufsiz - n, "last_lsn_v13 %"PRIu64"\n", engstat.last_lsn_v13); n += snprintf(buff + n, bufsiz - n, "last_lsn_v13 %"PRIu64"\n", engstat.last_lsn_v13);
......
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