summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/conn/conn_tiered.c
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2021-06-09 17:18:47 +1000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-09 10:23:11 +0000
commit98fb4a099b3e9425da80e95cf2adfecc50557cc8 (patch)
treefc19afec82617b4624c8299cbf51a0d5c35e1de7 /src/third_party/wiredtiger/src/conn/conn_tiered.c
parentfe4c8e2f67e304e97d1f9c8c7a25a36f42fd2d40 (diff)
downloadmongo-98fb4a099b3e9425da80e95cf2adfecc50557cc8.tar.gz
Import wiredtiger: 8a3206b68bd7ef048c5805ef3396c408791d668b from branch mongodb-5.0
ref: 92379db4f8..8a3206b68b for: 5.1.0 WT-7651 Add synchronization for flush_tier calls
Diffstat (limited to 'src/third_party/wiredtiger/src/conn/conn_tiered.c')
-rw-r--r--src/third_party/wiredtiger/src/conn/conn_tiered.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/third_party/wiredtiger/src/conn/conn_tiered.c b/src/third_party/wiredtiger/src/conn/conn_tiered.c
index b331875855b..507e1a13fcf 100644
--- a/src/third_party/wiredtiger/src/conn/conn_tiered.c
+++ b/src/third_party/wiredtiger/src/conn/conn_tiered.c
@@ -350,12 +350,15 @@ int
__wt_flush_tier(WT_SESSION_IMPL *session, const char *config)
{
WT_CONFIG_ITEM cval;
+ WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
uint32_t flags;
const char *cfg[3];
+ bool wait;
+ conn = S2C(session);
WT_STAT_CONN_INCR(session, flush_tier);
- if (FLD_ISSET(S2C(session)->server_flags, WT_CONN_SERVER_TIERED_MGR))
+ if (FLD_ISSET(conn->server_flags, WT_CONN_SERVER_TIERED_MGR))
WT_RET_MSG(
session, EINVAL, "Cannot call flush_tier when storage manager thread is configured");
@@ -372,6 +375,21 @@ __wt_flush_tier(WT_SESSION_IMPL *session, const char *config)
else if (WT_STRING_MATCH("on", cval.str, cval.len))
LF_SET(WT_FLUSH_TIER_ON);
+ WT_RET(__wt_config_gets(session, cfg, "lock_wait", &cval));
+ if (cval.val)
+ wait = true;
+ else
+ wait = false;
+
+ /*
+ * We have to hold the lock around both the wait call for a previous flush tier and the
+ * execution of the current flush tier call.
+ */
+ if (wait)
+ __wt_spin_lock(session, &conn->flush_tier_lock);
+ else
+ WT_RET(__wt_spin_trylock(session, &conn->flush_tier_lock));
+
/*
* We cannot perform another flush tier until any earlier ones are done. Often threads will wait
* after the flush tier based on the sync setting so this check will be fast. But if sync is
@@ -379,8 +397,11 @@ __wt_flush_tier(WT_SESSION_IMPL *session, const char *config)
* holding the schema lock.
*/
__flush_tier_wait(session);
-
- WT_WITH_SCHEMA_LOCK(session, ret = __flush_tier_once(session, flags));
+ if (wait)
+ WT_WITH_SCHEMA_LOCK(session, ret = __flush_tier_once(session, flags));
+ else
+ WT_WITH_SCHEMA_LOCK_NOWAIT(session, ret, ret = __flush_tier_once(session, flags));
+ __wt_spin_unlock(session, &conn->flush_tier_lock);
if (ret == 0 && LF_ISSET(WT_FLUSH_TIER_ON))
__flush_tier_wait(session);