Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WT-4733 change format to do longer-term repeatable read testing #4610

Merged
merged 26 commits into from
Jun 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
17151ef
Convert the list of operations into a circular buffer so they survive
keithbostic Apr 28, 2019
44aec3b
The prepared-state ("is this transaction prepared") doesn't need to live
keithbostic Apr 28, 2019
d4532dd
First cut at doing repeatable reads after the original transaction has
keithbostic Apr 29, 2019
a3d7695
If timestamps are configured, change format to do all operations insi…
keithbostic May 3, 2019
254a747
whitespace
keithbostic May 3, 2019
488f5e6
Long-lines.
keithbostic May 3, 2019
d48c803
ops.c:415:21: error: read_ts may be used uninitialized in this function
keithbostic May 4, 2019
f9ab031
ops.c(925): warning C4047: 'function': 'bool' differs in levels of
keithbostic May 4, 2019
93e3906
ops.c:1334:35: error: variable 'commit_ts' may be uninitialized when
keithbostic May 4, 2019
5133d80
Switch boolean function arguments to type boolean.
keithbostic May 4, 2019
74dff33
Don't set transaction_timestamps permanently, it will skew the dice on
keithbostic May 4, 2019
f46f1fc
Read timestamps that are older than the oldest timestamp no longer ou…
keithbostic May 4, 2019
cfc5e0e
Merge branch 'develop' into wt-4733-format-timestamp-testing
keithbostic May 4, 2019
985605c
Fix some random indentation typos.
keithbostic May 4, 2019
37eca8a
Merge branch 'develop' into wt-4733-format-timestamp-testing
keithbostic May 6, 2019
0da1fd7
Merge branch 'develop' into wt-4733-format-timestamp-testing
keithbostic May 6, 2019
0b45a80
Merge branch 'develop' into wt-4733-format-timestamp-testing
keithbostic May 10, 2019
cb65fb5
Merge branch 'develop' into wt-4733-format-timestamp-testing
michaelcahill May 13, 2019
ad833cf
fixed a bug of assigning durable timestamp correctly.
bvpvamsikrishna May 22, 2019
ae07362
Merge branch 'develop' into wt-4733-format-timestamp-testing
keithbostic Jun 5, 2019
d0a6dbf
Merge branch 'develop' into wt-4733-format-timestamp-testing
keithbostic Jun 13, 2019
5c43ebf
WT-4733 bug fixes to long-term repeatable read branch (#4697)
keithbostic Jun 24, 2019
99975a2
Merge branch 'develop' into wt-4733-format-timestamp-testing
keithbostic Jun 24, 2019
ab4f9a0
Don't try and repeat read operations after a commit if there's either
keithbostic Jun 24, 2019
5d3a9dd
Do the bulk load with transactions if timestamps are configured,
keithbostic Jun 24, 2019
6a396a3
Now that bulk-load may be in a transaction, handle the possible insert
keithbostic Jun 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ t = env.Program("t_format",
"test/format/ops.c",
"test/format/rebalance.c",
"test/format/salvage.c",
"test/format/snap.c",
"test/format/t.c",
"test/format/util.c",
"test/format/wts.c"],
Expand Down
1 change: 1 addition & 0 deletions dist/s_define.list
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ WT_PACKED_STRUCT_END
WT_PADDING_CHECK
WT_PREPARE_INIT
WT_READ_BARRIER
WT_REF_SAVE_STATE_MAX
WT_REF_SIZE
WT_SESSION_LOCKED_CHECKPOINT
WT_SESSION_LOCKED_HOTBACKUP
Expand Down
4 changes: 2 additions & 2 deletions dist/s_string.ok
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ LZO
LeafGreen
LevelDB
Levyx
Llqr
Llqrt
LmT
LoadLoad
LockFile
Expand Down Expand Up @@ -948,6 +946,8 @@ lookaside
lookup
lookups
lossy
lqr
lqrt
lr
lrt
lru
Expand Down
12 changes: 7 additions & 5 deletions src/docs/checkpoint.dox
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ archiving purposes.
@section checkpoint_cursors Checkpoint cursors

Cursors are normally opened in the most recent version of a data source.
However, a checkpoint configuration string may be provided to
WT_SESSION::open_cursor, opening a read-only, static view of the data
source. This provides a limited form of time-travel, as the static view
is not changed by subsequent checkpoints, and will persist until the
checkpoint cursor is closed.
However, a checkpoint configuration string may be provided
to WT_SESSION::open_cursor, opening a read-only, static view of the
data source. This provides a limited form of time-travel, as the static
view is not changed by subsequent checkpoints and will persist until
the checkpoint cursor is closed. While it is not an error to set a read
timestamp in a transaction including a checkpoint cursor, it also has no
effect on the checkpoint cursor's behavior.

@section checkpoint_naming Checkpoint naming

Expand Down
13 changes: 7 additions & 6 deletions src/include/btmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -901,22 +901,23 @@ struct __wt_ref {
#define WT_REF_CAS_STATE(session, ref, old_state, new_state) \
__wt_ref_cas_state_int((session), (ref), (old_state), (new_state),\
__FILE__, __LINE__)
#define WT_REF_SAVE_STATE_MAX 3
#ifdef HAVE_DIAGNOSTIC
/* Capture history of ref state changes. */
struct __wt_ref_hist {
WT_SESSION_IMPL *session;
const char *name;
const char *file;
int line;
uint32_t state;
} hist[3];
uint16_t line;
uint16_t state;
} hist[WT_REF_SAVE_STATE_MAX];
uint64_t histoff;
#define WT_REF_SAVE_STATE(ref, s, f, l) do { \
(ref)->hist[(ref)->histoff].session = session; \
(ref)->hist[(ref)->histoff].name = session->name; \
(ref)->hist[(ref)->histoff].file = (f); \
(ref)->hist[(ref)->histoff].line = (l); \
(ref)->hist[(ref)->histoff].state = s; \
(ref)->hist[(ref)->histoff].line = (uint16_t)(l); \
(ref)->hist[(ref)->histoff].state = (uint16_t)(s); \
(ref)->histoff = \
((ref)->histoff + 1) % WT_ELEMENTS((ref)->hist); \
} while (0)
Expand All @@ -933,7 +934,7 @@ struct __wt_ref {
* the compiler hasn't inserted padding which would break the world.
*/
#ifdef HAVE_DIAGNOSTIC
#define WT_REF_SIZE (56 + 3 * sizeof(WT_REF_HIST) + 8)
#define WT_REF_SIZE (56 + WT_REF_SAVE_STATE_MAX * sizeof(WT_REF_HIST) + 8)
#else
#define WT_REF_SIZE 56
#endif
Expand Down
10 changes: 5 additions & 5 deletions src/reconcile/rec_visibility.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,9 @@ __wt_rec_upd_select(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_INSERT *ins,
r->unstable_txn = first_upd->txnid;
if (first_ts_upd != NULL) {
WT_ASSERT(session,
first_ts_upd->prepare_state ==
WT_PREPARE_INPROGRESS ||
first_ts_upd->start_ts <= first_ts_upd->durable_ts);
first_ts_upd->prepare_state ==
WT_PREPARE_INPROGRESS ||
first_ts_upd->start_ts <= first_ts_upd->durable_ts);

if (r->unstable_timestamp < first_ts_upd->start_ts)
r->unstable_timestamp = first_ts_upd->start_ts;
Expand All @@ -452,8 +452,8 @@ __wt_rec_upd_select(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_INSERT *ins,
* both will be set.
*/
WT_ASSERT(session,
upd->prepare_state == WT_PREPARE_INPROGRESS ||
upd->durable_ts >= upd->start_ts);
upd->prepare_state == WT_PREPARE_INPROGRESS ||
upd->durable_ts >= upd->start_ts);

if (r->unstable_timestamp > upd->start_ts)
r->unstable_timestamp = upd->start_ts;
Expand Down
2 changes: 1 addition & 1 deletion src/txn/txn.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[])
"transaction");

