diff options
author | Andrew Morton <andrew.morton@mongodb.com> | 2023-05-16 22:21:25 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-05-17 00:50:01 +0000 |
commit | 376eae9eefe9f752d8d9b5189528f1353c019e54 (patch) | |
tree | 8780daf7a9ebd0ed2e8c1b25bf81571b3bb89911 /src/third_party/wiredtiger/src/schema/schema_drop.c | |
parent | e94168acd89dba4faef5e43f970633a781e8cba2 (diff) | |
download | mongo-376eae9eefe9f752d8d9b5189528f1353c019e54.tar.gz |
Import wiredtiger: 04dcc362042b8cc35fdd8de8343be3a15d4fa47c from branch mongodb-master
ref: d310d6330e..04dcc36204
for: 7.1.0-rc0
WT-10898 Add assertions for owning a spinlock
Diffstat (limited to 'src/third_party/wiredtiger/src/schema/schema_drop.c')
-rw-r--r-- | src/third_party/wiredtiger/src/schema/schema_drop.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/third_party/wiredtiger/src/schema/schema_drop.c b/src/third_party/wiredtiger/src/schema/schema_drop.c index 354e779b908..883065d1f25 100644 --- a/src/third_party/wiredtiger/src/schema/schema_drop.c +++ b/src/third_party/wiredtiger/src/schema/schema_drop.c @@ -183,10 +183,10 @@ __drop_tiered(WT_SESSION_IMPL *session, const char *uri, bool force, const char WT_TIERED *tiered; u_int i, localid; const char *filename, *name; - bool exist, got_dhandle, locked, remove_files, remove_shared; + bool exist, got_dhandle, remove_files, remove_shared; conn = S2C(session); - got_dhandle = locked = false; + got_dhandle = false; WT_RET(__wt_config_gets(session, cfg, "remove_files", &cval)); remove_files = cval.val != 0; WT_RET(__wt_config_gets(session, cfg, "remove_shared", &cval)); @@ -279,7 +279,6 @@ __drop_tiered(WT_SESSION_IMPL *session, const char *uri, bool force, const char * race and process work for this handle. */ __wt_spin_lock(session, &conn->tiered_lock); - locked = true; /* * Close all btree handles associated with this table. This must be done after we're done using * the tiered structure because that is from the dhandle. @@ -291,9 +290,8 @@ __drop_tiered(WT_SESSION_IMPL *session, const char *uri, bool force, const char WT_ERR(ret); /* If everything is successful, remove any tiered work associated with this tiered handle. */ - __wt_tiered_remove_work(session, tiered, locked); + __wt_tiered_remove_work(session, tiered, true); __wt_spin_unlock(session, &conn->tiered_lock); - locked = false; __wt_verbose(session, WT_VERB_TIERED, "DROP_TIERED: remove tiered table %s from metadata", uri); ret = __wt_metadata_remove(session, uri); @@ -302,8 +300,7 @@ err: if (got_dhandle) WT_TRET(__wt_session_release_dhandle(session)); __wt_free(session, name); - if (locked) - __wt_spin_unlock(session, &conn->tiered_lock); + __wt_spin_unlock_if_owned(session, &conn->tiered_lock); return (ret); } @@ -370,6 +367,15 @@ __wt_schema_drop(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) WT_DECL_RET; WT_SESSION_IMPL *int_session; + /* + * We should be calling this function with the schema lock, but we cannot verify it here because + * we can re-enter this function with the internal session. If we get here using the internal + * session, we cannot check whether we own the lock, as it would be locked by the outer session. + * We can thus only check whether the lock is acquired, as opposed to, whether the lock is + * acquired by us. + */ + WT_ASSERT(session, __wt_spin_locked(session, &S2C(session)->schema_lock)); + WT_RET(__wt_schema_internal_session(session, &int_session)); ret = __schema_drop(int_session, uri, cfg); WT_TRET(__wt_schema_session_release(session, int_session)); |