summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schubert <thomas.schubert@mongodb.com>2017-06-20 15:41:56 -0400
committerThomas Schubert <thomas.schubert@mongodb.com>2017-06-20 15:41:56 -0400
commitf3a7c3d40e8633558e47dad69c63f2b3b1b7543b (patch)
treec0ba6e1d4bdf17ee9cf9ff541da744727e26225f
parenta5bd12ede845f640d4d9f38865a72d3c7bfd922a (diff)
downloadmongo-f3a7c3d40e8633558e47dad69c63f2b3b1b7543b.tar.gz
Import wiredtiger: 534677a2eab033bf817588704417bb25f0d19551 from branch mongodb-3.2
ref: 6da948fe3d..534677a2ea for: 3.2.15 WT-3158 Fix structure layout on Windows. WT-3362 Cursor opens should never block for the duration of a checkpoint WT-3369 WT_CURSOR->uri should always match the URI used to open the cursor
-rwxr-xr-xsrc/third_party/wiredtiger/dist/s_style11
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/src/conn/conn_dhandle.c89
-rw-r--r--src/third_party/wiredtiger/src/cursor/cur_table.c6
-rw-r--r--src/third_party/wiredtiger/src/include/btmem.h2
-rw-r--r--src/third_party/wiredtiger/src/lsm/lsm_cursor.c4
-rw-r--r--src/third_party/wiredtiger/src/session/session_dhandle.c3
-rw-r--r--src/third_party/wiredtiger/test/suite/test_cursor01.py1
8 files changed, 72 insertions, 46 deletions
diff --git a/src/third_party/wiredtiger/dist/s_style b/src/third_party/wiredtiger/dist/s_style
index 388a481ef56..69cf1f667fa 100755
--- a/src/third_party/wiredtiger/dist/s_style
+++ b/src/third_party/wiredtiger/dist/s_style
@@ -101,10 +101,13 @@ else
cat $t
fi
- # Alignment directive before "struct".
- egrep 'WT_COMPILER_TYPE_ALIGN.*struct' $f > $t
- test -s $t && {
- echo "$f: compiler alignment direction must precede \"struct\""
+ # If we don't have matching pack-begin and pack-end calls, we don't get
+ # an error, we just get a Windows performance regression. Using awk and
+ # not wc to ensure there's no whitespace in the assignment.
+ egrep WT_PACKED_STRUCT $f > $t
+ cnt=`awk 'BEGIN { line = 0 } { ++line } END { print line }' < $t`
+ test `expr "$cnt" % 2` -ne 0 && {
+ echo "$f: mismatched WT_PACKED_STRUCT_BEGIN/END lines"
cat $t
}
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index 6650d2864c8..d797dadef6e 100644
--- a/src/third_party/wiredtiger/import.data
+++ b/src/third_party/wiredtiger/import.data
@@ -1,5 +1,5 @@
{
- "commit": "6da948fe3d4dd7262cbd0528d66867f276ce811d",
+ "commit": "534677a2eab033bf817588704417bb25f0d19551",
"github": "wiredtiger/wiredtiger.git",
"vendor": "wiredtiger",
"branch": "mongodb-3.2"
diff --git a/src/third_party/wiredtiger/src/conn/conn_dhandle.c b/src/third_party/wiredtiger/src/conn/conn_dhandle.c
index 41dcfb8fffb..1816e66b0b7 100644
--- a/src/third_party/wiredtiger/src/conn/conn_dhandle.c
+++ b/src/third_party/wiredtiger/src/conn/conn_dhandle.c
@@ -476,6 +476,49 @@ err: WT_DHANDLE_RELEASE(dhandle);
}
/*
+ * __conn_dhandle_close_one --
+ * Lock and, if necessary, close a data handle.
+ */
+static int
+__conn_dhandle_close_one(WT_SESSION_IMPL *session,
+ const char *uri, const char *checkpoint, bool force)
+{
+ WT_DECL_RET;
+
+ /*
+ * Lock the handle exclusively. If this is part of schema-changing
+ * operation (indicated by metadata tracking being enabled), hold the
+ * lock for the duration of the operation.
+ */
+ WT_RET(__wt_session_get_btree(session, uri, checkpoint,
+ NULL, WT_DHANDLE_EXCLUSIVE | WT_DHANDLE_LOCK_ONLY));
+ if (WT_META_TRACKING(session))
+ WT_RET(__wt_meta_track_handle_lock(session, false));
+
+ /*
+ * We have an exclusive lock, which means there are no cursors open at
+ * this point. Close the handle, if necessary.
+ */
+ if (F_ISSET(session->dhandle, WT_DHANDLE_OPEN)) {
+ __wt_meta_track_sub_on(session);
+ ret = __wt_conn_btree_sync_and_close(session, false, force);
+
+ /*
+ * If the close succeeded, drop any locks it acquired. If
+ * there was a failure, this function will fail and the whole
+ * transaction will be rolled back.
+ */
+ if (ret == 0)
+ ret = __wt_meta_track_sub_off(session);
+ }
+
+ if (!WT_META_TRACKING(session))
+ WT_TRET(__wt_session_release_btree(session));
+
+ return (ret);
+}
+
+/*
* __wt_conn_dhandle_close_all --
* Close all data handles handles with matching name (including all
* checkpoint handles).
@@ -495,48 +538,22 @@ __wt_conn_dhandle_close_all(
F_ISSET(session, WT_SESSION_LOCKED_HANDLE_LIST_WRITE));
WT_ASSERT(session, session->dhandle == NULL);
+ /*
+ * Lock the live handle first. This ordering is important: we rely on
+ * locking the live handle to fail fast if the tree is busy (e.g., with
+ * cursors open or in a checkpoint).
+ */
+ WT_ERR(__conn_dhandle_close_one(session, uri, NULL, force));
+
bucket = __wt_hash_city64(uri, strlen(uri)) % WT_HASH_ARRAY_SIZE;
TAILQ_FOREACH(dhandle, &conn->dhhash[bucket], hashq) {
if (strcmp(dhandle->name, uri) != 0 ||
+ dhandle->checkpoint == NULL ||
F_ISSET(dhandle, WT_DHANDLE_DEAD))
continue;
- session->dhandle = dhandle;
-
- /*
- * Lock the handle exclusively. If this is part of
- * schema-changing operation (indicated by metadata tracking
- * being enabled), hold the lock for the duration of the
- * operation.
- */
- WT_ERR(__wt_session_get_btree(session,
- dhandle->name, dhandle->checkpoint,
- NULL, WT_DHANDLE_EXCLUSIVE | WT_DHANDLE_LOCK_ONLY));
- if (WT_META_TRACKING(session))
- WT_ERR(__wt_meta_track_handle_lock(session, false));
-
- /*
- * We have an exclusive lock, which means there are no cursors
- * open at this point. Close the handle, if necessary.
- */
- if (F_ISSET(dhandle, WT_DHANDLE_OPEN)) {
- __wt_meta_track_sub_on(session);
- ret = __wt_conn_btree_sync_and_close(
- session, false, force);
-
- /*
- * If the close succeeded, drop any locks it acquired.
- * If there was a failure, this function will fail and
- * the whole transaction will be rolled back.
- */
- if (ret == 0)
- ret = __wt_meta_track_sub_off(session);
- }
-
- if (!WT_META_TRACKING(session))
- WT_TRET(__wt_session_release_btree(session));
-
- WT_ERR(ret);
+ WT_ERR(__conn_dhandle_close_one(
+ session, dhandle->name, dhandle->checkpoint, force));
}
err: session->dhandle = NULL;
diff --git a/src/third_party/wiredtiger/src/cursor/cur_table.c b/src/third_party/wiredtiger/src/cursor/cur_table.c
index 3b72bb0730f..f6855172e90 100644
--- a/src/third_party/wiredtiger/src/cursor/cur_table.c
+++ b/src/third_party/wiredtiger/src/cursor/cur_table.c
@@ -943,6 +943,12 @@ __wt_curtable_open(WT_SESSION_IMPL *session,
table->cgroups[0]->source, NULL, cfg, cursorp);
__wt_schema_release_table(session, table);
+ if (ret == 0) {
+ /* Fix up the public URI to match what was passed in. */
+ cursor = *cursorp;
+ __wt_free(session, cursor->uri);
+ WT_TRET(__wt_strdup(session, uri, &cursor->uri));
+ }
return (ret);
}
diff --git a/src/third_party/wiredtiger/src/include/btmem.h b/src/third_party/wiredtiger/src/include/btmem.h
index eb523c01ad7..d0b21b17965 100644
--- a/src/third_party/wiredtiger/src/include/btmem.h
+++ b/src/third_party/wiredtiger/src/include/btmem.h
@@ -930,7 +930,7 @@ WT_PACKED_STRUCT_BEGIN(__wt_update)
#define WT_UPDATE_MEMSIZE(upd) \
WT_ALIGN(sizeof(WT_UPDATE) + \
(WT_UPDATE_DELETED_ISSET(upd) ? 0 : (upd)->size), 32)
-};
+WT_PACKED_STRUCT_END
/*
* WT_INSERT --
diff --git a/src/third_party/wiredtiger/src/lsm/lsm_cursor.c b/src/third_party/wiredtiger/src/lsm/lsm_cursor.c
index 52265f02e62..4d00143b28f 100644
--- a/src/third_party/wiredtiger/src/lsm/lsm_cursor.c
+++ b/src/third_party/wiredtiger/src/lsm/lsm_cursor.c
@@ -1661,8 +1661,6 @@ __wt_clsm_close(WT_CURSOR *cursor)
/* In case we were somehow left positioned, clear that. */
__clsm_leave(clsm);
- /* The WT_LSM_TREE owns the URI. */
- cursor->uri = NULL;
if (clsm->lsm_tree != NULL)
__wt_lsm_tree_release(session, clsm->lsm_tree);
WT_TRET(__wt_cursor_close(cursor));
@@ -1744,7 +1742,7 @@ __wt_clsm_open(WT_SESSION_IMPL *session,
cursor = &clsm->iface;
*cursor = iface;
cursor->session = &session->iface;
- cursor->uri = lsm_tree->name;
+ WT_ERR(__wt_strdup(session, lsm_tree->name, &cursor->uri));
cursor->key_format = lsm_tree->key_format;
cursor->value_format = lsm_tree->value_format;
diff --git a/src/third_party/wiredtiger/src/session/session_dhandle.c b/src/third_party/wiredtiger/src/session/session_dhandle.c
index 9abc7a54f5d..ffeb6137766 100644
--- a/src/third_party/wiredtiger/src/session/session_dhandle.c
+++ b/src/third_party/wiredtiger/src/session/session_dhandle.c
@@ -229,7 +229,8 @@ __wt_session_lock_dhandle(
WT_ASSERT(session, !F_ISSET(dhandle, WT_DHANDLE_DEAD));
return (0);
}
- if (ret != EBUSY || (is_open && want_exclusive))
+ if (ret != EBUSY || (is_open && want_exclusive) ||
+ LF_ISSET(WT_DHANDLE_LOCK_ONLY))
return (ret);
lock_busy = true;
diff --git a/src/third_party/wiredtiger/test/suite/test_cursor01.py b/src/third_party/wiredtiger/test/suite/test_cursor01.py
index 8c66042eec0..2a33b15dccc 100644
--- a/src/third_party/wiredtiger/test/suite/test_cursor01.py
+++ b/src/third_party/wiredtiger/test/suite/test_cursor01.py
@@ -99,6 +99,7 @@ class test_cursor01(wttest.WiredTigerTestCase):
self.pr('creating cursor')
cursor = self.session.open_cursor(tablearg, None, None)
self.assertCursorHasNoKeyValue(cursor)
+ self.assertEqual(cursor.uri, tablearg)
for i in range(0, self.nentries):
cursor[self.genkey(i)] = self.genvalue(i)