From 2f93a13731d6b24c4101eca2d4652db18349d504 Mon Sep 17 00:00:00 2001 From: Etienne Petrel Date: Mon, 29 Aug 2022 22:42:09 +0000 Subject: Import wiredtiger: 064bbe0878ef559d76339d7812ef141e89436eaa from branch mongodb-master ref: dd3f4cb274..064bbe0878 for: 6.2.0-rc0 WT-9772 Fix RTS to abort the updates using the recovered checkpoint snapshot (#8229) --- src/third_party/wiredtiger/import.data | 2 +- .../wiredtiger/src/txn/txn_rollback_to_stable.c | 25 ++- .../test/format/failure_configs/CONFIG.WT-9772 | 212 +++++++++++++++++++++ 3 files changed, 235 insertions(+), 4 deletions(-) create mode 100644 src/third_party/wiredtiger/test/format/failure_configs/CONFIG.WT-9772 diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data index 0c95a055526..e9e1d548e58 100644 --- a/src/third_party/wiredtiger/import.data +++ b/src/third_party/wiredtiger/import.data @@ -2,5 +2,5 @@ "vendor": "wiredtiger", "github": "wiredtiger/wiredtiger.git", "branch": "mongodb-master", - "commit": "dd3f4cb2749cfd33551d66762a49063bb19459fd" + "commit": "064bbe0878ef559d76339d7812ef141e89436eaa" } diff --git a/src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c b/src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c index 0a17f020b05..1238681fd57 100644 --- a/src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c +++ b/src/third_party/wiredtiger/src/txn/txn_rollback_to_stable.c @@ -18,6 +18,8 @@ WT_DECL_VERBOSE_MULTI_CATEGORY(((WT_VERBOSE_CATEGORY[]){WT_VERB_RECOVERY, WT_VERB_RTS})) : \ WT_DECL_VERBOSE_MULTI_CATEGORY(((WT_VERBOSE_CATEGORY[]){WT_VERB_RTS}))) +static bool __rollback_txn_visible_id(WT_SESSION_IMPL *session, uint64_t id); + /* * __rollback_delete_hs -- * Delete the updates for a key in the history store until the first update (including) that is @@ -91,7 +93,19 @@ __rollback_abort_update(WT_SESSION_IMPL *session, WT_ITEM *key, WT_UPDATE *first if (upd->txnid == WT_TXN_ABORTED) continue; - if (rollback_timestamp < upd->durable_ts || upd->prepare_state == WT_PREPARE_INPROGRESS) { + /* + * An unstable update needs to be aborted if any of the following are true: + * 1. An update is invisible based on the checkpoint snapshot during recovery. + * 2. The update durable timestamp is greater than the stable timestamp. + * 3. The update is a prepared update. + * + * Usually during recovery, there are no in memory updates present on the page. But + * whenever an unstable fast truncate operation is written to the disk, as part + * of the rollback to stable page read, it instantiates the tombstones on the page. + * The transaction id validation is ignored in all scenarios except recovery. + */ + if (!__rollback_txn_visible_id(session, upd->txnid) || + rollback_timestamp < upd->durable_ts || upd->prepare_state == WT_PREPARE_INPROGRESS) { __wt_verbose_multi(session, WT_VERB_RECOVERY_RTS(session), "rollback to stable update aborted with txnid: %" PRIu64 " durable timestamp: %s and stable timestamp: %s, prepared: %s", @@ -1180,9 +1194,10 @@ __rollback_page_needs_abort( } __wt_verbose_multi(session, WT_VERB_RECOVERY_RTS(session), - "%p: page with %s durable timestamp: %s, newest txn: %" PRIu64 " and prepared updates: %s", + "%p: page with %s durable timestamp: %s, newest txn: %" PRIu64 + " and prepared updates: %s needs abort: %s", (void *)ref, tag, __wt_timestamp_to_string(durable_ts, ts_string), newest_txn, - prepared ? "true" : "false"); + prepared ? "true" : "false", result ? "true" : "false"); return (result); } @@ -1276,6 +1291,10 @@ __rollback_to_stable_page_skip( WT_ASSERT(session, page_del == NULL || page_del->prepare_state == WT_PREPARE_INIT || page_del->prepare_state == WT_PREPARE_RESOLVED); + + __wt_verbose_multi( + session, WT_VERB_RECOVERY_RTS(session), "%p: deleted page walk skipped", (void *)ref); + WT_STAT_CONN_INCR(session, txn_rts_tree_walk_skip_pages); *skipp = true; } WT_REF_SET_STATE(ref, WT_REF_DELETED); diff --git a/src/third_party/wiredtiger/test/format/failure_configs/CONFIG.WT-9772 b/src/third_party/wiredtiger/test/format/failure_configs/CONFIG.WT-9772 new file mode 100644 index 00000000000..54210bbc872 --- /dev/null +++ b/src/third_party/wiredtiger/test/format/failure_configs/CONFIG.WT-9772 @@ -0,0 +1,212 @@ +############################################ +# RUN PARAMETERS: V3 +############################################ +assert.read_timestamp=0 +backup=1 +backup.incremental=off +backup.incr_granularity=1957 +block_cache=0 +block_cache.cache_on_checkpoint=0 +block_cache.cache_on_writes=1 +block_cache.size=50 +btree.huffman_value=0 +cache=1682 +cache.evict_max=5 +cache.minimum=20 +checkpoint=wiredtiger +checkpoint.log_size=165 +checkpoint.wait=5 +disk.data_extend=0 +disk.direct_io=0 +disk.encryption=none +disk.mmap=1 +disk.mmap_all=0 +format.abort=0 +format.independent_thread_rng=1 +format.major_timeout=0 +import=0 +logging=0 +logging.compression=none +logging.file_max=384971 +logging.prealloc=0 +logging.remove=1 +ops.alter=0 +ops.compaction=0 +ops.hs_cursor=0 +ops.prepare=0 +ops.random_cursor=1 +ops.salvage=1 +ops.verify=1 +quiet=1 +runs.in_memory=0 +runs.ops=0 +runs.rows=1000000 +runs.tables=5 +runs.threads=28 +runs.timer=6 +runs.verify_failure_dump=0 +statistics=1 +statistics.server=0 +stress.aggressive_sweep=0 +stress.checkpoint=0 +stress.checkpoint_evict_page=0 +stress.checkpoint_reserved_txnid_delay=0 +stress.checkpoint_prepare=0 +stress.evict_reposition=0 +stress.failpoint_eviction_fail_after_reconciliation=1 +stress.failpoint_hs_delete_key_from_ts=1 +stress.hs_checkpoint_delay=0 +stress.hs_search=0 +stress.hs_sweep=0 +stress.split_1=0 +stress.split_2=0 +stress.split_3=0 +stress.split_4=0 +stress.split_5=0 +stress.split_6=0 +stress.split_7=0 +transaction.implicit=22 +transaction.timestamps=0 +wiredtiger.config=off +wiredtiger.rwlock=1 +wiredtiger.leak_memory=0 +############################################ +# TABLE PARAMETERS: table 1 +############################################ +table1.btree.compression=snappy +table1.btree.dictionary=0 +table1.btree.internal_key_truncation=1 +table1.btree.internal_page_max=9 +table1.btree.key_max=56 +table1.btree.key_min=32 +table1.btree.leaf_page_max=11 +table1.btree.memory_page_max=9 +table1.btree.prefix_len=0 +table1.btree.prefix_compression=1 +table1.btree.prefix_compression_min=6 +table1.btree.reverse=0 +table1.btree.split_pct=56 +table1.btree.value_max=1389 +table1.btree.value_min=19 +table1.disk.checksum=off +table1.disk.firstfit=0 +table1.ops.pct.delete=9 +table1.ops.pct.insert=11 +table1.ops.pct.modify=2 +table1.ops.pct.read=76 +table1.ops.pct.write=2 +table1.ops.truncate=1 +table1.runs.mirror=1 +table1.runs.source=table +table1.runs.type=row-store +############################################ +# TABLE PARAMETERS: table 2 +############################################ +table2.btree.compression=none +table2.btree.dictionary=0 +table2.btree.internal_key_truncation=1 +table2.btree.internal_page_max=10 +table2.btree.key_max=29 +table2.btree.key_min=29 +table2.btree.leaf_page_max=10 +table2.btree.memory_page_max=4 +table2.btree.prefix_len=0 +table2.btree.prefix_compression=1 +table2.btree.prefix_compression_min=5 +table2.btree.reverse=0 +table2.btree.split_pct=58 +table2.btree.value_max=2451 +table2.btree.value_min=4 +table2.disk.checksum=unencrypted +table2.disk.firstfit=0 +table2.ops.pct.delete=13 +table2.ops.pct.insert=1 +table2.ops.pct.modify=3 +table2.ops.pct.read=65 +table2.ops.pct.write=18 +table2.ops.truncate=1 +table2.runs.mirror=1 +table2.runs.source=table +table2.runs.type=row-store +############################################ +# TABLE PARAMETERS: table 3 +############################################ +table3.btree.compression=zstd +table3.btree.dictionary=0 +table3.btree.internal_key_truncation=1 +table3.btree.internal_page_max=10 +table3.btree.key_max=124 +table3.btree.key_min=21 +table3.btree.leaf_page_max=14 +table3.btree.memory_page_max=2 +table3.btree.prefix_len=0 +table3.btree.prefix_compression=1 +table3.btree.prefix_compression_min=1 +table3.btree.reverse=0 +table3.btree.split_pct=99 +table3.btree.value_max=853 +table3.btree.value_min=15 +table3.disk.checksum=unencrypted +table3.disk.firstfit=0 +table3.ops.pct.delete=2 +table3.ops.pct.insert=29 +table3.ops.pct.modify=39 +table3.ops.pct.read=22 +table3.ops.pct.write=8 +table3.ops.truncate=1 +table3.runs.mirror=1 +table3.runs.source=table +table3.runs.type=row-store +############################################ +# TABLE PARAMETERS: table 4 +############################################ +table4.btree.compression=zlib +table4.btree.dictionary=0 +table4.btree.internal_key_truncation=1 +table4.btree.internal_page_max=15 +table4.btree.key_max=89 +table4.btree.key_min=17 +table4.btree.leaf_page_max=17 +table4.btree.memory_page_max=10 +table4.btree.prefix_len=0 +table4.btree.prefix_compression=1 +table4.btree.prefix_compression_min=3 +table4.btree.reverse=0 +table4.btree.split_pct=53 +table4.btree.value_max=232 +table4.btree.value_min=0 +table4.disk.checksum=uncompressed +table4.disk.firstfit=0 +table4.ops.pct.delete=0 +table4.ops.pct.insert=22 +table4.ops.pct.modify=0 +table4.ops.pct.read=76 +table4.ops.pct.write=2 +table4.ops.truncate=1 +table4.runs.mirror=0 +table4.runs.source=table +table4.runs.type=row-store +############################################ +# TABLE PARAMETERS: table 5 +############################################ +table5.btree.compression=none +table5.btree.dictionary=0 +table5.btree.internal_key_truncation=1 +table5.btree.internal_page_max=9 +table5.btree.leaf_page_max=14 +table5.btree.memory_page_max=4 +table5.btree.repeat_data_pct=85 +table5.btree.split_pct=76 +table5.btree.value_max=604 +table5.btree.value_min=3 +table5.disk.checksum=on +table5.disk.firstfit=0 +table5.ops.pct.delete=1 +table5.ops.pct.insert=9 +table5.ops.pct.modify=8 +table5.ops.pct.read=18 +table5.ops.pct.write=64 +table5.ops.truncate=1 +table5.runs.mirror=0 +table5.runs.source=table +table5.runs.type=variable-length column-store -- cgit v1.2.1