diff options
author | Luke Chen <luke.chen@mongodb.com> | 2022-03-21 18:06:59 +1100 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-03-21 07:38:35 +0000 |
commit | 695d96b17cc69001529021ad0da4f9196bd67ab0 (patch) | |
tree | 7e3ad03693326ef300596f5eb796749695da2ff4 /src/third_party/wiredtiger/test/csuite/random_abort/main.c | |
parent | ba3c9346d18a79d57e6400482bca046d55fb3d31 (diff) | |
download | mongo-695d96b17cc69001529021ad0da4f9196bd67ab0.tar.gz |
Import wiredtiger: 12c575c6acaa455fe0c9f3f49a6c8385f9e60acc from branch mongodb-master
ref: 255ab0a126..12c575c6ac
for: 6.0.0
WT-8966 Failed test_random_abort: WT_ROLLBACK conflict between concurrent operations
Diffstat (limited to 'src/third_party/wiredtiger/test/csuite/random_abort/main.c')
-rw-r--r-- | src/third_party/wiredtiger/test/csuite/random_abort/main.c | 79 |
1 files changed, 40 insertions, 39 deletions
diff --git a/src/third_party/wiredtiger/test/csuite/random_abort/main.c b/src/third_party/wiredtiger/test/csuite/random_abort/main.c index 8a1031935f8..07145b05861 100644 --- a/src/third_party/wiredtiger/test/csuite/random_abort/main.c +++ b/src/third_party/wiredtiger/test/csuite/random_abort/main.c @@ -190,8 +190,6 @@ thread_run(void *arg) if (i == 0) i++; - testutil_check(session->begin_transaction(session, NULL)); - /* * The value is the insert- with key appended. */ @@ -215,9 +213,9 @@ thread_run(void *arg) data.data = buf; } cursor->set_value(cursor, &data); - testutil_check(cursor->insert(cursor)); - - testutil_check(session->commit_transaction(session, NULL)); + while ((ret = cursor->insert(cursor)) == WT_ROLLBACK) + ; + testutil_assert(ret == 0); /* * Save the key separately for checking later. @@ -240,16 +238,14 @@ thread_run(void *arg) * Decide what kind of operation can be performed on the already inserted data. */ if (i % MAX_NUM_OPS == OP_TYPE_DELETE) { - testutil_check(session->begin_transaction(session, NULL)); - if (columnar_table) cursor->set_key(cursor, i); else cursor->set_key(cursor, kname); - testutil_check(cursor->remove(cursor)); - - testutil_check(session->commit_transaction(session, NULL)); + while ((ret = cursor->remove(cursor)) == WT_ROLLBACK) + ; + testutil_assert(ret == 0); /* Save the key separately for checking later.*/ if (fprintf(fp[DELETE_RECORD_FILE_ID], "%" PRIu64 "\n", i) == -1) @@ -266,27 +262,29 @@ thread_run(void *arg) * Make sure the modify operation is carried out in an snapshot isolation level with * explicit transaction. */ - testutil_check(session->begin_transaction(session, NULL)); - - ret = wiredtiger_calc_modify(session, &data, &newv, maxdiff, entries, &nentries); + do { + testutil_check(session->begin_transaction(session, NULL)); - if (columnar_table) - cursor->set_key(cursor, i); - else - cursor->set_key(cursor, kname); - - if (ret == 0) - testutil_check(cursor->modify(cursor, entries, nentries)); - else { - /* - * In case if we couldn't able to generate modify vectors, treat this change as a - * normal update operation. - */ - cursor->set_value(cursor, &newv); - testutil_check(cursor->update(cursor)); - } + if (columnar_table) + cursor->set_key(cursor, i); + else + cursor->set_key(cursor, kname); - testutil_check(session->commit_transaction(session, NULL)); + ret = wiredtiger_calc_modify(session, &data, &newv, maxdiff, entries, &nentries); + if (ret == 0) + ret = cursor->modify(cursor, entries, nentries); + else { + /* + * In case if we couldn't able to generate modify vectors, treat this change as + * a normal update operation. + */ + cursor->set_value(cursor, &newv); + ret = cursor->update(cursor); + } + testutil_check(ret == 0 ? session->commit_transaction(session, NULL) : + session->rollback_transaction(session, NULL)); + } while (ret == WT_ROLLBACK); + testutil_assert(ret == 0); /* * Save the key and new value separately for checking later. @@ -487,10 +485,11 @@ recover_and_verify(uint32_t nthreads) cursor->set_key(cursor, kname); } - if ((ret = cursor->search(cursor)) != 0) { - if (ret != WT_NOTFOUND) - testutil_die(ret, "search"); - } else if (middle != 0) { + while ((ret = cursor->search(cursor)) == WT_ROLLBACK) + ; + if (ret != 0) + testutil_assert(ret == WT_NOTFOUND); + else if (middle != 0) { /* * We should never find an existing key after we have detected one missing for * the thread. @@ -516,9 +515,10 @@ recover_and_verify(uint32_t nthreads) cursor->set_key(cursor, kname); } - if ((ret = cursor->search(cursor)) != 0) { - if (ret != WT_NOTFOUND) - testutil_die(ret, "search"); + while ((ret = cursor->search(cursor)) == WT_ROLLBACK) + ; + if (ret != 0) { + testutil_assert(ret == WT_NOTFOUND); if (!inmem) printf("%s: no insert record with key %" PRIu64 "\n", fname[INSERT_RECORD_FILE_ID], key); @@ -567,9 +567,10 @@ recover_and_verify(uint32_t nthreads) cursor->set_key(cursor, kname); } - if ((ret = cursor->search(cursor)) != 0) { - if (ret != WT_NOTFOUND) - testutil_die(ret, "search"); + while ((ret = cursor->search(cursor)) == WT_ROLLBACK) + ; + if (ret != 0) { + testutil_assert(ret == WT_NOTFOUND); if (!inmem) printf("%s: no modified record with key %" PRIu64 "\n", fname[MODIFY_RECORD_FILE_ID], key); |