diff options
Diffstat (limited to 'src/third_party/wiredtiger/src/meta/meta_ckpt.c')
-rw-r--r-- | src/third_party/wiredtiger/src/meta/meta_ckpt.c | 87 |
1 files changed, 57 insertions, 30 deletions
diff --git a/src/third_party/wiredtiger/src/meta/meta_ckpt.c b/src/third_party/wiredtiger/src/meta/meta_ckpt.c index a5373dabccc..65dae99e577 100644 --- a/src/third_party/wiredtiger/src/meta/meta_ckpt.c +++ b/src/third_party/wiredtiger/src/meta/meta_ckpt.c @@ -11,7 +11,6 @@ static int __ckpt_last(WT_SESSION_IMPL *, const char *, WT_CKPT *); static int __ckpt_last_name(WT_SESSION_IMPL *, const char *, const char **); static int __ckpt_load(WT_SESSION_IMPL *, WT_CONFIG_ITEM *, WT_CONFIG_ITEM *, WT_CKPT *); -static int __ckpt_load_blk_mods(WT_SESSION_IMPL *, const char *, WT_CKPT *); static int __ckpt_named(WT_SESSION_IMPL *, const char *, const char *, WT_CKPT *); static int __ckpt_set(WT_SESSION_IMPL *, const char *, const char *, bool); static int __ckpt_version_chk(WT_SESSION_IMPL *, const char *, const char *); @@ -73,6 +72,11 @@ __ckpt_load_blk_mods(WT_SESSION_IMPL *session, const char *config, WT_CKPT *ckpt blk_mod->nbits = (uint64_t)b.val; WT_RET(__wt_config_subgets(session, &v, "offset", &b)); blk_mod->offset = (uint64_t)b.val; + WT_RET(__wt_config_subgets(session, &v, "rename", &b)); + if (b.val) + F_SET(blk_mod, WT_BLOCK_MODS_RENAME); + else + F_CLR(blk_mod, WT_BLOCK_MODS_RENAME); ret = __wt_config_subgets(session, &v, "blocks", &b); WT_RET_NOTFOUND_OK(ret); if (ret != WT_NOTFOUND) { @@ -388,7 +392,7 @@ __ckpt_compare_order(const void *a, const void *b) * information. */ static int -__ckpt_valid_blk_mods(WT_SESSION_IMPL *session, WT_CKPT *ckpt) +__ckpt_valid_blk_mods(WT_SESSION_IMPL *session, WT_CKPT *ckpt, bool rename) { WT_BLKINCR *blk; WT_BLOCK_MODS *blk_mod; @@ -426,6 +430,10 @@ __ckpt_valid_blk_mods(WT_SESSION_IMPL *session, WT_CKPT *ckpt) setup = true; } + /* If we are keeping or setting up an entry on a rename, set the flag. */ + if (rename && (!free || setup)) + F_SET(blk_mod, WT_BLOCK_MODS_RENAME); + /* Free any old information if we need to do so. */ if (free && F_ISSET(blk_mod, WT_BLOCK_MODS_VALID)) { __wt_free(session, blk_mod->id_str); @@ -450,6 +458,32 @@ __ckpt_valid_blk_mods(WT_SESSION_IMPL *session, WT_CKPT *ckpt) } /* + * __wt_meta_blk_mods_load -- + * Load the block mods for a given checkpoint and set up all the information to store. + */ +int +__wt_meta_blk_mods_load(WT_SESSION_IMPL *session, const char *config, WT_CKPT *ckpt, bool rename) +{ + /* + * Load most recent checkpoint backup blocks to this checkpoint. + */ + WT_RET(__ckpt_load_blk_mods(session, config, ckpt)); + + WT_RET(__wt_meta_block_metadata(session, config, ckpt)); + + /* + * Set the add-a-checkpoint flag, and if we're doing incremental backups, request a list of the + * checkpoint's modified blocks from the block manager. + */ + F_SET(ckpt, WT_CKPT_ADD); + if (F_ISSET(S2C(session), WT_CONN_INCR_BACKUP)) { + F_SET(ckpt, WT_CKPT_BLOCK_MODS); + WT_RET(__ckpt_valid_blk_mods(session, ckpt, rename)); + } + return (0); +} + +/* * __wt_meta_ckptlist_get -- * Load all available checkpoint information for a file. */ @@ -523,22 +557,7 @@ __wt_meta_ckptlist_get( __wt_atomic_cas64(&conn->ckpt_most_recent, most_recent, ckpt->sec)) break; } - /* - * Load most recent checkpoint backup blocks to this checkpoint. - */ - WT_ERR(__ckpt_load_blk_mods(session, config, ckpt)); - - WT_ERR(__wt_meta_block_metadata(session, config, ckpt)); - - /* - * Set the add-a-checkpoint flag, and if we're doing incremental backups, request a list of - * the checkpoint's modified blocks from the block manager. - */ - F_SET(ckpt, WT_CKPT_ADD); - if (F_ISSET(conn, WT_CONN_INCR_BACKUP)) { - F_SET(ckpt, WT_CKPT_BLOCK_MODS); - WT_ERR(__ckpt_valid_blk_mods(session, ckpt)); - } + WT_ERR(__wt_meta_blk_mods_load(session, config, ckpt, false)); } /* Return the array to our caller. */ @@ -764,11 +783,11 @@ __wt_meta_ckptlist_to_meta(WT_SESSION_IMPL *session, WT_CKPT *ckptbase, WT_ITEM } /* - * __ckpt_blkmod_to_meta -- + * __wt_ckpt_blkmod_to_meta -- * Add in any modification block string needed, including an empty one. */ -static int -__ckpt_blkmod_to_meta(WT_SESSION_IMPL *session, WT_ITEM *buf, WT_CKPT *ckpt) +int +__wt_ckpt_blkmod_to_meta(WT_SESSION_IMPL *session, WT_ITEM *buf, WT_CKPT *ckpt) { WT_BLOCK_MODS *blk; WT_ITEM bitstring; @@ -797,10 +816,11 @@ __ckpt_blkmod_to_meta(WT_SESSION_IMPL *session, WT_ITEM *buf, WT_CKPT *ckpt) if (!F_ISSET(blk, WT_BLOCK_MODS_VALID)) continue; WT_RET(__wt_raw_to_hex(session, blk->bitstring.data, blk->bitstring.size, &bitstring)); - WT_RET(__wt_buf_catfmt(session, buf, "%s\"%s\"=(id=%" PRIu32 ",granularity=%" PRIu64 - ",nbits=%" PRIu64 ",offset=%" PRIu64 ",blocks=%.*s)", + WT_RET(__wt_buf_catfmt(session, buf, + "%s\"%s\"=(id=%" PRIu32 ",granularity=%" PRIu64 ",nbits=%" PRIu64 ",offset=%" PRIu64 + ",rename=%d,blocks=%.*s)", i == 0 ? "" : ",", blk->id_str, i, blk->granularity, blk->nbits, blk->offset, - (int)bitstring.size, (char *)bitstring.data)); + F_ISSET(blk, WT_BLOCK_MODS_RENAME) ? 1 : 0, (int)bitstring.size, (char *)bitstring.data)); /* The hex string length should match the appropriate number of bits. */ WT_ASSERT(session, (blk->nbits >> 2) <= bitstring.size); __wt_buf_free(session, &bitstring); @@ -828,7 +848,7 @@ __wt_meta_ckptlist_set( /* Add backup block modifications for any added checkpoint. */ WT_CKPT_FOREACH (ckptbase, ckpt) if (F_ISSET(ckpt, WT_CKPT_ADD)) - WT_ERR(__ckpt_blkmod_to_meta(session, buf, ckpt)); + WT_ERR(__wt_ckpt_blkmod_to_meta(session, buf, ckpt)); has_lsn = ckptlsn != NULL; if (ckptlsn != NULL) @@ -897,12 +917,9 @@ __wt_meta_sysinfo_set(WT_SESSION_IMPL *session) { WT_DECL_ITEM(buf); WT_DECL_RET; - char hex_timestamp[2 * sizeof(wt_timestamp_t) + 2]; + char hex_timestamp[WT_TS_HEX_STRING_SIZE]; WT_ERR(__wt_scr_alloc(session, 0, &buf)); - hex_timestamp[0] = '0'; - hex_timestamp[1] = '\0'; - /* * We need to record the timestamp of the checkpoint in the metadata. The timestamp value is set * at a higher level, either in checkpoint or in recovery. @@ -917,10 +934,20 @@ __wt_meta_sysinfo_set(WT_SESSION_IMPL *session) if (strcmp(hex_timestamp, "0") == 0) WT_ERR_NOTFOUND_OK(__wt_metadata_remove(session, WT_SYSTEM_CKPT_URI), false); else { - WT_ERR(__wt_buf_catfmt(session, buf, "checkpoint_timestamp=\"%s\"", hex_timestamp)); + WT_ERR(__wt_buf_fmt(session, buf, WT_SYSTEM_CKPT_TS "=\"%s\"", hex_timestamp)); WT_ERR(__wt_metadata_update(session, WT_SYSTEM_CKPT_URI, buf->data)); } + /* We also need to record the oldest timestamp in the metadata so we can set it on startup. */ + __wt_timestamp_to_hex_string( + S2C(session)->txn_global.checkpoint_oldest_timestamp, hex_timestamp); + if (strcmp(hex_timestamp, "0") == 0) + WT_ERR_NOTFOUND_OK(__wt_metadata_remove(session, WT_SYSTEM_OLDEST_URI), false); + else { + WT_ERR(__wt_buf_fmt(session, buf, WT_SYSTEM_OLDEST_TS "=\"%s\"", hex_timestamp)); + WT_ERR(__wt_metadata_update(session, WT_SYSTEM_OLDEST_URI, buf->data)); + } + err: __wt_scr_free(session, &buf); return (ret); |