Skip to content

Commit a28e071

Browse files
lukechEvergreen Agent
authored andcommitted
Import wiredtiger: 850b579d4b526de7f296cb617999ccc20adb4aff from branch mongodb-4.6
ref: 4cacb06e31..850b579d4b for: 4.5.1 WT-5693 Enable test_wt4105_large_doc_small_upd WT-6390 Extend compact02 timeout from 8 => 10 minutes WT-6569 Squash the prepared updates into a single update before writing it to data store WT-6578 Prevent reconciliation from looking past the on-disk value WT-6602 Allow operation timeout ms to be passed to commit and rollback
1 parent 63e6928 commit a28e071

File tree

20 files changed

+428
-64
lines changed

20 files changed

+428
-64
lines changed

src/third_party/wiredtiger/dist/api_data.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,11 +1450,11 @@ def __ge__(self, other):
14501450
Config('name', '', r'''
14511451
name of the transaction for tracing and debugging'''),
14521452
Config('operation_timeout_ms', '0', r'''
1453-
when non-zero, a requested limit on the number of elapsed real time milliseconds taken
1454-
to complete database operations in this transaction. Time is measured from the start
1455-
of each WiredTiger API call. There is no guarantee any operation will not take longer
1456-
than this amount of time. If WiredTiger notices the limit has been exceeded, an operation
1457-
may return a WT_ROLLBACK error. Default is to have no limit''',
1453+
when non-zero, a requested limit on the time taken to complete operations in this
1454+
transaction. Time is measured in real time milliseconds from the start of each WiredTiger
1455+
API call. There is no guarantee any operation will not take longer than this amount of time.
1456+
If WiredTiger notices the limit has been exceeded, an operation may return a WT_ROLLBACK
1457+
error. Default is to have no limit''',
14581458
min=1),
14591459
Config('priority', 0, r'''
14601460
priority of the transaction for resolving conflicts.
@@ -1501,6 +1501,13 @@ def __ge__(self, other):
15011501
current transaction. The value must also not be older than the
15021502
current stable timestamp. See
15031503
@ref transaction_timestamps'''),
1504+
Config('operation_timeout_ms', '0', r'''
1505+
when non-zero, a requested limit on the time taken to complete operations in this
1506+
transaction. Time is measured in real time milliseconds from the start of each WiredTiger
1507+
API call. There is no guarantee any operation will not take longer than this amount of time.
1508+
If WiredTiger notices the limit has been exceeded, an operation may return a WT_ROLLBACK
1509+
error. Default is to have no limit''',
1510+
min=1),
15041511
Config('sync', '', r'''
15051512
override whether to sync log records when the transaction commits,
15061513
inherited from ::wiredtiger_open \c transaction_sync.
@@ -1542,7 +1549,15 @@ def __ge__(self, other):
15421549
for a transaction. See @ref transaction_timestamps'''),
15431550
]),
15441551

1545-
'WT_SESSION.rollback_transaction' : Method([]),
1552+
'WT_SESSION.rollback_transaction' : Method([
1553+
Config('operation_timeout_ms', '0', r'''
1554+
when non-zero, a requested limit on the time taken to complete operations in this
1555+
transaction. Time is measured in real time milliseconds from the start of each WiredTiger
1556+
API call. There is no guarantee any operation will not take longer than this amount of time.
1557+
If WiredTiger notices the limit has been exceeded, an operation may return a WT_ROLLBACK
1558+
error. Default is to have no limit''',
1559+
min=1),
1560+
]),
15461561

15471562
'WT_SESSION.checkpoint' : Method([
15481563
Config('drop', '', r'''

src/third_party/wiredtiger/import.data

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"vendor": "wiredtiger",
33
"github": "wiredtiger/wiredtiger.git",
44
"branch": "mongodb-4.6",
5-
"commit": "4cacb06e31b67cd17e0ecdcc366c3e9466e5ac3a"
5+
"commit": "850b579d4b526de7f296cb617999ccc20adb4aff"
66
}

