diff options
Diffstat (limited to 'src/third_party/wiredtiger/src/txn/txn_ckpt.c')
-rw-r--r-- | src/third_party/wiredtiger/src/txn/txn_ckpt.c | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/src/third_party/wiredtiger/src/txn/txn_ckpt.c b/src/third_party/wiredtiger/src/txn/txn_ckpt.c index 9b3d1bb51fb..59a10c36733 100644 --- a/src/third_party/wiredtiger/src/txn/txn_ckpt.c +++ b/src/third_party/wiredtiger/src/txn/txn_ckpt.c @@ -8,7 +8,7 @@ #include "wt_internal.h" -static void __checkpoint_timing_stress(WT_SESSION_IMPL *, bool); +static void __checkpoint_timing_stress(WT_SESSION_IMPL *, uint64_t, struct timespec *); static int __checkpoint_lock_dirty_tree(WT_SESSION_IMPL *, bool, bool, bool, const char *[]); static int __checkpoint_mark_skip(WT_SESSION_IMPL *, WT_CKPT *, bool); static int __checkpoint_presync(WT_SESSION_IMPL *, const char *[]); @@ -137,9 +137,7 @@ __checkpoint_apply_operation( } if (v.len != 0) - WT_ERR_MSG(session, EINVAL, - "invalid checkpoint target %.*s: URIs may require " - "quoting", + WT_ERR_MSG(session, EINVAL, "invalid checkpoint target %.*s: URIs may require quoting", (int)cval.len, (char *)cval.str); /* Some objects don't support named checkpoints. */ @@ -517,6 +515,7 @@ __checkpoint_fail_reset(WT_SESSION_IMPL *session) static int __checkpoint_prepare(WT_SESSION_IMPL *session, bool *trackingp, const char *cfg[]) { + struct timespec tsp; WT_CONFIG_ITEM cval; WT_CONNECTION_IMPL *conn; WT_DECL_RET; @@ -546,6 +545,10 @@ __checkpoint_prepare(WT_SESSION_IMPL *session, bool *trackingp, const char *cfg[ __wt_epoch(session, &conn->ckpt_prep_start); WT_RET(__wt_txn_begin(session, txn_cfg)); + /* Wait 1000 microseconds to simulate slowdown in checkpoint prepare. */ + tsp.tv_sec = 0; + tsp.tv_nsec = WT_MILLION; + __checkpoint_timing_stress(session, WT_TIMING_STRESS_PREPARE_CHECKPOINT_DELAY, &tsp); original_snap_min = session->txn->snap_min; WT_DIAGNOSTIC_YIELD; @@ -585,7 +588,8 @@ __checkpoint_prepare(WT_SESSION_IMPL *session, bool *trackingp, const char *cfg[ /* * Sanity check that the oldest ID hasn't moved on before we have cleared our entry. */ - WT_ASSERT(session, WT_TXNID_LE(txn_global->oldest_id, txn_shared->id) && + WT_ASSERT(session, + WT_TXNID_LE(txn_global->oldest_id, txn_shared->id) && WT_TXNID_LE(txn_global->oldest_id, txn_shared->pinned_id)); /* @@ -748,6 +752,7 @@ __txn_checkpoint_can_skip( static int __txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]) { + struct timespec tsp; WT_CACHE *cache; WT_CONNECTION_IMPL *conn; WT_DATA_HANDLE *hs_dhandle; @@ -870,11 +875,14 @@ __txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]) if (full && logging) WT_ERR(__wt_txn_checkpoint_log(session, full, WT_TXN_LOG_CKPT_START, NULL)); - __checkpoint_timing_stress(session, false); + /* Add a ten second wait to simulate checkpoint slowness. */ + tsp.tv_sec = 10; + tsp.tv_nsec = 0; + __checkpoint_timing_stress(session, WT_TIMING_STRESS_CHECKPOINT_SLOW, &tsp); WT_ERR(__checkpoint_apply_to_dhandles(session, cfg, __checkpoint_tree_helper)); /* Wait prior to checkpointing the history store to simulate checkpoint slowness. */ - __checkpoint_timing_stress(session, true); + __checkpoint_timing_stress(session, WT_TIMING_STRESS_HS_CHECKPOINT_DELAY, &tsp); /* * Get a history store dhandle. If the history store file is opened for a special operation this @@ -1129,11 +1137,8 @@ __wt_txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[], bool waiting) */ #undef WT_CHECKPOINT_SESSION_FLAGS #define WT_CHECKPOINT_SESSION_FLAGS (WT_SESSION_CAN_WAIT | WT_SESSION_IGNORE_CACHE_SIZE) -#undef WT_CHECKPOINT_SESSION_FLAGS_OFF -#define WT_CHECKPOINT_SESSION_FLAGS_OFF (WT_SESSION_HS_CURSOR) - orig_flags = F_MASK(session, WT_CHECKPOINT_SESSION_FLAGS | WT_CHECKPOINT_SESSION_FLAGS_OFF); + orig_flags = F_MASK(session, WT_CHECKPOINT_SESSION_FLAGS); F_SET(session, WT_CHECKPOINT_SESSION_FLAGS); - F_CLR(session, WT_CHECKPOINT_SESSION_FLAGS_OFF); /* * Only one checkpoint can be active at a time, and checkpoints must run in the same order as @@ -1274,9 +1279,8 @@ __checkpoint_lock_dirty_tree_int(WT_SESSION_IMPL *session, bool is_checkpoint, b continue; } WT_RET_MSG(session, EBUSY, - "checkpoint %s blocked by hot backup: it would " - "delete an existing named checkpoint, and such " - "checkpoints cannot be deleted during a hot backup", + "checkpoint %s blocked by hot backup: it would delete an existing named checkpoint, " + "and such checkpoints cannot be deleted during a hot backup", ckpt->name); } /* @@ -1307,8 +1311,9 @@ __checkpoint_lock_dirty_tree_int(WT_SESSION_IMPL *session, bool is_checkpoint, b WT_CKPT_FOREACH (ckptbase, ckpt) { if (!F_ISSET(ckpt, WT_CKPT_DELETE)) continue; - WT_ASSERT(session, !WT_PREFIX_MATCH(ckpt->name, WT_CHECKPOINT) || - conn->hot_backup_start == 0 || ckpt->sec > conn->hot_backup_start); + WT_ASSERT(session, + !WT_PREFIX_MATCH(ckpt->name, WT_CHECKPOINT) || conn->hot_backup_start == 0 || + ckpt->sec > conn->hot_backup_start); /* * We can't delete checkpoints referenced by a cursor. WiredTiger checkpoints are * uniquely named and it's OK to have multiple in the system: clear the delete flag for @@ -1445,9 +1450,7 @@ __checkpoint_lock_dirty_tree( else if (WT_STRING_MATCH("to", k.str, k.len)) __drop_to(ckptbase, v.str, v.len); else - WT_ERR_MSG(session, EINVAL, - "unexpected value for checkpoint " - "key: %.*s", + WT_ERR_MSG(session, EINVAL, "unexpected value for checkpoint key: %.*s", (int)k.len, k.str); } WT_ERR_NOTFOUND_OK(ret, false); @@ -1536,8 +1539,8 @@ __checkpoint_mark_skip(WT_SESSION_IMPL *session, WT_CKPT *ckptbase, bool force) name = (ckpt - 1)->name; if (ckpt > ckptbase + 1 && deleted < 2 && (strcmp(name, (ckpt - 2)->name) == 0 || - (WT_PREFIX_MATCH(name, WT_CHECKPOINT) && - WT_PREFIX_MATCH((ckpt - 2)->name, WT_CHECKPOINT)))) { + (WT_PREFIX_MATCH(name, WT_CHECKPOINT) && + WT_PREFIX_MATCH((ckpt - 2)->name, WT_CHECKPOINT)))) { F_SET(btree, WT_BTREE_SKIP_CKPT); /* * If there are potentially extra checkpoints to delete, we set the timer to recheck @@ -1887,7 +1890,7 @@ __wt_checkpoint_close(WT_SESSION_IMPL *session, bool final) */ if (btree->modified && !bulk && !__wt_btree_immediately_durable(session) && (S2C(session)->txn_global.has_stable_timestamp || - (!F_ISSET(S2C(session), WT_CONN_FILE_CLOSE_SYNC) && !metadata))) + (!F_ISSET(S2C(session), WT_CONN_FILE_CLOSE_SYNC) && !metadata))) return (__wt_set_return(session, EBUSY)); /* @@ -1915,12 +1918,12 @@ __wt_checkpoint_close(WT_SESSION_IMPL *session, bool final) /* * __checkpoint_timing_stress -- - * Optionally add a 10 second delay to a checkpoint to simulate a long running checkpoint for - * debug purposes. The reason for this option is finding operations that can block while waiting - * for a checkpoint to complete. + * Optionally add a delay to a checkpoint to simulate a long running checkpoint for debug + * purposes. The reason for this option is finding operations that can block while waiting for a + * checkpoint to complete. */ static void -__checkpoint_timing_stress(WT_SESSION_IMPL *session, bool history_store_stress) +__checkpoint_timing_stress(WT_SESSION_IMPL *session, uint64_t flag, struct timespec *tsp) { WT_CONNECTION_IMPL *conn; @@ -1931,9 +1934,6 @@ __checkpoint_timing_stress(WT_SESSION_IMPL *session, bool history_store_stress) * the session used is either of the two sessions set aside for internal checkpoints. */ if (conn->ckpt_session != session && conn->meta_ckpt_session != session && - ((FLD_ISSET(conn->timing_stress_flags, WT_TIMING_STRESS_CHECKPOINT_SLOW) && - !history_store_stress) || - (FLD_ISSET(conn->timing_stress_flags, WT_TIMING_STRESS_HS_CHECKPOINT_DELAY) && - history_store_stress))) - __wt_sleep(10, 0); + FLD_ISSET(conn->timing_stress_flags, flag)) + __wt_sleep((uint64_t)tsp->tv_sec, (uint64_t)tsp->tv_nsec / WT_THOUSAND); } |