summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c
diff options
context:
space:
mode:
authorAlex Gorrod <alexander.gorrod@mongodb.com>2017-08-21 09:26:14 +1000
committerAlex Gorrod <alexander.gorrod@mongodb.com>2017-08-21 09:26:14 +1000
commit0cfe4dfc2cf371f9e8196cb79414c3432b95b5af (patch)
tree3ea1dfc60609b4b6c424144f02af5e8045d1fe40 /src/third_party/wiredtiger/src/lsm/lsm_work_unit.c
parent1cbfc673303260c725ef428eb0f2b6372feb5ec1 (diff)
downloadmongo-0cfe4dfc2cf371f9e8196cb79414c3432b95b5af.tar.gz
Import wiredtiger: b055251678e6b4fcc74a1f651432aadbfeecc0e4 from branch mongodb-3.6
ref: 698847557c..b055251678 for: 3.5.12 WT-3328 Enhance docs around when schema operations can get EBUSY WT-3358 LSM will hang if the manager fails to start WT-3365 Understand how timestamps interact with LSM chunk switching WT-3399 Add new checkpoint blocking test case to automated testing WT-3417 Drain transactions during upgrade/downgrade. WT-3441 test_timestamp01 doesn't account for a large WT_TIMESTAMP_SIZE WT-3450 Add verbose option that tracks timestamp state and information WT-3452 Enhance existing recovery test to exercise timestamp API WT-3455 Enhance eviction to be aware of stable timestamp WT-3459 Test WiredTiger with clock shifting WT-3460 Add support for rollback_to_stable to column store WT-3465 Optimize performance when timestamp size is 8 bytes WT-3483 WT_SESSION::checkpoint returning WT_ROLLBACK WT-3492 ex_all.c not calling transaction_ops WT-3493 wt_verbose_dump_txn should display timestamp information WT-3497 Improve logging message when hitting the WT session limits WT-3498 Incorrect data read after caching overflow items WT-3499 Checkpoint can miss not yet committed item WT-3500 New timestamp-abort test is too chatty WT-3502 Only keep 10 delta updates between full copies WT-3503 Coverity 1379333: unchecked return value, full-build Friday WT-3508 timestamp-abort bug in verification phase WT-3509 __wt_illegal_value doesn't always provide a failure location WT-3514 WT_SESSION.checkpoint: read timestamp 6373c older than oldest timestamp WT-3517 WT_SESSION::reset doesn't need to call out EBUSY specially WT-3521 Unstable updates should not be written by lookaside eviction
Diffstat (limited to 'src/third_party/wiredtiger/src/lsm/lsm_work_unit.c')
-rw-r--r--src/third_party/wiredtiger/src/lsm/lsm_work_unit.c61
1 files changed, 58 insertions, 3 deletions
diff --git a/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c b/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c
index 2f21e8acdc3..816eafebe99 100644
--- a/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c
+++ b/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c
@@ -256,6 +256,63 @@ err:
}
/*
+ * __wt_lsm_chunk_visible_all --
+ * Setup a timestamp and check visibility for a chunk, can be called
+ * from multiple threads in parallel
+ */
+bool
+__wt_lsm_chunk_visible_all(
+ WT_SESSION_IMPL *session, WT_LSM_CHUNK *chunk)
+{
+ /* Once a chunk has been flushed it's contents must be visible */
+ if (F_ISSET(chunk, WT_LSM_CHUNK_ONDISK | WT_LSM_CHUNK_STABLE))
+ return (true);
+
+ if (chunk->switch_txn == WT_TXN_NONE ||
+ !__wt_txn_visible_all(session, chunk->switch_txn, NULL))
+ return (false);
+
+#ifdef HAVE_TIMESTAMPS
+ {
+ WT_TXN_GLOBAL *txn_global;
+
+ txn_global = &S2C(session)->txn_global;
+
+ /*
+ * Once all transactions with updates in the chunk are visible all
+ * timestamps associated with those updates are assigned so setup a
+ * timestamp for visibility checking.
+ */
+ if (txn_global->has_commit_timestamp ||
+ txn_global->has_pinned_timestamp) {
+ if (!F_ISSET(chunk, WT_LSM_CHUNK_HAS_TIMESTAMP)) {
+ __wt_spin_lock(session, &chunk->timestamp_spinlock);
+ /* Set the timestamp if we won the race */
+ if (!F_ISSET(chunk, WT_LSM_CHUNK_HAS_TIMESTAMP)) {
+ __wt_readlock(session, &txn_global->rwlock);
+ __wt_timestamp_set(&chunk->switch_timestamp,
+ &txn_global->commit_timestamp);
+ __wt_readunlock(session, &txn_global->rwlock);
+ F_SET(chunk, WT_LSM_CHUNK_HAS_TIMESTAMP);
+ }
+ __wt_spin_unlock(session, &chunk->timestamp_spinlock);
+ }
+ if (!__wt_txn_visible_all(
+ session, chunk->switch_txn, &chunk->switch_timestamp))
+ return (false);
+ } else
+ /*
+ * If timestamps aren't in use when the chunk becomes visible
+ * use the zero timestamp for visibility checks. Otherwise
+ * there could be confusion if timestamps start being used.
+ */
+ F_SET(chunk, WT_LSM_CHUNK_HAS_TIMESTAMP);
+ }
+#endif
+ return (true);
+}
+
+/*
* __wt_lsm_checkpoint_chunk --
* Flush a single LSM chunk to disk.
*/
@@ -295,14 +352,12 @@ __wt_lsm_checkpoint_chunk(WT_SESSION_IMPL *session,
/* Stop if a running transaction needs the chunk. */
WT_RET(__wt_txn_update_oldest(
session, WT_TXN_OLDEST_STRICT | WT_TXN_OLDEST_WAIT));
- if (chunk->switch_txn == WT_TXN_NONE ||
- !__wt_txn_visible_all(session, chunk->switch_txn, NULL)) {
+ if (!__wt_lsm_chunk_visible_all(session, chunk)) {
__wt_verbose(session, WT_VERB_LSM,
"LSM worker %s: running transaction, return",
chunk->uri);
return (0);
}
-
if (!__wt_atomic_cas8(&chunk->flushing, 0, 1))
return (0);
flush_set = true;