diff options
author | Luke Chen <luke.chen@mongodb.com> | 2018-04-18 15:56:04 +1000 |
---|---|---|
committer | Luke Chen <luke.chen@mongodb.com> | 2018-04-18 15:56:04 +1000 |
commit | 0ea8ebafc20bb379955b2168b31099aefa220d7b (patch) | |
tree | 45ae9717fd0db22de6ca56240381c8106a633e7d /src/third_party/wiredtiger/test/format/ops.c | |
parent | f1dce2d1934052cbac4032d0c5833d3857a0cfb2 (diff) | |
download | mongo-0ea8ebafc20bb379955b2168b31099aefa220d7b.tar.gz |
Import wiredtiger: ad25980c88b87d45dbcefdb10cdcf696d02a8ac2 from branch mongodb-3.8
ref: 5fc85c47ca..ad25980c88
for: 3.7.6
WT-3998 Fix a bug where stable timestamp was ignored on shutdown
WT-4012 Fix lookaside entry counters
WT-4019 Change test/format to test transaction prepare less often
WT-4027 Yield cursor operations between restarted search/traverse
WT-4031 on-page zero-length row-store values can be discarded from checkpoints
WT-4035 Truncate information discarded while active
WT-4036 Fix Coverity false positive: out-of-bounds access.
WT-4042 Access data handles safely during cursor reopen
Diffstat (limited to 'src/third_party/wiredtiger/test/format/ops.c')
-rw-r--r-- | src/third_party/wiredtiger/test/format/ops.c | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/src/third_party/wiredtiger/test/format/ops.c b/src/third_party/wiredtiger/test/format/ops.c index 54aa6d2b766..6930e470b8d 100644 --- a/src/third_party/wiredtiger/test/format/ops.c +++ b/src/third_party/wiredtiger/test/format/ops.c @@ -193,11 +193,12 @@ wts_ops(int lastrun) tinfo = tinfo_list[i]; total.commit += tinfo->commit; total.deadlock += tinfo->deadlock; - total.prepare += tinfo->prepare; total.insert += tinfo->insert; + total.prepare += tinfo->prepare; total.remove += tinfo->remove; total.rollback += tinfo->rollback; total.search += tinfo->search; + total.truncate += tinfo->truncate; total.update += tinfo->update; switch (tinfo->state) { @@ -496,26 +497,36 @@ begin_transaction(TINFO *tinfo, WT_SESSION *session, u_int *iso_configp) u_int v; const char *config; char config_buf[64]; + bool locked; + + locked = false; if ((v = g.c_isolation_flag) == ISOLATION_RANDOM) - v = mmrand(&tinfo->rnd, 2, 4); + v = mmrand(&tinfo->rnd, 1, 3); switch (v) { - case ISOLATION_READ_UNCOMMITTED: + case 1: + v = ISOLATION_READ_UNCOMMITTED; config = "isolation=read-uncommitted"; break; - case ISOLATION_READ_COMMITTED: + case 2: + v = ISOLATION_READ_COMMITTED; config = "isolation=read-committed"; break; - case ISOLATION_SNAPSHOT: + case 3: default: v = ISOLATION_SNAPSHOT; config = "isolation=snapshot"; + if (g.c_txn_timestamps) { /* * Avoid starting a new reader when a prepare is in * progress. */ - (void)pthread_rwlock_rdlock(&g.prepare_lock); + if (g.c_prepare) { + testutil_check( + pthread_rwlock_rdlock(&g.prepare_lock)); + locked = true; + } /* * Set the thread's read timestamp to the current value @@ -537,8 +548,8 @@ begin_transaction(TINFO *tinfo, WT_SESSION *session, u_int *iso_configp) testutil_check(session->begin_transaction(session, config)); - if (v == ISOLATION_SNAPSHOT && g.c_txn_timestamps) - (void)pthread_rwlock_unlock(&g.prepare_lock); + if (locked) + testutil_check(pthread_rwlock_unlock(&g.prepare_lock)); /* * It's OK for the oldest timestamp to move past a running query, clear @@ -630,12 +641,8 @@ prepare_transaction(TINFO *tinfo, WT_SESSION *session) uint64_t ts; char config_buf[64]; - /* - * We cannot prepare a transaction if logging on the table is set. - * Prepare also requires timestamps. Skip if not using timestamps, - * if no timestamp has yet been set, or if using logging. - */ - if (!g.c_txn_timestamps || g.timestamp == 0 || g.c_logging) + /* Skip if no timestamp has yet been set. */ + if (g.timestamp == 0) return (0); /* @@ -652,14 +659,14 @@ prepare_transaction(TINFO *tinfo, WT_SESSION *session) * Prepare will return error if prepare timestamp is less than any * active read timestamp. */ - (void)pthread_rwlock_wrlock(&g.prepare_lock); + testutil_check(pthread_rwlock_wrlock(&g.prepare_lock)); ts = set_commit_timestamp(tinfo); testutil_check(__wt_snprintf( config_buf, sizeof(config_buf), "prepare_timestamp=%" PRIx64, ts)); ret = session->prepare_transaction(session, config_buf); - (void)pthread_rwlock_unlock(&g.prepare_lock); + testutil_check(pthread_rwlock_unlock(&g.prepare_lock)); return (ret); } @@ -1095,9 +1102,10 @@ update_instead_of_chosen_op: } /* - * Prepare the transaction 10% of the time. + * If prepare configured, prepare the transaction 10% of the + * time. */ - if (mmrand(&tinfo->rnd, 1, 10) == 1) { + if (g.c_prepare && mmrand(&tinfo->rnd, 1, 10) == 1) { ret = prepare_transaction(tinfo, session); testutil_assert(ret == 0 || ret == WT_PREPARE_CONFLICT); if (ret == WT_PREPARE_CONFLICT) |