Skip to content

Commit

Permalink
Revert "WT-4968 remove all committed and connection level commit time…
Browse files Browse the repository at this point in the history
…stamps (#5040)" (#5053)

This reverts commit c2e9914.
  • Loading branch information
lukech committed Dec 16, 2019
1 parent 99636a2 commit 2b7cf1e
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 46 deletions.
14 changes: 12 additions & 2 deletions dist/api_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,8 @@ def __ge__(self, other):

'WT_CONNECTION.query_timestamp' : Method([
Config('get', 'all_durable', r'''
specify which timestamp to query:
specify which timestamp to query: \c all_committed returns the largest
timestamp such that all timestamps up to that value have committed,
\c all_durable returns the largest timestamp such that all timestamps
up to that value have been made durable, \c last_checkpoint returns the
timestamp of the most recent stable checkpoint, \c oldest returns the
Expand All @@ -1579,11 +1580,20 @@ def __ge__(self, other):
timestamp of the most recent stable checkpoint taken prior to a shutdown
and \c stable returns the most recent \c stable_timestamp set with
WT_CONNECTION::set_timestamp. See @ref transaction_timestamps''',
choices=['all_durable','last_checkpoint',
choices=['all_committed','all_durable','last_checkpoint',
'oldest','oldest_reader','pinned','recovery','stable']),
]),

'WT_CONNECTION.set_timestamp' : Method([
Config('commit_timestamp', '', r'''
(deprecated) reset the maximum commit timestamp tracked by WiredTiger.
This will cause future calls to WT_CONNECTION::query_timestamp to
ignore commit timestamps greater than the specified value until the
next commit moves the tracked commit timestamp forwards. This is only
intended for use where the application is rolling back locally
committed transactions. The supplied value must not be older than the
current oldest and stable timestamps.
See @ref transaction_timestamps'''),
Config('durable_timestamp', '', r'''
reset the maximum durable timestamp tracked by WiredTiger. This will
cause future calls to WT_CONNECTION::query_timestamp to ignore durable
Expand Down
4 changes: 2 additions & 2 deletions examples/c/ex_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -912,12 +912,12 @@ transaction_ops(WT_SESSION *session_arg)

error_check(session->commit_transaction(session, NULL));

error_check(conn->query_timestamp(conn, timestamp_buf, "get=all_durable"));
error_check(conn->query_timestamp(conn, timestamp_buf, "get=all_committed"));
/*! [query timestamp] */
}

/*! [set commit timestamp] */
error_check(conn->set_timestamp(conn, "durable_timestamp=2a"));
error_check(conn->set_timestamp(conn, "commit_timestamp=2a"));
/*! [set commit timestamp] */

/*! [set oldest timestamp] */
Expand Down
12 changes: 7 additions & 5 deletions src/config/config_def.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ static const WT_CONFIG_CHECK confchk_WT_CONNECTION_open_session[] = {

static const WT_CONFIG_CHECK confchk_WT_CONNECTION_query_timestamp[] = {
{"get", "string", NULL,
"choices=[\"all_durable\",\"last_checkpoint\",\"oldest\","
"\"oldest_reader\",\"pinned\",\"recovery\",\"stable\"]",
"choices=[\"all_committed\",\"all_durable\","
"\"last_checkpoint\",\"oldest\",\"oldest_reader\",\"pinned\","
"\"recovery\",\"stable\"]",
NULL, 0},
{NULL, NULL, NULL, NULL, NULL, 0}};

Expand Down Expand Up @@ -145,6 +146,7 @@ static const WT_CONFIG_CHECK confchk_WT_CONNECTION_reconfigure[] = {
{NULL, NULL, NULL, NULL, NULL, 0}};

static const WT_CONFIG_CHECK confchk_WT_CONNECTION_set_timestamp[] = {
{"commit_timestamp", "string", NULL, NULL, NULL, 0},
{"durable_timestamp", "string", NULL, NULL, NULL, 0}, {"force", "boolean", NULL, NULL, NULL, 0},
{"oldest_timestamp", "string", NULL, NULL, NULL, 0},
{"stable_timestamp", "string", NULL, NULL, NULL, 0}, {NULL, NULL, NULL, NULL, NULL, 0}};
Expand Down Expand Up @@ -822,9 +824,9 @@ static const WT_CONFIG_ENTRY config_entries[] = {{"WT_CONNECTION.add_collator",
confchk_WT_CONNECTION_reconfigure, 26},
{"WT_CONNECTION.rollback_to_stable", "", NULL, 0}, {"WT_CONNECTION.set_file_system", "", NULL, 0},
{"WT_CONNECTION.set_timestamp",
"durable_timestamp=,force=false,oldest_timestamp=,"
"stable_timestamp=",
confchk_WT_CONNECTION_set_timestamp, 4},
"commit_timestamp=,durable_timestamp=,force=false,"
"oldest_timestamp=,stable_timestamp=",
confchk_WT_CONNECTION_set_timestamp, 5},
{"WT_CURSOR.close", "", NULL, 0},
{"WT_CURSOR.reconfigure", "append=false,overwrite=true", confchk_WT_CURSOR_reconfigure, 2},
{"WT_SESSION.alter",
Expand Down
29 changes: 19 additions & 10 deletions src/include/wiredtiger.in
Original file line number Diff line number Diff line change
Expand Up @@ -2439,16 +2439,18 @@ struct __wt_connection {
* hexadecimal encoding of the timestamp being queried. Must be large
* enough to hold a NUL terminated, hex-encoded 8B timestamp (17 bytes).
* @configstart{WT_CONNECTION.query_timestamp, see dist/api_data.py}
* @config{get, specify which timestamp to query: \c all_durable returns the largest
* timestamp such that all timestamps up to that value have been made durable\, \c
* last_checkpoint returns the timestamp of the most recent stable checkpoint\, \c oldest
* returns the most recent \c oldest_timestamp set with WT_CONNECTION::set_timestamp\, \c
* oldest_reader returns the minimum of the read timestamps of all active readers \c pinned
* returns the minimum of the \c oldest_timestamp and the read timestamps of all active
* readers\, \c recovery returns the timestamp of the most recent stable checkpoint taken
* prior to a shutdown and \c stable returns the most recent \c stable_timestamp set with
* WT_CONNECTION::set_timestamp. See @ref transaction_timestamps., a string\, chosen from
* the following options: \c "all_durable"\, \c "last_checkpoint"\, \c "oldest"\, \c
* @config{get, specify which timestamp to query: \c all_committed returns the largest
* timestamp such that all timestamps up to that value have committed\, \c all_durable
* returns the largest timestamp such that all timestamps up to that value have been made
* durable\, \c last_checkpoint returns the timestamp of the most recent stable checkpoint\,
* \c oldest returns the most recent \c oldest_timestamp set with
* WT_CONNECTION::set_timestamp\, \c oldest_reader returns the minimum of the read
* timestamps of all active readers \c pinned returns the minimum of the \c oldest_timestamp
* and the read timestamps of all active readers\, \c recovery returns the timestamp of the
* most recent stable checkpoint taken prior to a shutdown and \c stable returns the most
* recent \c stable_timestamp set with WT_CONNECTION::set_timestamp. See @ref
* transaction_timestamps., a string\, chosen from the following options: \c
* "all_committed"\, \c "all_durable"\, \c "last_checkpoint"\, \c "oldest"\, \c
* "oldest_reader"\, \c "pinned"\, \c "recovery"\, \c "stable"; default \c all_durable.}
* @configend
* @errors
Expand All @@ -2469,6 +2471,13 @@ struct __wt_connection {
*
* @param connection the connection handle
* @configstart{WT_CONNECTION.set_timestamp, see dist/api_data.py}
* @config{commit_timestamp, (deprecated) reset the maximum commit timestamp tracked by
* WiredTiger. This will cause future calls to WT_CONNECTION::query_timestamp to ignore
* commit timestamps greater than the specified value until the next commit moves the
* tracked commit timestamp forwards. This is only intended for use where the application
* is rolling back locally committed transactions. The supplied value must not be older
* than the current oldest and stable timestamps. See @ref transaction_timestamps., a
* string; default empty.}
* @config{durable_timestamp, reset the maximum durable timestamp tracked by WiredTiger.
* This will cause future calls to WT_CONNECTION::query_timestamp to ignore durable
* timestamps greater than the specified value until the next durable timestamp moves the
Expand Down
16 changes: 14 additions & 2 deletions src/txn/txn_timestamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ __txn_global_query_timestamp(WT_SESSION_IMPL *session, wt_timestamp_t *tsp, cons

WT_STAT_CONN_INCR(session, txn_query_ts);
WT_RET(__wt_config_gets(session, cfg, "get", &cval));
if (WT_STRING_MATCH("all_durable", cval.str, cval.len)) {
if (WT_STRING_MATCH("all_committed", cval.str, cval.len) ||
WT_STRING_MATCH("all_durable", cval.str, cval.len)) {
if (!txn_global->has_durable_timestamp)
return (WT_NOTFOUND);
ts = txn_global->durable_timestamp;
Expand Down Expand Up @@ -433,11 +434,22 @@ __wt_txn_global_set_timestamp(WT_SESSION_IMPL *session, const char *cfg[])

WT_STAT_CONN_INCR(session, txn_set_ts);

WT_RET(__wt_config_gets_def(session, cfg, "durable_timestamp", 0, &durable_cval));
/*
* TODO: When we remove all_committed, we need to remove this too. For now, we're temporarily
* aliasing the global commit timestamp to the global durable timestamp.
*/
WT_RET(__wt_config_gets_def(session, cfg, "commit_timestamp", 0, &durable_cval));
has_durable = durable_cval.len != 0;
if (has_durable)
WT_STAT_CONN_INCR(session, txn_set_ts_durable);

if (!has_durable) {
WT_RET(__wt_config_gets_def(session, cfg, "durable_timestamp", 0, &durable_cval));
has_durable = durable_cval.len != 0;
if (has_durable)
WT_STAT_CONN_INCR(session, txn_set_ts_durable);
}

WT_RET(__wt_config_gets_def(session, cfg, "oldest_timestamp", 0, &oldest_cval));
has_oldest = oldest_cval.len != 0;
if (has_oldest)
Expand Down
2 changes: 1 addition & 1 deletion test/csuite/timestamp_abort/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ thread_ts_run(void *arg)
* that requires locking out transactional ops that set or query a timestamp.
*/
testutil_check(pthread_rwlock_wrlock(&ts_lock));
ret = td->conn->query_timestamp(td->conn, ts_string, "get=all_durable");
ret = td->conn->query_timestamp(td->conn, ts_string, "get=all_committed");
testutil_check(pthread_rwlock_unlock(&ts_lock));
testutil_assert(ret == 0 || ret == WT_NOTFOUND);
if (ret == 0) {
Expand Down
4 changes: 2 additions & 2 deletions test/suite/test_timestamp02.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ def test_basic(self):
self.assertTimestampsEqual(self.conn.query_timestamp(), timestamp_str(200))

# Test that we can manually move the commit timestamp back
self.conn.set_timestamp('durable_timestamp=' + timestamp_str(150))
self.conn.set_timestamp('commit_timestamp=' + timestamp_str(150))
self.assertTimestampsEqual(self.conn.query_timestamp(), timestamp_str(150))
self.conn.set_timestamp('durable_timestamp=' + timestamp_str(200))
self.conn.set_timestamp('commit_timestamp=' + timestamp_str(200))

# Now the stable timestamp before we read.
self.conn.set_timestamp('stable_timestamp=' + timestamp_str(200))
Expand Down
Loading

0 comments on commit 2b7cf1e

Please sign in to comment.