diff options
author | Luke Chen <luke.chen@mongodb.com> | 2019-11-18 05:14:47 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-11-18 05:14:47 +0000 |
commit | 8772a8a2e8c966d10ff22180633ea4e908734a47 (patch) | |
tree | 341647f3b3bdb833ac750214ad7183f5a47054da /src/third_party/wiredtiger/src/meta | |
parent | fa6a120e11a01504ff01378231a5ece470af082d (diff) | |
download | mongo-8772a8a2e8c966d10ff22180633ea4e908734a47.tar.gz |
Import wiredtiger: d44b1af8a84ef93d9857432c9af5ef3b3adc8bdd from branch mongodb-4.4
ref: 3a42ced495..d44b1af8a8
for: 4.3.2
WT-4983 Migrate Jenkins “wiredtiger” job to Evergreen
WT-4988 Migrate Jenkins “wiredtiger-test-unit” job to Evergreen
WT-4989 Migrate Jenkins “wiredtiger-test-unit-long” job to Evergreen
WT-4990 Migrate Jenkins “wiredtiger-test-unit-ppc” job to Evergreen
WT-4991 Migrate Jenkins “wiredtiger-test-unit-zseries” job to Evergreen
WT-5025 Migrate Jenkins “wiredtiger-test-coverage” job to Evergreen
WT-5042 Reduce configuration parsing overhead from checkpoints
WT-5125 Adding new stats for eviction target strategy
WT-5126 Fix incorrect assertion regarding prepared update resolution
WT-5136 Fix reading freed memory due to birthmark after uncommitted updates freed
WT-5142 Don't create huge root pages when rebalancing or bulk-loading objects with overflow keys
WT-5174 Truncation rollback locking is insufficient
WT-5181 Preload eatmydata before running evergreen pull request test
WT-5193 Revert LAS dropped table change from WT-5150
WT-5196 Data mismatch failures with test/checkpoint after enabling LAS sweep
WT-5220 Re-enable LAS dropped table change from WT-5150
WT-5239 Fix syscall failure about metadata file open
Diffstat (limited to 'src/third_party/wiredtiger/src/meta')
-rw-r--r-- | src/third_party/wiredtiger/src/meta/meta_ckpt.c | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/src/third_party/wiredtiger/src/meta/meta_ckpt.c b/src/third_party/wiredtiger/src/meta/meta_ckpt.c index c8c4383f1a3..93a01fa6abb 100644 --- a/src/third_party/wiredtiger/src/meta/meta_ckpt.c +++ b/src/third_party/wiredtiger/src/meta/meta_ckpt.c @@ -12,7 +12,7 @@ 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_named(WT_SESSION_IMPL *, const char *, const char *, WT_CKPT *); -static int __ckpt_set(WT_SESSION_IMPL *, const char *, const char *); +static int __ckpt_set(WT_SESSION_IMPL *, const char *, const char *, bool); static int __ckpt_version_chk(WT_SESSION_IMPL *, const char *, const char *); /* @@ -94,7 +94,7 @@ __wt_meta_checkpoint_clear(WT_SESSION_IMPL *session, const char *fname) * If we are unrolling a failed create, we may have already removed the metadata entry. If no * entry is found to update and we're trying to clear the checkpoint, just ignore it. */ - WT_RET_NOTFOUND_OK(__ckpt_set(session, fname, NULL)); + WT_RET_NOTFOUND_OK(__ckpt_set(session, fname, NULL, false)); return (0); } @@ -104,25 +104,40 @@ __wt_meta_checkpoint_clear(WT_SESSION_IMPL *session, const char *fname) * Set a file's checkpoint. */ static int -__ckpt_set(WT_SESSION_IMPL *session, const char *fname, const char *v) +__ckpt_set(WT_SESSION_IMPL *session, const char *fname, const char *v, bool use_base) { + WT_DECL_ITEM(tmp); WT_DECL_RET; char *config, *newcfg; - const char *cfg[3]; + const char *cfg[3], *str; + /* + * If the caller knows we're on a path like checkpoints where we have a valid checkpoint and + * checkpoint LSN and should use the base, then use that faster path. Some paths don't have a + * dhandle or want to have the older value retained from the existing metadata. In those cases, + * use the slower path through configuration parsing functions. + */ config = newcfg = NULL; - - /* Retrieve the metadata for this file. */ - WT_ERR(__wt_metadata_search(session, fname, &config)); - - /* Replace the checkpoint entry. */ - cfg[0] = config; - cfg[1] = v == NULL ? "checkpoint=()" : v; - cfg[2] = NULL; - WT_ERR(__wt_config_collapse(session, cfg, &newcfg)); - WT_ERR(__wt_metadata_update(session, fname, newcfg)); + str = v == NULL ? "checkpoint=(),checkpoint_lsn=" : v; + if (use_base && session->dhandle != NULL) { + WT_ERR(__wt_scr_alloc(session, 0, &tmp)); + WT_ASSERT(session, strcmp(session->dhandle->name, fname) == 0); + /* Concatenate the metadata base string with the checkpoint string. */ + WT_ERR(__wt_buf_fmt(session, tmp, "%s,%s", session->dhandle->meta_base, str)); + WT_ERR(__wt_metadata_update(session, fname, tmp->mem)); + } else { + /* Retrieve the metadata for this file. */ + WT_ERR(__wt_metadata_search(session, fname, &config)); + /* Replace the checkpoint entry. */ + cfg[0] = config; + cfg[1] = str; + cfg[2] = NULL; + WT_ERR(__wt_config_collapse(session, cfg, &newcfg)); + WT_ERR(__wt_metadata_update(session, fname, newcfg)); + } err: + __wt_scr_free(session, &tmp); __wt_free(session, config); __wt_free(session, newcfg); return (ret); @@ -236,37 +251,27 @@ __wt_meta_block_metadata(WT_SESSION_IMPL *session, const char *config, WT_CKPT * WT_DECL_RET; WT_KEYED_ENCRYPTOR *kencryptor; size_t encrypt_size, metadata_len; - char *min_config; const char *metadata, *filecfg[] = {WT_CONFIG_BASE(session, file_meta), NULL, NULL}; - min_config = NULL; WT_ERR(__wt_scr_alloc(session, 0, &a)); WT_ERR(__wt_scr_alloc(session, 0, &b)); + /* Fill out the configuration array for normal retrieval. */ + filecfg[1] = config; + /* + * Find out if this file is encrypted. If encrypting, encrypt and encode. * The metadata has to be encrypted because it contains private data * (for example, column names). We pass the block manager text that * describes the metadata (the encryption information), and the * possibly encrypted metadata encoded as a hexadecimal string. - * configuration string. - * - * Get a minimal configuration string, just the non-default entries. - */ - WT_ERR(__wt_config_discard_defaults(session, filecfg, config, &min_config)); - - /* Fill out the configuration array for normal retrieval. */ - filecfg[1] = config; - - /* - * Find out if this file is encrypted. If encrypting, encrypt and encode the minimal - * configuration. */ WT_ERR(__wt_btree_config_encryptor(session, filecfg, &kencryptor)); if (kencryptor == NULL) { - metadata = min_config; - metadata_len = strlen(min_config); + metadata = config; + metadata_len = strlen(config); } else { - WT_ERR(__wt_buf_set(session, a, min_config, strlen(min_config))); + WT_ERR(__wt_buf_set(session, a, config, strlen(config))); __wt_encrypt_size(session, kencryptor, a->size, &encrypt_size); WT_ERR(__wt_buf_grow(session, b, encrypt_size)); WT_ERR(__wt_encrypt(session, kencryptor, 0, a, b)); @@ -289,7 +294,6 @@ __wt_meta_block_metadata(WT_SESSION_IMPL *session, const char *config, WT_CKPT * WT_ERR(__wt_strndup(session, b->data, b->size, &ckpt->block_metadata)); err: - __wt_free(session, min_config); __wt_scr_free(session, &a); __wt_scr_free(session, &b); return (ret); @@ -584,16 +588,18 @@ __wt_meta_ckptlist_set( WT_CKPT *ckpt; WT_DECL_ITEM(buf); WT_DECL_RET; + bool has_lsn; WT_RET(__wt_scr_alloc(session, 1024, &buf)); WT_ERR(__wt_meta_ckptlist_to_meta(session, ckptbase, buf)); + has_lsn = ckptlsn != NULL; if (ckptlsn != NULL) WT_ERR(__wt_buf_catfmt(session, buf, ",checkpoint_lsn=(%" PRIu32 ",%" PRIuMAX ")", ckptlsn->l.file, (uintmax_t)ckptlsn->l.offset)); - WT_ERR(__ckpt_set(session, fname, buf->mem)); + WT_ERR(__ckpt_set(session, fname, buf->mem, has_lsn)); /* Review the checkpoint's write generation. */ WT_CKPT_FOREACH (ckptbase, ckpt) |