summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/session/session_compact.c
diff options
context:
space:
mode:
authorChenhao Qu <chenhao.qu@mongodb.com>2021-12-22 18:32:31 +1100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-12-22 07:57:33 +0000
commitd9c83ee0c93970029e41234c77dc20b2c5ca6291 (patch)
tree8b1e7d15df8be0545562e0938831695e46eecbd4 /src/third_party/wiredtiger/src/session/session_compact.c
parentbea0c9bf186fea629d23b8d21c8ca0d024d0b813 (diff)
downloadmongo-d9c83ee0c93970029e41234c77dc20b2c5ca6291.tar.gz
Import wiredtiger: a9197f1480f65355eaf9e16812e5fd7e8f591eab from branch mongodb-master
ref: 7feed3f635..a9197f1480 for: 5.3.0 WT-8566 Implement timing stress in compact
Diffstat (limited to 'src/third_party/wiredtiger/src/session/session_compact.c')
-rw-r--r--src/third_party/wiredtiger/src/session/session_compact.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/third_party/wiredtiger/src/session/session_compact.c b/src/third_party/wiredtiger/src/session/session_compact.c
index 0fc929ac94f..05851afd4c5 100644
--- a/src/third_party/wiredtiger/src/session/session_compact.c
+++ b/src/third_party/wiredtiger/src/session/session_compact.c
@@ -176,6 +176,24 @@ __compact_handle_append(WT_SESSION_IMPL *session, const char *cfg[])
}
/*
+ * __compact_timing_stress --
+ * Optionally add a delay to the compact for debug purposes.
+ */
+static void
+__compact_timing_stress(WT_SESSION_IMPL *session)
+{
+ struct timespec tsp;
+
+ /* We only want to sleep if the flag is set. */
+ if (FLD_ISSET(S2C(session)->timing_stress_flags, WT_TIMING_STRESS_COMPACT_SLOW)) {
+ /* Add a 2 second wait to simulate compact slowness. */
+ tsp.tv_sec = 2;
+ tsp.tv_nsec = 0;
+ __wt_sleep((uint64_t)tsp.tv_sec, (uint64_t)tsp.tv_nsec / WT_THOUSAND);
+ }
+}
+
+/*
* __wt_session_compact_check_timeout --
* Check if the timeout has been exceeded.
*/
@@ -257,6 +275,8 @@ __compact_worker(WT_SESSION_IMPL *session)
if (session->op_handle[i]->compact_skip)
continue;
+ __compact_timing_stress(session);
+
session->compact_state = WT_COMPACT_RUNNING;
WT_WITH_DHANDLE(session, session->op_handle[i], ret = __wt_compact(session));
WT_ERR_ERROR_OK(ret, EBUSY, true);