summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/block/block_ckpt.c
diff options
context:
space:
mode:
authorChenhao Qu <chenhao.qu@mongodb.com>2021-01-25 10:17:02 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-01-25 11:01:39 +0000
commit62c3f69e2b2d2e805bb609edce01736f8ffa389b (patch)
tree314ef6ba4b2e51631d4d189207fca355eda49d27 /src/third_party/wiredtiger/src/block/block_ckpt.c
parent4a262f6844b3a054f4d89c8d7dc802e263dbdfc1 (diff)
downloadmongo-62c3f69e2b2d2e805bb609edce01736f8ffa389b.tar.gz
Import wiredtiger: e39ffb554160de902060cd063c4b1547ff6d5e1e from branch mongodb-5.0
ref: 1e9c8aed12..e39ffb5541 for: 4.9.0 WT-6309 Add support for start/stop arguments to wt printlog command WT-6866 Refactor python backup tests initial base class WT-6946 Adding test tags to an initial set of test programs WT-7084 Fix assert in test code and a comment error WT-7109 Retain no longer supported configuration options for backward compatibility WT-7113 Integrate prototype tiered storage code into WT WT-7114 Revert Makefile code to always run the prototype script
Diffstat (limited to 'src/third_party/wiredtiger/src/block/block_ckpt.c')
-rw-r--r--src/third_party/wiredtiger/src/block/block_ckpt.c51
1 files changed, 45 insertions, 6 deletions
diff --git a/src/third_party/wiredtiger/src/block/block_ckpt.c b/src/third_party/wiredtiger/src/block/block_ckpt.c
index cdabd131e40..ceb9cf39262 100644
--- a/src/third_party/wiredtiger/src/block/block_ckpt.c
+++ b/src/third_party/wiredtiger/src/block/block_ckpt.c
@@ -95,8 +95,13 @@ __wt_block_checkpoint_load(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint
if (ci->root_offset != WT_BLOCK_INVALID_OFFSET) {
endp = root_addr;
WT_ERR(__wt_block_addr_to_buffer(
- block, &endp, ci->root_offset, ci->root_size, ci->root_checksum));
+ block, &endp, ci->root_logid, ci->root_offset, ci->root_size, ci->root_checksum));
*root_addr_sizep = WT_PTRDIFF(endp, root_addr);
+
+ if (block->log_structured) {
+ block->logid = ci->root_logid;
+ WT_ERR(__wt_block_newfile(session, block));
+ }
}
/*
@@ -113,7 +118,7 @@ __wt_block_checkpoint_load(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint
* the end of the file, that was done when the checkpoint was first written (re-writing the
* checkpoint might possibly make it relevant here, but it's unlikely enough I don't bother).
*/
- if (!checkpoint)
+ if (!checkpoint && !block->log_structured)
WT_ERR(__wt_block_truncate(session, block, ci->file_size));
if (0) {
@@ -237,10 +242,10 @@ __wt_block_checkpoint(
*/
if (buf == NULL) {
ci->root_offset = WT_BLOCK_INVALID_OFFSET;
- ci->root_size = ci->root_checksum = 0;
+ ci->root_logid = ci->root_size = ci->root_checksum = 0;
} else
- WT_ERR(__wt_block_write_off(session, block, buf, &ci->root_offset, &ci->root_size,
- &ci->root_checksum, data_checksum, true, false));
+ WT_ERR(__wt_block_write_off(session, block, buf, &ci->root_logid, &ci->root_offset,
+ &ci->root_size, &ci->root_checksum, data_checksum, true, false));
/*
* Checkpoints are potentially reading/writing/merging lots of blocks, pre-allocate structures
@@ -463,6 +468,37 @@ __ckpt_add_blk_mods_ext(WT_SESSION_IMPL *session, WT_CKPT *ckptbase, WT_BLOCK_CK
}
/*
+ * __wt_block_newfile --
+ * Switch a log-structured block object to a new file.
+ */
+int
+__wt_block_newfile(WT_SESSION_IMPL *session, WT_BLOCK *block)
+{
+ WT_DECL_ITEM(tmp);
+ WT_DECL_RET;
+ const char *filename;
+
+ /* Bump to a new file ID. */
+ ++block->logid;
+
+ WT_ERR(__wt_scr_alloc(session, 0, &tmp));
+ WT_ERR(__wt_buf_fmt(session, tmp, "%s.%08" PRIu32, block->name, block->logid));
+ filename = tmp->data;
+ WT_ERR(__wt_close(session, &block->fh));
+ WT_ERR(__wt_open(session, filename, WT_FS_OPEN_FILE_TYPE_DATA,
+ WT_FS_OPEN_CREATE | block->file_flags, &block->fh));
+ WT_ERR(__wt_desc_write(session, block->fh, block->allocsize));
+
+ block->size = block->allocsize;
+ __wt_block_ckpt_destroy(session, &block->live);
+ WT_ERR(__wt_block_ckpt_init(session, &block->live, "live"));
+
+err:
+ __wt_scr_free(session, &tmp);
+ return (ret);
+}
+
+/*
* __ckpt_process --
* Process the list of checkpoints.
*/
@@ -610,7 +646,7 @@ __ckpt_process(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase)
* lists, and the freed blocks will then be included when writing the live extent lists.
*/
WT_CKPT_FOREACH (ckptbase, ckpt) {
- if (F_ISSET(ckpt, WT_CKPT_FAKE) || !F_ISSET(ckpt, WT_CKPT_DELETE))
+ if (F_ISSET(ckpt, WT_CKPT_FAKE) || !F_ISSET(ckpt, WT_CKPT_DELETE) || block->log_structured)
continue;
if (WT_VERBOSE_ISSET(session, WT_VERB_CHECKPOINT))
@@ -744,6 +780,9 @@ live_update:
ci->ckpt_discard = ci->discard;
WT_ERR(__wt_block_extlist_init(session, &ci->discard, "live", "discard", false));
+ if (block->log_structured)
+ WT_ERR(__wt_block_newfile(session, block));
+
#ifdef HAVE_DIAGNOSTIC
/*
* The first checkpoint in the system should always have an empty discard list. If we've read