WT_ASSERT(session,
txn->prepare_timestamp <= txn->commit_timestamp);
txn->prepare_timestamp <= txn->commit_timestamp);
} else {
if (F_ISSET(txn, WT_TXN_HAS_TS_PREPARE))
WT_ERR_MSG(session, EINVAL,
Expand Down
2 changes: 1 addition & 1 deletion test/format/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ noinst_PROGRAMS = t
noinst_SCRIPTS = s_dumpcmp
t_SOURCES =\
backup.c bulk.c compact.c config.c lrt.c ops.c rebalance.c \
salvage.c t.c util.c wts.c
salvage.c snap.c t.c util.c wts.c

if HAVE_BERKELEY_DB
t_SOURCES += bdb.c
Expand Down
103 changes: 75 additions & 28 deletions test/format/bulk.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,49 @@

#include "format.h"

/*
* bulk_begin_transaction --
* Begin a bulk-load transaction.
*/
static void
bulk_begin_transaction(WT_SESSION *session)
{
uint64_t ts;
char buf[64];

wiredtiger_begin_transaction(session, "isolation=snapshot");
ts = __wt_atomic_addv64(&g.timestamp, 1);
testutil_check(__wt_snprintf(
buf, sizeof(buf), "read_timestamp=%" PRIx64, ts));
testutil_check(session->timestamp_transaction(session, buf));
}

/*
* bulk_commit_transaction --
* Commit a bulk-load transaction.
*/
static void
bulk_commit_transaction(WT_SESSION *session)
{
uint64_t ts;
char buf[64];

ts = __wt_atomic_addv64(&g.timestamp, 1);
testutil_check(__wt_snprintf(
buf, sizeof(buf), "commit_timestamp=%" PRIx64, ts));
testutil_check(session->commit_transaction(session, buf));
}

/*
* bulk_rollback_transaction --
* Rollback a bulk-load transaction.
*/
static void
bulk_rollback_transaction(WT_SESSION *session)
{
testutil_check(session->rollback_transaction(session, NULL));
}

void
wts_load(void)
{
Expand All @@ -42,9 +85,7 @@ wts_load(void)

testutil_check(conn->open_session(conn, NULL, NULL, &session));

if (g.logging != 0)
(void)g.wt_api->msg_printf(g.wt_api, session,
"=============== bulk load start ===============");
logop(session, "%s", "=============== bulk load start");

/*
* No bulk load with data-sources.
Expand All @@ -71,16 +112,25 @@ wts_load(void)
key_gen_init(&key);
val_gen_init(&value);

if (g.c_txn_timestamps)
bulk_begin_transaction(session);
agorrod marked this conversation as resolved.
Show resolved Hide resolved

for (;;) {
if (++g.key_cnt > g.c_rows) {
g.key_cnt = g.rows = g.c_rows;
break;
}

/* Report on progress every 100 inserts. */
if (g.key_cnt % 1000 == 0)
if (g.key_cnt % 10000 == 0) {
track("bulk load", g.key_cnt, NULL);

if (g.c_txn_timestamps) {
bulk_commit_transaction(session);
bulk_begin_transaction(session);
}
}

key_gen(&key, g.key_cnt);
val_gen(NULL, &value, g.key_cnt);

Expand All @@ -89,34 +139,24 @@ wts_load(void)
if (!is_bulk)
cursor->set_key(cursor, g.key_cnt);
cursor->set_value(cursor, *(uint8_t *)value.data);
if (g.logging == LOG_OPS)
(void)g.wt_api->msg_printf(g.wt_api, session,
"%-10s %" PRIu64 " {0x%02" PRIx8 "}",
"bulk V",
g.key_cnt, ((uint8_t *)value.data)[0]);
logop(session, "%-10s %" PRIu64 " {0x%02" PRIx8 "}",
"bulk", g.key_cnt, ((uint8_t *)value.data)[0]);
break;
case VAR:
if (!is_bulk)
cursor->set_key(cursor, g.key_cnt);
cursor->set_value(cursor, &value);
if (g.logging == LOG_OPS)
(void)g.wt_api->msg_printf(g.wt_api, session,
"%-10s %" PRIu64 " {%.*s}", "bulk V",
g.key_cnt,
(int)value.size, (char *)value.data);
logop(session, "%-10s %" PRIu64 " {%.*s}", "bulk",
g.key_cnt, (int)value.size, (char *)value.data);
break;
case ROW:
cursor->set_key(cursor, &key);
if (g.logging == LOG_OPS)
(void)g.wt_api->msg_printf(g.wt_api, session,
"%-10s %" PRIu64 " {%.*s}", "bulk K",
g.key_cnt, (int)key.size, (char *)key.data);
cursor->set_value(cursor, &value);
if (g.logging == LOG_OPS)
(void)g.wt_api->msg_printf(g.wt_api, session,
"%-10s %" PRIu64 " {%.*s}", "bulk V",
g.key_cnt,
(int)value.size, (char *)value.data);
logop(session,
"%-10s %" PRIu64 " {%.*s}, {%.*s}", "bulk",
g.key_cnt,
(int)key.size, (char *)key.data,
(int)value.size, (char *)value.data);
break;
}

Expand All @@ -132,8 +172,14 @@ wts_load(void)
* extra space once the run starts.
*/
if ((ret = cursor->insert(cursor)) != 0) {
if (ret != WT_CACHE_FULL)
testutil_die(ret, "cursor.insert");
testutil_assert(
ret == WT_CACHE_FULL || ret == WT_ROLLBACK);

if (g.c_txn_timestamps) {
bulk_rollback_transaction(session);
bulk_begin_transaction(session);
}

g.rows = --g.key_cnt;
g.c_rows = (uint32_t)g.key_cnt;

Expand All @@ -150,11 +196,12 @@ wts_load(void)
#endif
}

if (g.c_txn_timestamps)
bulk_commit_transaction(session);

testutil_check(cursor->close(cursor));

if (g.logging != 0)
(void)g.wt_api->msg_printf(g.wt_api, session,
"=============== bulk load stop ===============");
logop(session, "%s", "=============== bulk load stop");

testutil_check(session->close(session, NULL));

Expand Down
Loading