diff options
author | Luke Chen <luke.chen@mongodb.com> | 2021-06-01 19:21:18 +1000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-06-01 09:41:02 +0000 |
commit | b87ab36e559d1df441e7e8cc0956f83aa6f05cc5 (patch) | |
tree | a08a05fac93c9c253e6b1e79eb6804b611d3d302 /src/third_party | |
parent | b32f247f19ee5dfe870880438a0bb8e89aceab5e (diff) | |
download | mongo-b87ab36e559d1df441e7e8cc0956f83aa6f05cc5.tar.gz |
Import wiredtiger: cf86c311b3df45e388de49a0d4f8624953e34f76 from branch mongodb-5.0
ref: 4923eb3586..cf86c311b3
for: 5.1.0
WT-7595 Add flag to history store cursor to track whether underlying table insertion was successful
Diffstat (limited to 'src/third_party')
-rw-r--r-- | src/third_party/wiredtiger/import.data | 2 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/cursor/cur_hs.c | 37 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/history/hs_rec.c | 30 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/include/cursor.h | 2 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/include/extern.h | 3 |
5 files changed, 65 insertions, 9 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data index adac3168662..f1cc4cf8d5f 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-5.0", - "commit": "4923eb3586c39806c74c4d53f7ff8e445984ead3" + "commit": "cf86c311b3df45e388de49a0d4f8624953e34f76" } diff --git a/src/third_party/wiredtiger/src/cursor/cur_hs.c b/src/third_party/wiredtiger/src/cursor/cur_hs.c index 2c01dcc04d6..b51ab765888 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_hs.c +++ b/src/third_party/wiredtiger/src/cursor/cur_hs.c @@ -883,6 +883,12 @@ retry: goto retry; WT_ERR(ret); + /* + * Mark the insert as successful. Even if one of the calls below fails, some callers will still + * need to know whether the actual insert went through or not. + */ + hs_cursor->insert_success = true; + #ifdef HAVE_DIAGNOSTIC /* Do a search again and call next to check the key order. */ WT_WITH_PAGE_INDEX(session, ret = __wt_hs_row_search(cbt, &file_cursor->key, true)); @@ -1098,3 +1104,34 @@ err: } return (ret); } + +/* + * __wt_curhs_clear_insert_success -- + * Clear the insertion flag for the history store cursor. We should call this prior to using the + * WT_CURSOR->insert method. + */ +void +__wt_curhs_clear_insert_success(WT_CURSOR *cursor) +{ + WT_CURSOR_HS *hs_cursor; + + hs_cursor = (WT_CURSOR_HS *)cursor; + hs_cursor->insert_success = false; +} + +/* + * __wt_curhs_check_insert_success -- + * Check whether the insertion flag for the history store cursor is set or not. This signals + * whether or not the last WT_CURSOR->insert call successfully inserted the history store + * record. This is distinctly different from the return value of WT_CURSOR->insert since the + * return value could be non-zero due to cursor operations AFTER the actual history store + * insertion. + */ +bool +__wt_curhs_check_insert_success(WT_CURSOR *cursor) +{ + WT_CURSOR_HS *hs_cursor; + + hs_cursor = (WT_CURSOR_HS *)cursor; + return (hs_cursor->insert_success); +} diff --git a/src/third_party/wiredtiger/src/history/hs_rec.c b/src/third_party/wiredtiger/src/history/hs_rec.c index 15f856cc928..43fc87989e4 100644 --- a/src/third_party/wiredtiger/src/history/hs_rec.c +++ b/src/third_party/wiredtiger/src/history/hs_rec.c @@ -609,6 +609,9 @@ __wt_hs_insert_updates( WT_ASSERT(session, __txn_visible_id(session, upd->txnid)); #endif + /* Clear out the insert success flag prior to our insert attempt. */ + __wt_curhs_clear_insert_success(hs_cursor); + /* * Calculate reverse modify and clear the history store records with timestamps when * inserting the first update. Always write on-disk data store updates to the history @@ -628,20 +631,31 @@ __wt_hs_insert_updates( __wt_calc_modify(session, prev_full_value, full_value, prev_full_value->size / 10, entries, &nentries) == 0) { WT_ERR(__wt_modify_pack(hs_cursor, entries, nentries, &modify_value)); - WT_ERR(__hs_insert_record( - session, hs_cursor, btree, key, WT_UPDATE_MODIFY, modify_value, &tw)); + ret = __hs_insert_record( + session, hs_cursor, btree, key, WT_UPDATE_MODIFY, modify_value, &tw); __wt_scr_free(session, &modify_value); ++modify_cnt; } else { modify_cnt = 0; - WT_ERR(__hs_insert_record( - session, hs_cursor, btree, key, WT_UPDATE_STANDARD, full_value, &tw)); + ret = __hs_insert_record( + session, hs_cursor, btree, key, WT_UPDATE_STANDARD, full_value, &tw); + } + + /* + * Flag the update as now in the history store. + * + * Ensure that we don't use `WT_ERR` for the insertions above. Insertion can return + * non-zero even when the update made it into the history store. In those cases we need + * to write the flag to mark the update as having been written to the history store + * before jumping to the error handling. + */ + if (__wt_curhs_check_insert_success(hs_cursor)) { + F_SET(upd, WT_UPDATE_HS); + if (tombstone != NULL) + F_SET(tombstone, WT_UPDATE_HS); } + WT_ERR(ret); - /* Flag the update as now in the history store. */ - F_SET(upd, WT_UPDATE_HS); - if (tombstone != NULL) - F_SET(tombstone, WT_UPDATE_HS); hs_inserted = true; ++insert_cnt; if (squashed) { diff --git a/src/third_party/wiredtiger/src/include/cursor.h b/src/third_party/wiredtiger/src/include/cursor.h index 82023a1573e..ffe960de07f 100644 --- a/src/third_party/wiredtiger/src/include/cursor.h +++ b/src/third_party/wiredtiger/src/include/cursor.h @@ -290,6 +290,8 @@ struct __wt_cursor_hs { uint32_t btree_id; WT_ITEM *datastore_key; + bool insert_success; + /* AUTOMATIC FLAG VALUE GENERATION START */ #define WT_HS_CUR_BTREE_ID_SET 0x1u #define WT_HS_CUR_COUNTER_SET 0x2u diff --git a/src/third_party/wiredtiger/src/include/extern.h b/src/third_party/wiredtiger/src/include/extern.h index 5080fbc3952..0cdc923d66f 100644 --- a/src/third_party/wiredtiger/src/include/extern.h +++ b/src/third_party/wiredtiger/src/include/extern.h @@ -14,6 +14,8 @@ extern bool __wt_cell_type_check(uint8_t cell_type, uint8_t dsk_type) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern bool __wt_checksum_alt_match(const void *chunk, size_t len, uint32_t v) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern bool __wt_curhs_check_insert_success(WT_CURSOR *cursor) + WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern bool __wt_delete_page_skip(WT_SESSION_IMPL *session, WT_REF *ref, bool visible_all) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern bool __wt_evict_thread_chk(WT_SESSION_IMPL *session) @@ -1690,6 +1692,7 @@ extern void __wt_conn_config_discard(WT_SESSION_IMPL *session); extern void __wt_conn_foc_discard(WT_SESSION_IMPL *session); extern void __wt_conn_stat_init(WT_SESSION_IMPL *session); extern void __wt_connection_destroy(WT_CONNECTION_IMPL *conn); +extern void __wt_curhs_clear_insert_success(WT_CURSOR *cursor); extern void __wt_cursor_close(WT_CURSOR *cursor); extern void __wt_cursor_get_hash( WT_SESSION_IMPL *session, const char *uri, WT_CURSOR *to_dup, uint64_t *hash_value); |