summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/schema/schema_worker.c
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2018-04-06 16:06:32 +1000
committerLuke Chen <luke.chen@mongodb.com>2018-04-06 16:23:17 +1000
commitb180ec4ad34b40b499cb4c7a2f01508ed639b44b (patch)
tree87c8fe8e92a19bb0beb69c1c2696e2b3d98aca07 /src/third_party/wiredtiger/src/schema/schema_worker.c
parentf728898d2be6b231175c9d64b39d0f072f5d8d18 (diff)
downloadmongo-b180ec4ad34b40b499cb4c7a2f01508ed639b44b.tar.gz
Import wiredtiger: ea986ede145b8c2e3da8f8d11ef25813770c0b39 from branch mongodb-3.8
ref: 875e91581c..ea986ede14 for: 3.7.4 WT-3724 Log an error if flushing with F_FULLSYNC fails WT-3849 Add timestamp validation to WT_SESSION::prepare_transaction WT-3870 Bi-weekly WT codebase lint WT-3922 Allow truncate operations to be prepared WT-3931 cursor.prev split race WT-3971 Make cursor duplication use cursor caching WT-3973 Allow alter to modify app_metadata WT-3981 Make snapshot consistent with read_timestamp WT-3984 Fix race conditions around prepare state transitions WT-3996 Test truncate with timestamps and lookaside WT-3997 The cursor walk code can spin without sleeping on restart/split. WT-4002 Allow duplicates in api_data.py WT-4005 AddressSanitizer in __wt_timestamp_iszero(). WT-4007 eviction instantiates pages from dead trees. WT-4008 Add ARM NEON support for row search operations WT-4011 Checkpoint should not read truncated pages WT-4022 Avoid WT_RESTART error return during eviction walk WT-4025 Allow debug dumping of internal pages
Diffstat (limited to 'src/third_party/wiredtiger/src/schema/schema_worker.c')
-rw-r--r--src/third_party/wiredtiger/src/schema/schema_worker.c52
1 files changed, 33 insertions, 19 deletions
diff --git a/src/third_party/wiredtiger/src/schema/schema_worker.c b/src/third_party/wiredtiger/src/schema/schema_worker.c
index 407550bfdba..aa38ad79bee 100644
--- a/src/third_party/wiredtiger/src/schema/schema_worker.c
+++ b/src/third_party/wiredtiger/src/schema/schema_worker.c
@@ -9,6 +9,36 @@
#include "wt_internal.h"
/*
+ * __wt_exclusive_handle_operation --
+ * Get exclusive access to a file and apply a function.
+ */
+int
+__wt_exclusive_handle_operation(WT_SESSION_IMPL *session,
+ const char *uri,
+ int (*file_func)(WT_SESSION_IMPL *, const char *[]),
+ const char *cfg[], uint32_t open_flags)
+{
+ WT_DECL_RET;
+
+ /*
+ * If the operation requires exclusive access, close
+ * any open file handles, including checkpoints.
+ */
+ if (FLD_ISSET(open_flags, WT_DHANDLE_EXCLUSIVE)) {
+ WT_WITH_HANDLE_LIST_WRITE_LOCK(session,
+ ret = __wt_conn_dhandle_close_all(
+ session, uri, false, false));
+ WT_RET(ret);
+ }
+
+ WT_RET(__wt_session_get_btree_ckpt(session, uri, cfg, open_flags));
+ WT_SAVE_DHANDLE(session, ret = file_func(session, cfg));
+ WT_TRET(__wt_session_release_dhandle(session));
+
+ return (ret);
+}
+
+/*
* __wt_schema_worker --
* Get Btree handles for the object and cycle through calls to an
* underlying worker function with each handle.
@@ -41,25 +71,9 @@ __wt_schema_worker(WT_SESSION_IMPL *session,
/* Get the btree handle(s) and call the underlying function. */
if (WT_PREFIX_MATCH(uri, "file:")) {
- if (file_func != NULL) {
- /*
- * If the operation requires exclusive access, close
- * any open file handles, including checkpoints.
- */
- if (FLD_ISSET(open_flags, WT_DHANDLE_EXCLUSIVE)) {
- WT_WITH_HANDLE_LIST_WRITE_LOCK(session,
- ret = __wt_conn_dhandle_close_all(
- session, uri, false, false));
- WT_ERR(ret);
- }
-
- WT_ERR(__wt_session_get_btree_ckpt(
- session, uri, cfg, open_flags));
- WT_SAVE_DHANDLE(session,
- ret = file_func(session, cfg));
- WT_TRET(__wt_session_release_dhandle(session));
- WT_ERR(ret);
- }
+ if (file_func != NULL)
+ WT_ERR(__wt_exclusive_handle_operation(session,
+ uri, file_func, cfg, open_flags));
} else if (WT_PREFIX_MATCH(uri, "colgroup:")) {
WT_ERR(__wt_schema_get_colgroup(
session, uri, false, NULL, &colgroup));