diff options
author | Luke Chen <luke.chen@mongodb.com> | 2020-10-15 16:28:31 +1100 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-10-15 05:47:36 +0000 |
commit | 0d50b1116aecab5a7dc2d1736e19b37785798a0c (patch) | |
tree | 9a997d00dd0fa82fc807fae9617f5593816714eb | |
parent | 60d52fdb2512cc21a44ef798200b77339fa1e224 (diff) | |
download | mongo-0d50b1116aecab5a7dc2d1736e19b37785798a0c.tar.gz |
Import wiredtiger: 0626020133546d8e475e63522f49840c33a250d6 from branch mongodb-5.0
ref: 593ae41db7..0626020133
for: 4.9.0
WT-6671 Save the checkpoint snapshot that is used to take checkpoint in the metadata
WT-6763 Fix freeing update on the chain when insert fail after inserting to the update chain
WT-6793 Organize code statistics Evergreen tasks
WT-6806 Back off aggressive abort in random_directio
15 files changed, 226 insertions, 47 deletions
diff --git a/src/third_party/wiredtiger/dist/s_string.ok b/src/third_party/wiredtiger/dist/s_string.ok index 6364398f6ff..be6ae0893fe 100644 --- a/src/third_party/wiredtiger/dist/s_string.ok +++ b/src/third_party/wiredtiger/dist/s_string.ok @@ -1269,6 +1269,7 @@ struct structs su subdirectory +subget subgetraw subgets subinit diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data index 3a42a06b1fd..7c33a4bc909 100644 --- a/src/third_party/wiredtiger/import.data +++ b/src/third_party/wiredtiger/import.data @@ -2,5 +2,5 @@ "vendor": "wiredtiger", "github": "wiredtiger/wiredtiger.git", "branch": "mongodb-5.0", - "commit": "593ae41db7c2e454201f9f0539d8c74685f3242b" + "commit": "0626020133546d8e475e63522f49840c33a250d6" } diff --git a/src/third_party/wiredtiger/src/btree/row_modify.c b/src/third_party/wiredtiger/src/btree/row_modify.c index caef5a88c52..3b10493780f 100644 --- a/src/third_party/wiredtiger/src/btree/row_modify.c +++ b/src/third_party/wiredtiger/src/btree/row_modify.c @@ -54,14 +54,14 @@ __wt_row_modify(WT_CURSOR_BTREE *cbt, const WT_ITEM *key, const WT_ITEM *value, size_t ins_size, upd_size; uint32_t ins_slot; u_int i, skipdepth; - bool logged; + bool inserted_to_update_chain, logged; ins = NULL; page = cbt->ref->page; session = CUR2S(cbt); last_upd = NULL; upd = upd_arg; - logged = false; + inserted_to_update_chain = logged = false; /* * We should have one of the following: @@ -206,6 +206,8 @@ __wt_row_modify(WT_CURSOR_BTREE *cbt, const WT_ITEM *key, const WT_ITEM *value, session, page, cbt->ins_head, cbt->ins_stack, &ins, ins_size, skipdepth, exclusive)); } + inserted_to_update_chain = true; + if (logged && modify_type != WT_UPDATE_RESERVE) { WT_ERR(__wt_txn_log_op(session, cbt)); /* @@ -224,7 +226,7 @@ err: __wt_txn_unmodify(session); __wt_free(session, ins); cbt->ins = NULL; - if (upd_arg == NULL) + if (upd_arg == NULL && !inserted_to_update_chain) __wt_free(session, upd); if (last_upd != NULL) last_upd->next = NULL; diff --git a/src/third_party/wiredtiger/src/config/config.c b/src/third_party/wiredtiger/src/config/config.c index de6e7c4e0b4..ec7fa076150 100644 --- a/src/third_party/wiredtiger/src/config/config.c +++ b/src/third_party/wiredtiger/src/config/config.c @@ -728,3 +728,17 @@ __wt_config_subgets( return (__wt_config_subgetraw(session, cfg, &key_item, value)); } + +/* + * __wt_config_subget_next -- + * Get the value for a given key from a config string and set the processed value in the given + * key structure. This is useful for unusual case of dealing with list in config string. + */ +int +__wt_config_subget_next(WT_CONFIG *conf, WT_CONFIG_ITEM *key) +{ + WT_CONFIG_ITEM value; + WT_RET(__config_next(conf, key, &value)); + __config_process_value(key); + return (0); +} diff --git a/src/third_party/wiredtiger/src/conn/conn_handle.c b/src/third_party/wiredtiger/src/conn/conn_handle.c index f0d861d16b4..9668e8a26bc 100644 --- a/src/third_party/wiredtiger/src/conn/conn_handle.c +++ b/src/third_party/wiredtiger/src/conn/conn_handle.c @@ -131,6 +131,9 @@ __wt_connection_destroy(WT_CONNECTION_IMPL *conn) __wt_free(session, conn->dhhash); __wt_free(session, conn->fhhash); + /* Free allocated recovered checkpoint snapshot memory */ + __wt_free(session, conn->recovery_ckpt_snapshot); + /* Free allocated memory. */ __wt_free(session, conn->cfg); __wt_free(session, conn->debug_ckpt); diff --git a/src/third_party/wiredtiger/src/include/connection.h b/src/third_party/wiredtiger/src/include/connection.h index a5a642fa5b0..3520b3b3941 100644 --- a/src/third_party/wiredtiger/src/include/connection.h +++ b/src/third_party/wiredtiger/src/include/connection.h @@ -266,6 +266,11 @@ struct __wt_connection_impl { WT_TXN_GLOBAL txn_global; /* Global transaction state */ + /* Recovery checkpoint snapshot details saved in the metadata file */ + uint64_t recovery_ckpt_snap_min, recovery_ckpt_snap_max; + uint64_t *recovery_ckpt_snapshot; + uint32_t recovery_ckpt_snapshot_count; + WT_RWLOCK hot_backup_lock; /* Hot backup serialization */ uint64_t hot_backup_start; /* Clock value of most recent checkpoint needed by hot backup */ char **hot_backup_list; /* Hot backup file list */ diff --git a/src/third_party/wiredtiger/src/include/extern.h b/src/third_party/wiredtiger/src/include/extern.h index 9729b79b06d..e0c268aacf8 100644 --- a/src/third_party/wiredtiger/src/include/extern.h +++ b/src/third_party/wiredtiger/src/include/extern.h @@ -396,6 +396,8 @@ extern int __wt_config_merge(WT_SESSION_IMPL *session, const char **cfg, const c WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_config_next(WT_CONFIG *conf, WT_CONFIG_ITEM *key, WT_CONFIG_ITEM *value) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern int __wt_config_subget_next(WT_CONFIG *conf, WT_CONFIG_ITEM *key) + WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_config_subgetraw(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *cfg, WT_CONFIG_ITEM *key, WT_CONFIG_ITEM *value) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_config_subgets(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *cfg, const char *key, diff --git a/src/third_party/wiredtiger/src/include/meta.h b/src/third_party/wiredtiger/src/include/meta.h index 2bda37b02c3..9e274e9f3cc 100644 --- a/src/third_party/wiredtiger/src/include/meta.h +++ b/src/third_party/wiredtiger/src/include/meta.h @@ -33,11 +33,16 @@ #define WT_HS_FILE "WiredTigerHS.wt" /* History store table */ #define WT_HS_URI "file:WiredTigerHS.wt" /* History store table URI */ -#define WT_SYSTEM_PREFIX "system:" /* System URI prefix */ -#define WT_SYSTEM_CKPT_TS "checkpoint_timestamp" /* Checkpoint timestamp name */ -#define WT_SYSTEM_CKPT_URI "system:checkpoint" /* Checkpoint timestamp URI */ -#define WT_SYSTEM_OLDEST_TS "oldest_timestamp" /* Oldest timestamp name */ -#define WT_SYSTEM_OLDEST_URI "system:oldest" /* Oldest timestamp URI */ +#define WT_SYSTEM_PREFIX "system:" /* System URI prefix */ +#define WT_SYSTEM_CKPT_TS "checkpoint_timestamp" /* Checkpoint timestamp name */ +#define WT_SYSTEM_CKPT_URI "system:checkpoint" /* Checkpoint timestamp URI */ +#define WT_SYSTEM_OLDEST_TS "oldest_timestamp" /* Oldest timestamp name */ +#define WT_SYSTEM_OLDEST_URI "system:oldest" /* Oldest timestamp URI */ +#define WT_SYSTEM_CKPT_SNAPSHOT "snapshots" /* List of snapshots */ +#define WT_SYSTEM_CKPT_SNAPSHOT_MIN "snapshot_min" /* Snapshot minimum */ +#define WT_SYSTEM_CKPT_SNAPSHOT_MAX "snapshot_max" /* Snapshot maximum */ +#define WT_SYSTEM_CKPT_SNAPSHOT_COUNT "snapshot_count" /* Snapshot count */ +#define WT_SYSTEM_CKPT_SNAPSHOT_URI "system:checkpoint_snapshot" /* Checkpoint snapshot URI */ #define WT_SYSTEM_BASE_WRITE_GEN_URI "system:checkpoint_base_write_gen" /* Base write gen URI */ #define WT_SYSTEM_BASE_WRITE_GEN "base_write_gen" /* Base write gen name */ diff --git a/src/third_party/wiredtiger/src/meta/meta_ckpt.c b/src/third_party/wiredtiger/src/meta/meta_ckpt.c index d27d6203baf..aa9191bdc6a 100644 --- a/src/third_party/wiredtiger/src/meta/meta_ckpt.c +++ b/src/third_party/wiredtiger/src/meta/meta_ckpt.c @@ -947,13 +947,16 @@ __wt_meta_sysinfo_set(WT_SESSION_IMPL *session) { WT_DECL_ITEM(buf); WT_DECL_RET; + WT_TXN *txn; WT_TXN_GLOBAL *txn_global; wt_timestamp_t oldest_timestamp; + uint32_t snap_count; char hex_timestamp[WT_TS_HEX_STRING_SIZE]; txn_global = &S2C(session)->txn_global; - WT_ERR(__wt_scr_alloc(session, 0, &buf)); + txn = session->txn; + WT_ERR(__wt_scr_alloc(session, 1024, &buf)); /* * 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. @@ -991,6 +994,21 @@ __wt_meta_sysinfo_set(WT_SESSION_IMPL *session) WT_ERR(__wt_metadata_update(session, WT_SYSTEM_OLDEST_URI, buf->data)); } + /* Record snapshot information in metadata for checkpoint. */ + if (txn->snapshot_count > 0) { + WT_ERR(__wt_buf_fmt(session, buf, + WT_SYSTEM_CKPT_SNAPSHOT_MIN "=%" PRIu64 "," WT_SYSTEM_CKPT_SNAPSHOT_MAX "=%" PRIu64 + "," WT_SYSTEM_CKPT_SNAPSHOT_COUNT "=%" PRIu32 + "," WT_SYSTEM_CKPT_SNAPSHOT "=[", + txn->snap_min, txn->snap_max, txn->snapshot_count)); + + for (snap_count = 0; snap_count < txn->snapshot_count - 1; ++snap_count) + WT_ERR(__wt_buf_catfmt(session, buf, "%" PRIu64 "%s", txn->snapshot[snap_count], ",")); + + WT_ERR(__wt_buf_catfmt(session, buf, "%" PRIu64 "%s", txn->snapshot[snap_count], "]")); + WT_ERR(__wt_metadata_update(session, WT_SYSTEM_CKPT_SNAPSHOT_URI, buf->data)); + } + /* Record the base write gen in metadata as part of checkpoint */ WT_ERR(__wt_buf_fmt( session, buf, WT_SYSTEM_BASE_WRITE_GEN "=%" PRIu64, S2C(session)->base_write_gen)); diff --git a/src/third_party/wiredtiger/src/txn/txn_recover.c b/src/third_party/wiredtiger/src/txn/txn_recover.c index a4bca612341..044a3b00f02 100644 --- a/src/third_party/wiredtiger/src/txn/txn_recover.c +++ b/src/third_party/wiredtiger/src/txn/txn_recover.c @@ -453,6 +453,70 @@ __recovery_set_oldest_timestamp(WT_RECOVERY *r) } /* + * __recovery_set_checkpoint_snapshot -- + * Set the checkpoint snapshot details as retrieved from the metadata file. + */ +static int +__recovery_set_checkpoint_snapshot(WT_SESSION_IMPL *session) +{ + WT_CONFIG list; + WT_CONFIG_ITEM cval; + WT_CONFIG_ITEM k; + WT_CONNECTION_IMPL *conn; + WT_DECL_RET; + uint8_t counter; + char *sys_config; + + sys_config = NULL; + conn = S2C(session); + counter = 0; + + /* + * Read the system checkpoint information from the metadata file and save the snapshot related + * details of the last checkpoint for later query. This gets saved in the connection. + */ + WT_ERR_NOTFOUND_OK( + __wt_metadata_search(session, WT_SYSTEM_CKPT_SNAPSHOT_URI, &sys_config), false); + if (sys_config != NULL) { + WT_CLEAR(cval); + if (__wt_config_getones(session, sys_config, WT_SYSTEM_CKPT_SNAPSHOT_MIN, &cval) == 0 && + cval.len != 0) + conn->recovery_ckpt_snap_min = (uint64_t)cval.val; + + if (__wt_config_getones(session, sys_config, WT_SYSTEM_CKPT_SNAPSHOT_MAX, &cval) == 0 && + cval.len != 0) + conn->recovery_ckpt_snap_max = (uint64_t)cval.val; + + if (__wt_config_getones(session, sys_config, WT_SYSTEM_CKPT_SNAPSHOT_COUNT, &cval) == 0 && + cval.len != 0) + conn->recovery_ckpt_snapshot_count = (uint32_t)cval.val; + + if (__wt_config_getones(session, sys_config, WT_SYSTEM_CKPT_SNAPSHOT, &cval) == 0 && + cval.len != 0) { + __wt_config_subinit(session, &list, &cval); + WT_ERR(__wt_calloc_def( + session, conn->recovery_ckpt_snapshot_count, &conn->recovery_ckpt_snapshot)); + while (__wt_config_subget_next(&list, &k) == 0) + conn->recovery_ckpt_snapshot[counter++] = (uint64_t)k.val; + } + + /* + * Make sure that checkpoint snapshot does not have any unexpected value. The recovered + * snapshot array should contain the values between recovered snapshot min and recovered + * snapshot max. + */ + WT_ASSERT(session, + conn->recovery_ckpt_snapshot_count == counter && + conn->recovery_ckpt_snapshot[0] == conn->recovery_ckpt_snap_min && + conn->recovery_ckpt_snapshot[counter - 1] < conn->recovery_ckpt_snap_max); + } + +err: + __wt_free(session, sys_config); + return (ret); +} + +/* * __recovery_set_ckpt_base_write_gen -- * Set the base write gen as retrieved from the metadata file. */ @@ -696,6 +760,7 @@ __wt_txn_recover(WT_SESSION_IMPL *session, const char *cfg[]) F_SET(conn, WT_CONN_RECOVERING); WT_ERR(__recovery_set_ckpt_base_write_gen(&r)); + WT_ERR(__recovery_set_checkpoint_snapshot(session)); WT_ERR(__wt_metadata_search(session, WT_METAFILE_URI, &config)); WT_ERR(__recovery_setup_file(&r, WT_METAFILE_URI, config)); WT_ERR(__wt_metadata_cursor_open(session, NULL, &metac)); diff --git a/src/third_party/wiredtiger/test/csuite/random_directio/main.c b/src/third_party/wiredtiger/test/csuite/random_directio/main.c index 2212befaadb..d887ce50337 100644 --- a/src/third_party/wiredtiger/test/csuite/random_directio/main.c +++ b/src/third_party/wiredtiger/test/csuite/random_directio/main.c @@ -800,7 +800,6 @@ check_db(uint32_t nth, uint32_t datasize, pid_t pid, bool directio, uint32_t fla char checkdir[4096], dbgdir[4096], savedir[4096]; char *gotkey, *gotvalue, *keybuf, *p; char **large_arr; - bool fatal; keybuf = dcalloc(datasize, 1); lastid = dcalloc(nth, sizeof(uint64_t)); @@ -825,21 +824,9 @@ check_db(uint32_t nth, uint32_t datasize, pid_t pid, bool directio, uint32_t fla * Copy the original home directory explicitly without direct I/O. Copy this first because * copying with directio may abort and we want to see what the original copy saw. */ - fatal = copy_directory(home, dbgdir, false); - if (fatal) { - printf("FATAL: Copying from %s to %s, directio %d\n", home, dbgdir, false); - kill_child(pid); - } - fatal = copy_directory(home, checkdir, directio); - if (fatal) { - printf("FATAL: Copying from %s to %s, directio %d\n", home, checkdir, directio); - kill_child(pid); - } - fatal = copy_directory(checkdir, savedir, false); - if (fatal) { - printf("FATAL: Copying from %s to %s, directio %d\n", checkdir, savedir, false); - kill_child(pid); - } + copy_directory(home, dbgdir, false); + copy_directory(home, checkdir, directio); + copy_directory(checkdir, savedir, false); printf("Open database, run recovery and verify content\n"); ret = wiredtiger_open(checkdir, NULL, ENV_CONFIG_REC, &conn); diff --git a/src/third_party/wiredtiger/test/csuite/random_directio/util.c b/src/third_party/wiredtiger/test/csuite/random_directio/util.c index df8b65ce248..a69dfd28ba1 100644 --- a/src/third_party/wiredtiger/test/csuite/random_directio/util.c +++ b/src/third_party/wiredtiger/test/csuite/random_directio/util.c @@ -43,7 +43,7 @@ * copy_directory -- * Copy a directory, using direct IO if indicated. */ -bool +void copy_directory(const char *fromdir, const char *todir, bool directio) { struct dirent *dp; @@ -52,10 +52,9 @@ copy_directory(const char *fromdir, const char *todir, bool directio) size_t blksize, bufsize, readbytes, n, remaining; ssize_t ioret; uintptr_t bufptr; - int enoent, openflags, rfd, wfd; + int openflags, rfd, wfd; u_char *buf, *orig_buf; char fromfile[4096], tofile[4096]; - bool fatal; #ifdef O_DIRECT openflags = directio ? O_DIRECT : 0; @@ -66,8 +65,6 @@ copy_directory(const char *fromdir, const char *todir, bool directio) orig_buf = dcalloc(COPY_BUF_SIZE, sizeof(u_char)); buf = NULL; blksize = bufsize = 0; - enoent = 0; - fatal = false; dirp = opendir(todir); if (dirp != NULL) { @@ -105,16 +102,7 @@ copy_directory(const char *fromdir, const char *todir, bool directio) * directory will still return its entry. Handle that case and skip the file if it happens. */ if (rfd < 0 && errno == ENOENT) { - ++enoent; - /* - * At most there can be one thread in the middle of drop due to the schema lock. So if - * we find more than one missing file, we have a fatal and unexpected situation. We want - * to know all the files in this. So note them here and fail later. - */ - printf("COPY_DIR: direct:%d ENOENT %d: Source file %s not found.\n", directio, enoent, - dp->d_name); - if (enoent > 1) - fatal = true; + printf("COPY_DIR: direct:%d ENOENT Source file %s not found.\n", directio, dp->d_name); continue; } testutil_assertfmt(rfd >= 0, "Open of source %s failed with %d\n", fromfile, errno); @@ -166,5 +154,4 @@ copy_directory(const char *fromdir, const char *todir, bool directio) } testutil_check(closedir(dirp)); free(orig_buf); - return (fatal); } diff --git a/src/third_party/wiredtiger/test/csuite/random_directio/util.h b/src/third_party/wiredtiger/test/csuite/random_directio/util.h index a849150d52c..57ed381a112 100644 --- a/src/third_party/wiredtiger/test/csuite/random_directio/util.h +++ b/src/third_party/wiredtiger/test/csuite/random_directio/util.h @@ -30,4 +30,4 @@ * util.h * Utility functions for test that simulates system crashes. */ -extern bool copy_directory(const char *, const char *, bool); +extern void copy_directory(const char *, const char *, bool); diff --git a/src/third_party/wiredtiger/test/evergreen.yml b/src/third_party/wiredtiger/test/evergreen.yml index 6da3fa56e90..2dd16239845 100755 --- a/src/third_party/wiredtiger/test/evergreen.yml +++ b/src/third_party/wiredtiger/test/evergreen.yml @@ -2351,7 +2351,6 @@ tasks: tags: ["stress-test-3", "stress-test-zseries-3"] - name: cyclomatic-complexity - tags: ["pull_request"] commands: - func: "get project" - command: shell.exec @@ -2395,7 +2394,6 @@ buildvariants: - name: make-check-asan-test - name: configure-combinations - name: checkpoint-filetypes-test - - name: coverage-report - name: unit-test-long - name: spinlock-gcc-test - name: spinlock-pthread-adaptive-test @@ -2405,7 +2403,6 @@ buildvariants: - name: long-test - name: static-wt-build-test - name: format-failure-configs-test - - name: cyclomatic-complexity - name: ubuntu1804-compilers display_name: "! Ubuntu 18.04 Compilers" @@ -2508,7 +2505,6 @@ buildvariants: - name: ftruncate-test - name: long-test - name: configure-combinations - - name: coverage-report - name: large-scale-tests display_name: "~ Large scale tests" @@ -2518,6 +2514,17 @@ buildvariants: tasks: - name: million-collection-test +- name: code-statistics + display_name: "Code statistics" + batchtime: 1440 # 1 day + run_on: + - ubuntu1804-test + expansions: + test_env_vars: LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libeatmydata.so PATH=/opt/mongodbtoolchain/v3/bin:$PATH LD_LIBRARY_PATH=$(pwd)/.libs top_srcdir=$(pwd)/.. top_builddir=$(pwd) + tasks: + - name: coverage-report + - name: cyclomatic-complexity + - name: compatibility-tests-less-frequent display_name: Compatibility tests (less frequent) batchtime: 10080 # 7 days diff --git a/src/third_party/wiredtiger/test/suite/test_checkpoint_snapshot01.py b/src/third_party/wiredtiger/test/suite/test_checkpoint_snapshot01.py new file mode 100644 index 00000000000..a6eb0cf4905 --- /dev/null +++ b/src/third_party/wiredtiger/test/suite/test_checkpoint_snapshot01.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +# +# Public Domain 2014-2020 MongoDB, Inc. +# Public Domain 2008-2014 WiredTiger, Inc. +# +# This is free and unencumbered software released into the public domain. +# +# Anyone is free to copy, modify, publish, use, compile, sell, or +# distribute this software, either in source code form or as a compiled +# binary, for any purpose, commercial or non-commercial, and by any +# means. +# +# In jurisdictions that recognize copyright laws, the author or authors +# of this software dedicate any and all copyright interest in the +# software to the public domain. We make this dedication for the benefit +# of the public at large and to the detriment of our heirs and +# successors. We intend this dedication to be an overt act of +# relinquishment in perpetuity of all present and future rights to this +# software under copyright law. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. + +from helper import copy_wiredtiger_home +import wiredtiger, wttest +from wtdataset import SimpleDataSet +from wtscenario import make_scenarios +from wiredtiger import stat + +# test_checkpoint_snapshot01.py +# Checkpoint snapshot - Create multiple sessions which creates snapshots and +# checkpoint to save the snapshot details in metadata file. +# + +class test_checkpoint_snapshot01(wttest.WiredTigerTestCase): + conn_config = 'cache_size=50MB,statistics=(fast)' + + # Create a table. + uri = "table:test_checkpoint_snapshot01" + + nsessions = 5 + nkeys = 40 + nrows = 100 + + def test_checkpoint_snapshot(self): + + ds = SimpleDataSet(self, self.uri, self.nrows, key_format="S", value_format='u') + ds.populate() + value = b"aaaaa" * 100 + + sessions = [0] * self.nsessions + cursors = [0] * self.nsessions + + for j in range (0, self.nsessions): + sessions[j] = self.conn.open_session() + cursors[j] = sessions[j].open_cursor(self.uri) + sessions[j].begin_transaction('isolation=snapshot') + + start = (j * self.nkeys) + end = start + self.nkeys + + for i in range(start, end): + cursors[j].set_key(ds.key(self.nrows + i)) + cursors[j].set_value(value) + self.assertEquals(cursors[j].insert(),0) + + session_p2 = self.conn.open_session() + session_p2.checkpoint() + + #Simulate a crash by copying to a new directory(RESTART). + copy_wiredtiger_home(".", "RESTART") + + # Open the new directory. + self.conn = self.setUpConnectionOpen("RESTART") + self.session = self.setUpSessionOpen(self.conn) + +if __name__ == '__main__': + wttest.run() |