diff options
author | Luke Chen <luke.chen@mongodb.com> | 2020-07-23 16:56:43 +1000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-07-23 07:13:12 +0000 |
commit | facca86bc2bd0ec0b1221146b36ac698ba66d759 (patch) | |
tree | 1257618b6ea492f4e48385036aa4b570281af99d /src/third_party/wiredtiger/src/schema/schema_rename.c | |
parent | 6b5b168edf19e336dacff0a8c54a9dd1f32ed1e2 (diff) | |
download | mongo-facca86bc2bd0ec0b1221146b36ac698ba66d759.tar.gz |
Import wiredtiger: 820f85c016dd72529fe6d4d48cf3a7c98e9227aa from branch mongodb-4.6
ref: ba4be7edd7..820f85c016
for: 4.5.1
WT-6215 Clear backup block information on rename
WT-6325 Fast truncate can lead to never resolved prepared operations
WT-6533 No need to do obsolete check before inserting to history store
WT-6539 Fix backup and rename memory leak
Diffstat (limited to 'src/third_party/wiredtiger/src/schema/schema_rename.c')
-rw-r--r-- | src/third_party/wiredtiger/src/schema/schema_rename.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/src/third_party/wiredtiger/src/schema/schema_rename.c b/src/third_party/wiredtiger/src/schema/schema_rename.c index 3dfc99493c4..53c006ed226 100644 --- a/src/third_party/wiredtiger/src/schema/schema_rename.c +++ b/src/third_party/wiredtiger/src/schema/schema_rename.c @@ -9,14 +9,40 @@ #include "wt_internal.h" /* + * __rename_blkmod -- + * Reset the incremental backup information for a rename. + */ +static int +__rename_blkmod(WT_SESSION_IMPL *session, const char *oldvalue, WT_ITEM *buf) +{ + WT_CKPT ckpt; + WT_DECL_RET; + + WT_CLEAR(ckpt); + /* + * Replace the old file entries with new file entries. We need to recreate the incremental + * backup information to indicate copying the entire file in its bitmap. + */ + /* First load any existing backup information into a temp checkpoint structure. */ + WT_RET(__wt_meta_blk_mods_load(session, oldvalue, &ckpt, true)); + + /* Take the checkpoint structure and generate the metadata string. */ + ret = __wt_ckpt_blkmod_to_meta(session, buf, &ckpt); + __wt_meta_checkpoint_free(session, &ckpt); + return (ret); +} + +/* * __rename_file -- * WT_SESSION::rename for a file. */ static int __rename_file(WT_SESSION_IMPL *session, const char *uri, const char *newuri) { + WT_DECL_ITEM(buf); WT_DECL_RET; char *newvalue, *oldvalue; + const char *filecfg[3] = {NULL, NULL, NULL}; const char *filename, *newfile; bool exist; @@ -33,6 +59,7 @@ __rename_file(WT_SESSION_IMPL *session, const char *uri, const char *newuri) WT_WITH_HANDLE_LIST_WRITE_LOCK( session, ret = __wt_conn_dhandle_close_all(session, uri, true, false)); WT_ERR(ret); + WT_ERR(__wt_scr_alloc(session, 1024, &buf)); /* * First, check if the file being renamed exists in the system. Doing this check first matches @@ -54,13 +81,20 @@ __rename_file(WT_SESSION_IMPL *session, const char *uri, const char *newuri) default: WT_ERR(ret); } + __wt_free(session, newvalue); WT_ERR(__wt_fs_exist(session, newfile, &exist)); if (exist) WT_ERR_MSG(session, EEXIST, "%s", newfile); - /* Replace the old file entries with new file entries. */ WT_ERR(__wt_metadata_remove(session, uri)); - WT_ERR(__wt_metadata_insert(session, newuri, oldvalue)); + filecfg[0] = oldvalue; + if (F_ISSET(S2C(session), WT_CONN_INCR_BACKUP)) { + WT_ERR(__rename_blkmod(session, oldvalue, buf)); + filecfg[1] = buf->mem; + } else + filecfg[1] = NULL; + WT_ERR(__wt_config_collapse(session, filecfg, &newvalue)); + WT_ERR(__wt_metadata_insert(session, newuri, newvalue)); /* Rename the underlying file. */ WT_ERR(__wt_fs_rename(session, filename, newfile, false)); @@ -68,6 +102,7 @@ __rename_file(WT_SESSION_IMPL *session, const char *uri, const char *newuri) WT_ERR(__wt_meta_track_fileop(session, uri, newuri)); err: + __wt_scr_free(session, &buf); __wt_free(session, newvalue); __wt_free(session, oldvalue); return (ret); |