diff options
author | Keith Bostic <keith@wiredtiger.com> | 2015-07-28 15:02:54 -0400 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2015-07-28 15:02:54 -0400 |
commit | 2d6d9e8f7b02519f23a3c52638cac77f27b8b9d2 (patch) | |
tree | 5fd41659aef91c324039a6c012fe29078872c1fa | |
parent | 7400c9c0719623de662a596db5eda1e58da78fd6 (diff) | |
download | mongo-2d6d9e8f7b02519f23a3c52638cac77f27b8b9d2.tar.gz |
Use an explicit transaction: without an explicit begin_transaction, the
snapshot is only kept around while a cursor is positioned. As soon as
the cursor loses its position (including at the beginning of a search),
a new snapshot will be allocated.
-rw-r--r-- | test/format/lrt.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/test/format/lrt.c b/test/format/lrt.c index 921b73e4226..1e7ebe02ddc 100644 --- a/test/format/lrt.c +++ b/test/format/lrt.c @@ -59,8 +59,7 @@ lrt(void *arg) /* Open a session and cursor. */ conn = g.wts_conn; - if ((ret = conn->open_session( - conn, NULL, "isolation=snapshot", &session)) != 0) + if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) die(ret, "connection.open_session"); if ((ret = session->open_cursor( session, g.uri, NULL, NULL, &cursor)) != 0) @@ -68,7 +67,7 @@ lrt(void *arg) for (pinned = 0;;) { if (pinned) { - /* Confirm the returned value hasn't changed. */ + /* Re-read the record at the end of the table. */ while ((ret = read_row(cursor, &key, saved_keyno, 1)) == WT_ROLLBACK) ; @@ -90,15 +89,27 @@ lrt(void *arg) memcmp(buf, value.data, value.size) != 0) die(0, "mismatched start/stop values"); + /* End the transaction. */ + if ((ret = + session->commit_transaction(session, NULL)) != 0) + die(ret, "session.commit_transaction"); + /* Reset the cursor, releasing our pin. */ if ((ret = cursor->reset(cursor)) != 0) die(ret, "cursor.reset"); pinned = 0; } else { /* - * Read a record at the end of the table, creating a - * snapshot. + * Begin transaction: without an explicit transaction, + * the snapshot is only kept around while a cursor is + * positioned. As soon as the cursor loses its position + * a new snapshot will be allocated. */ + if ((ret = session->begin_transaction( + session, "isolation=snapshot")) != 0) + die(ret, "session.begin_transaction"); + + /* Read a record at the end of the table. */ do { saved_keyno = mmrand(NULL, (u_int)(g.key_cnt - g.key_cnt / 10), @@ -110,7 +121,7 @@ lrt(void *arg) if (ret != 0) die(ret, "read_row %" PRIu64, saved_keyno); - /* Take a copy of the cursor's value. */ + /* Copy the cursor's value. */ if (g.type == FIX) { ret = cursor->get_value(cursor, &bitfield); value.data = &bitfield; |