Skip to content

Commit

Permalink
WT_SESSION.prepare doesn't permit WT_SESSION.timestamp_transaction,
Browse files Browse the repository at this point in the history
instead it requires the timestamp be set at transaction commit.
  • Loading branch information
keithbostic committed May 3, 2018
1 parent 71bfa51 commit 23c4e64
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions test/format/ops.c
Expand Up @@ -586,31 +586,41 @@ set_commit_timestamp(TINFO *tinfo)
* Commit a transaction.
*/
static void
commit_transaction(TINFO *tinfo, WT_SESSION *session)
commit_transaction(TINFO *tinfo, WT_SESSION *session, bool prepared)
{
uint64_t ts;
char config_buf[64];
char *config, config_buf[64];

config = NULL;
if (g.c_txn_timestamps) {
ts = set_commit_timestamp(tinfo);
testutil_check(__wt_snprintf(
config_buf, sizeof(config_buf),
"commit_timestamp=%" PRIx64, ts));
config = config_buf;
}

if (prepared)
testutil_check(
session->timestamp_transaction(session, config_buf));
session->commit_transaction(session, config));

/*
* Clear the thread's active timestamp: it no longer needs to
* be pinned. Don't let the compiler re-order this statement,
* if we were to race with the timestamp thread, it might see
* our thread update before the commit_timestamp is set for the
* transaction.
*/
if (g.c_txn_timestamps)
WT_PUBLISH(tinfo->commit_timestamp, 0);
}
if (!prepared)
testutil_check(
session->timestamp_transaction(session, config));

/*
* Clear the thread's active timestamp: it no longer needs to
* be pinned. Don't let the compiler re-order this statement,
* if we were to race with the timestamp thread, it might see
* our thread update before the commit_timestamp is set for the
* transaction.
*/
if (g.c_txn_timestamps)
WT_PUBLISH(tinfo->commit_timestamp, 0);

if (!prepared)
testutil_check(session->commit_transaction(session, NULL));

testutil_check(session->commit_transaction(session, NULL));
++tinfo->commit;
}

Expand Down Expand Up @@ -705,7 +715,7 @@ ops(void *arg)
uint64_t reset_op, session_op, truncate_op;
uint32_t range, rnd;
u_int i, j, iso_config;
bool greater_than, intxn, next, positioned, readonly;
bool greater_than, intxn, next, positioned, prepared, readonly;

tinfo = arg;

Expand Down Expand Up @@ -746,7 +756,7 @@ ops(void *arg)
* resolve any running transaction.
*/
if (intxn) {
commit_transaction(tinfo, session);
commit_transaction(tinfo, session, false);
intxn = false;
}

Expand Down Expand Up @@ -1109,12 +1119,14 @@ ops(void *arg)
* If prepare configured, prepare the transaction 10% of the
* time.
*/
prepared = false;
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)
goto deadlock;

prepared = true;
__wt_yield(); /* Let other threads proceed. */
}

Expand All @@ -1124,7 +1136,7 @@ ops(void *arg)
*/
switch (rnd) {
case 1: case 2: case 3: case 4: /* 40% */
commit_transaction(tinfo, session);
commit_transaction(tinfo, session, prepared);
break;
case 5: /* 10% */
if (0) {
Expand Down

0 comments on commit 23c4e64

Please sign in to comment.