src/third_party/wiredtiger/src/btree/bt_page.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,20 @@ __inmem_row_leaf(WT_SESSION_IMPL *session, WT_PAGE *page)
633633
tombstone->prepare_state = WT_PREPARE_INPROGRESS;
634634
F_SET(tombstone, WT_UPDATE_PREPARE_RESTORED_FROM_DS);
635635
F_SET(upd, WT_UPDATE_RESTORED_FROM_DS);
636+
637+
/*
638+
* Mark the update also as in-progress if the update and tombstone are from same
639+
* transaction by comparing both the transaction and timestamps as the transaction
640+
* information gets lost after restart.
641+
*/
642+
if (unpack.tw.start_ts == unpack.tw.stop_ts &&
643+
unpack.tw.durable_start_ts == unpack.tw.durable_stop_ts &&
644+
unpack.tw.start_txn == unpack.tw.stop_txn) {
645+
upd->durable_ts = WT_TS_NONE;
646+
upd->prepare_state = WT_PREPARE_INPROGRESS;
647+
F_SET(upd, WT_UPDATE_PREPARE_RESTORED_FROM_DS);
648+
}
649+
636650
tombstone->next = upd;
637651
} else {
638652
upd->durable_ts = WT_TS_NONE;

src/third_party/wiredtiger/src/config/config_def.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ static const WT_CONFIG_CHECK confchk_WT_SESSION_checkpoint[] = {
215215
static const WT_CONFIG_CHECK confchk_WT_SESSION_commit_transaction[] = {
216216
{"commit_timestamp", "string", NULL, NULL, NULL, 0},
217217
{"durable_timestamp", "string", NULL, NULL, NULL, 0},
218+
{"operation_timeout_ms", "int", NULL, "min=1", NULL, 0},
218219
{"sync", "string", NULL, "choices=[\"background\",\"off\",\"on\"]", NULL, 0},
219220
{NULL, NULL, NULL, NULL, NULL, 0}};
220221

@@ -345,6 +346,9 @@ static const WT_CONFIG_CHECK confchk_WT_SESSION_reconfigure[] = {
345346
NULL, 0},
346347
{NULL, NULL, NULL, NULL, NULL, 0}};
347348

349+
static const WT_CONFIG_CHECK confchk_WT_SESSION_rollback_transaction[] = {
350+
{"operation_timeout_ms", "int", NULL, "min=1", NULL, 0}, {NULL, NULL, NULL, NULL, NULL, 0}};
351+
348352
static const WT_CONFIG_CHECK confchk_WT_SESSION_salvage[] = {
349353
{"force", "boolean", NULL, NULL, NULL, 0}, {NULL, NULL, NULL, NULL, NULL, 0}};
350354

@@ -887,7 +891,9 @@ static const WT_CONFIG_ENTRY config_entries[] = {{"WT_CONNECTION.add_collator",
887891
confchk_WT_SESSION_checkpoint, 5},
888892
{"WT_SESSION.close", "", NULL, 0},
889893
{"WT_SESSION.commit_transaction",
890-
"commit_timestamp=,durable_timestamp=,sync=", confchk_WT_SESSION_commit_transaction, 3},
894+
"commit_timestamp=,durable_timestamp=,operation_timeout_ms=0,"
895+
"sync=",
896+
confchk_WT_SESSION_commit_transaction, 4},
891897
{"WT_SESSION.compact", "timeout=1200", confchk_WT_SESSION_compact, 1},
892898
{"WT_SESSION.create",
893899
"access_pattern_hint=none,allocation_size=4KB,app_metadata=,"
@@ -939,7 +945,8 @@ static const WT_CONFIG_ENTRY config_entries[] = {{"WT_CONNECTION.add_collator",
939945
"isolation=read-committed",
940946
confchk_WT_SESSION_reconfigure, 3},
941947
{"WT_SESSION.rename", "", NULL, 0}, {"WT_SESSION.reset", "", NULL, 0},
942-
{"WT_SESSION.rollback_transaction", "", NULL, 0},
948+
{"WT_SESSION.rollback_transaction", "operation_timeout_ms=0",
949+
confchk_WT_SESSION_rollback_transaction, 1},
943950
{"WT_SESSION.salvage", "force=false", confchk_WT_SESSION_salvage, 1},
944951
{"WT_SESSION.strerror", "", NULL, 0},
945952
{"WT_SESSION.timestamp_transaction",

src/third_party/wiredtiger/src/history/hs.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ __wt_hs_cursor_search_near(WT_SESSION_IMPL *session, WT_CURSOR *cursor, int *exa
11601160
*/
11611161
int
11621162
__wt_hs_find_upd(WT_SESSION_IMPL *session, WT_ITEM *key, const char *value_format, uint64_t recno,
1163-
WT_UPDATE_VALUE *upd_value, bool allow_prepare, WT_ITEM *on_disk_buf)
1163+
WT_UPDATE_VALUE *upd_value, bool allow_prepare, WT_ITEM *on_disk_buf, WT_TIME_WINDOW *on_disk_tw)
11641164
{
11651165
WT_CURSOR *hs_cursor;
11661166
WT_CURSOR_BTREE *hs_cbt;
@@ -1341,6 +1341,21 @@ __wt_hs_find_upd(WT_SESSION_IMPL *session, WT_ITEM *key, const char *value_forma
13411341
break;
13421342
}
13431343

1344+
/*
1345+
* If we find a history store record that either corresponds to the on-disk value or is
1346+
* newer than it then we should use the on-disk value as the base value and apply our
1347+
* modifies on top of it.
1348+
*/
1349+
if (on_disk_tw->start_ts < hs_start_ts_tmp ||
1350+
(on_disk_tw->start_ts == hs_start_ts_tmp &&
1351+
on_disk_tw->start_txn <= hs_cbt->upd_value->tw.start_txn)) {
1352+
/* Fallback to the onpage value as the base value. */
1353+
orig_hs_value_buf = hs_value;
1354+
hs_value = on_disk_buf;
1355+
upd_type = WT_UPDATE_STANDARD;
1356+
break;
1357+
}
1358+
13441359
WT_ERR(hs_cursor->get_value(hs_cursor, &hs_stop_durable_ts_tmp, &durable_timestamp_tmp,
13451360
&upd_type_full, hs_value));
13461361
upd_type = (uint8_t)upd_type_full;

src/third_party/wiredtiger/src/include/btmem.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,12 +1075,13 @@ struct __wt_update {
10751075

10761076
/* AUTOMATIC FLAG VALUE GENERATION START */
10771077
#define WT_UPDATE_CLEARED_HS 0x01u /* Update that cleared the history store. */
1078-
#define WT_UPDATE_HS 0x02u /* Update has been written to history store. */
1079-
#define WT_UPDATE_OBSOLETE 0x04u /* Update that is obsolete. */
1080-
#define WT_UPDATE_PREPARE_RESTORED_FROM_DS 0x08u /* Prepared update restored from data store. */
1081-
#define WT_UPDATE_RESTORED_FAST_TRUNCATE 0x10u /* Fast truncate instantiation */
1082-
#define WT_UPDATE_RESTORED_FROM_DS 0x20u /* Update restored from data store. */
1083-
#define WT_UPDATE_RESTORED_FROM_HS 0x40u /* Update restored from history store. */
1078+
#define WT_UPDATE_DS 0x02u /* Update has been written to the data store. */
1079+
#define WT_UPDATE_HS 0x04u /* Update has been written to history store. */
1080+
#define WT_UPDATE_OBSOLETE 0x08u /* Update that is obsolete. */
1081+
#define WT_UPDATE_PREPARE_RESTORED_FROM_DS 0x10u /* Prepared update restored from data store. */
1082+
#define WT_UPDATE_RESTORED_FAST_TRUNCATE 0x20u /* Fast truncate instantiation */
1083+
#define WT_UPDATE_RESTORED_FROM_DS 0x40u /* Update restored from data store. */
1084+
#define WT_UPDATE_RESTORED_FROM_HS 0x80u /* Update restored from history store. */
10841085
/* AUTOMATIC FLAG VALUE GENERATION STOP */
10851086
uint8_t flags;
10861087

src/third_party/wiredtiger/src/include/extern.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,8 +771,8 @@ extern int __wt_hs_cursor_search_near(WT_SESSION_IMPL *session, WT_CURSOR *curso
771771
extern int __wt_hs_delete_key_from_ts(WT_SESSION_IMPL *session, uint32_t btree_id,
772772
const WT_ITEM *key, wt_timestamp_t ts) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
773773
extern int __wt_hs_find_upd(WT_SESSION_IMPL *session, WT_ITEM *key, const char *value_format,
774-
uint64_t recno, WT_UPDATE_VALUE *upd_value, bool allow_prepare, WT_ITEM *on_disk_buf)
775-
WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
774+
uint64_t recno, WT_UPDATE_VALUE *upd_value, bool allow_prepare, WT_ITEM *on_disk_buf,
775+
WT_TIME_WINDOW *on_disk_tw) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
776776
extern int __wt_hs_get_btree(WT_SESSION_IMPL *session, WT_BTREE **hs_btreep)
777777
WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
778778
extern int __wt_hs_insert_updates(WT_SESSION_IMPL *session, WT_PAGE *page, WT_MULTI *multi)

src/third_party/wiredtiger/src/include/txn.i

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ retry:
993993
/* If there's no visible update in the update chain or ondisk, check the history store file. */
994994
if (F_ISSET(S2C(session), WT_CONN_HS_OPEN) && !F_ISSET(S2BT(session), WT_BTREE_HS))
995995
WT_RET_NOTFOUND_OK(__wt_hs_find_upd(session, key, cbt->iface.value_format, recno,
996-
cbt->upd_value, false, &cbt->upd_value->buf));
996+
cbt->upd_value, false, &cbt->upd_value->buf, &tw));
997997

998998
/*
999999
* Retry if we race with prepared commit or rollback. If we race with prepared rollback, the
@@ -1045,8 +1045,7 @@ __wt_txn_begin(WT_SESSION_IMPL *session, const char *cfg[])
10451045

10461046
WT_ASSERT(session, !F_ISSET(txn, WT_TXN_RUNNING));
10471047

1048-
if (cfg != NULL)
1049-
WT_RET(__wt_txn_config(session, cfg));
1048+
WT_RET(__wt_txn_config(session, cfg));
10501049

10511050
/* Allocate a snapshot if required. */
10521051
if (txn->isolation == WT_ISO_SNAPSHOT) {

src/third_party/wiredtiger/src/include/wiredtiger.in

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,12 +1766,12 @@ struct __wt_session {
17661766
* \c "read-committed"\, \c "snapshot"; default empty.}
17671767
* @config{name, name of the transaction for tracing and debugging., a string; default
17681768
* empty.}
1769-
* @config{operation_timeout_ms, when non-zero\, a requested limit on the number of elapsed
1770-
* real time milliseconds taken to complete database operations in this transaction. Time
1771-
* is measured from the start of each WiredTiger API call. There is no guarantee any
1772-
* operation will not take longer than this amount of time. If WiredTiger notices the limit
1773-
* has been exceeded\, an operation may return a WT_ROLLBACK error. Default is to have no
1774-
* limit., an integer greater than or equal to 1; default \c 0.}
1769+
* @config{operation_timeout_ms, when non-zero\, a requested limit on the time taken to
1770+
* complete operations in this transaction. Time is measured in real time milliseconds from
1771+
* the start of each WiredTiger API call. There is no guarantee any operation will not take
1772+
* longer than this amount of time. If WiredTiger notices the limit has been exceeded\, an
1773+
* operation may return a WT_ROLLBACK error. Default is to have no limit., an integer
1774+
* greater than or equal to 1; default \c 0.}
17751775
* @config{priority, priority of the transaction for resolving conflicts. Transactions with
17761776
* higher values are less likely to abort., an integer between -100 and 100; default \c 0.}
17771777
* @config{read_timestamp, read using the specified timestamp. The supplied value must not
@@ -1820,6 +1820,12 @@ struct __wt_session {
18201820
* supplied value must not be older than the commit timestamp set for the current
18211821
* transaction. The value must also not be older than the current stable timestamp. See
18221822
* @ref transaction_timestamps., a string; default empty.}
1823+
* @config{operation_timeout_ms, when non-zero\, a requested limit on the time taken to
1824+
* complete operations in this transaction. Time is measured in real time milliseconds from
1825+
* the start of each WiredTiger API call. There is no guarantee any operation will not take
1826+
* longer than this amount of time. If WiredTiger notices the limit has been exceeded\, an
1827+
* operation may return a WT_ROLLBACK error. Default is to have no limit., an integer
1828+
* greater than or equal to 1; default \c 0.}
18231829
* @config{sync, override whether to sync log records when the transaction commits\,
18241830
* inherited from ::wiredtiger_open \c transaction_sync. The \c background setting
18251831
* initiates a background synchronization intended to be used with a later call to
@@ -1869,7 +1875,14 @@ struct __wt_session {
18691875
* @snippet ex_all.c transaction commit/rollback
18701876
*
18711877
* @param session the session handle
1872-
* @configempty{WT_SESSION.rollback_transaction, see dist/api_data.py}
1878+
* @configstart{WT_SESSION.rollback_transaction, see dist/api_data.py}
1879+
* @config{operation_timeout_ms, when non-zero\, a requested limit on the time taken to
1880+
* complete operations in this transaction. Time is measured in real time milliseconds from
1881+
* the start of each WiredTiger API call. There is no guarantee any operation will not take
1882+
* longer than this amount of time. If WiredTiger notices the limit has been exceeded\, an
1883+
* operation may return a WT_ROLLBACK error. Default is to have no limit., an integer
1884+
* greater than or equal to 1; default \c 0.}
1885+
* @configend
18731886
* @errors
18741887
*/
18751888
int __F(rollback_transaction)(WT_SESSION *session, const char *config);

src/third_party/wiredtiger/src/reconcile/rec_row.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,17 @@ __rec_row_leaf_insert(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_INSERT *ins)
590590
continue;
591591
}
592592

593+
/*
594+
* If we've selected an update, it should be flagged as being destined for the data store.
595+
*
596+
* If not, it's either because we're not doing a history store reconciliation or because the
597+
* update is globally visible (in which case, subsequent updates become irrelevant for
598+
* reconciliation).
599+
*/
600+
WT_ASSERT(session,
601+
F_ISSET(upd, WT_UPDATE_DS) || !F_ISSET(r, WT_REC_HS) ||
602+
__wt_txn_tw_start_visible_all(session, &upd_select.tw));
603+
593604
WT_TIME_WINDOW_COPY(&tw, &upd_select.tw);
594605

595606
switch (upd->type) {
@@ -839,6 +850,18 @@ __wt_rec_row_leaf(
839850
r->ovfl_items = true;
840851
}
841852
} else {
853+
/*
854+
* If we've selected an update, it should be flagged as being destined for the data
855+
* store.
856+
*
857+
* If not, it's either because we're not doing a history store reconciliation or because
858+
* the update is globally visible (in which case, subsequent updates become irrelevant
859+
* for reconciliation).
860+
*/
861+
WT_ASSERT(session,
862+
F_ISSET(upd, WT_UPDATE_DS) || !F_ISSET(r, WT_REC_HS) ||
863+
__wt_txn_tw_start_visible_all(session, &upd_select.tw));
864+
842865
/* The first time we find an overflow record, discard the underlying blocks. */
843866
if (F_ISSET(vpack, WT_CELL_UNPACK_OVERFLOW) && vpack->raw != WT_CELL_VALUE_OVFL_RM)
844867
WT_ERR(__wt_ovfl_remove(session, page, vpack));

0 commit comments

Comments
 (0)