summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2020-11-24 15:53:55 +1100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-11-24 05:12:33 +0000
commit5027e119ad67f5dc68b5263df9bcbda6b8801820 (patch)
treee3a441a5f9253912003f3f23b604669c32956817 /src
parent79be0f22b131489173d6d6aa068f0f90f97e338b (diff)
downloadmongo-5027e119ad67f5dc68b5263df9bcbda6b8801820.tar.gz
Import wiredtiger: 3e0f17b1697b1b010d9519387d4f11a84d94d972 from branch mongodb-5.0
ref: f5c56624e1..3e0f17b169 for: 4.9.0 WT-6934 Fix __wt_hs_upd_find wrongly returns WT_NOTFOUND
Diffstat (limited to 'src')
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/src/history/hs_cursor.c45
-rw-r--r--src/third_party/wiredtiger/src/include/txn_inline.h4
3 files changed, 30 insertions, 21 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index df0eeeee08c..e1b07e26b1b 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": "f5c56624e1367fa4dd105d43ffc244084e9069f9"
+ "commit": "3e0f17b1697b1b010d9519387d4f11a84d94d972"
}
diff --git a/src/third_party/wiredtiger/src/history/hs_cursor.c b/src/third_party/wiredtiger/src/history/hs_cursor.c
index 3923b8b2bdf..23fdd7b11e1 100644
--- a/src/third_party/wiredtiger/src/history/hs_cursor.c
+++ b/src/third_party/wiredtiger/src/history/hs_cursor.c
@@ -176,24 +176,24 @@ __wt_hs_find_upd(WT_SESSION_IMPL *session, WT_ITEM *key, const char *value_forma
WT_MODIFY_VECTOR modifies;
WT_TXN *txn;
WT_TXN_SHARED *txn_shared;
- WT_UPDATE *mod_upd, *upd;
+ WT_UPDATE *mod_upd;
wt_timestamp_t durable_timestamp, durable_timestamp_tmp, hs_start_ts, hs_start_ts_tmp;
wt_timestamp_t hs_stop_durable_ts, hs_stop_durable_ts_tmp, read_timestamp;
uint64_t hs_counter, hs_counter_tmp, upd_type_full;
uint32_t hs_btree_id;
uint8_t *p, recno_key_buf[WT_INTPACK64_MAXSIZE], upd_type;
int cmp;
- bool modify;
+ bool upd_found;
hs_cursor = NULL;
- mod_upd = upd = NULL;
+ mod_upd = NULL;
orig_hs_value_buf = NULL;
WT_CLEAR(hs_key);
__wt_modify_vector_init(session, &modifies);
txn = session->txn;
txn_shared = WT_SESSION_TXN_SHARED(session);
hs_btree_id = S2BT(session)->id;
- WT_NOT_READ(modify, false);
+ upd_found = false;
WT_STAT_CONN_INCR(session, cursor_search_hs);
WT_STAT_DATA_INCR(session, cursor_search_hs);
@@ -287,6 +287,8 @@ __wt_hs_find_upd(WT_SESSION_IMPL *session, WT_ITEM *key, const char *value_forma
/* We do not have tombstones in the history store anymore. */
WT_ASSERT(session, upd_type != WT_UPDATE_TOMBSTONE);
+ upd_found = true;
+
/*
* If the caller has signalled they don't need the value buffer, don't bother reconstructing a
* modify update or copying the contents into the value buffer.
@@ -299,7 +301,6 @@ __wt_hs_find_upd(WT_SESSION_IMPL *session, WT_ITEM *key, const char *value_forma
* together.
*/
if (upd_type == WT_UPDATE_MODIFY) {
- WT_NOT_READ(modify, true);
/* Store this so that we don't have to make a special case for the first modify. */
hs_stop_durable_ts_tmp = hs_stop_durable_ts;
@@ -321,7 +322,13 @@ __wt_hs_find_upd(WT_SESSION_IMPL *session, WT_ITEM *key, const char *value_forma
*/
WT_ERR_NOTFOUND_OK(__wt_hs_cursor_next(session, hs_cursor), true);
if (ret == WT_NOTFOUND) {
- /* Fallback to the onpage value as the base value. */
+ /*
+ * Fallback to the onpage value as the base value.
+ *
+ * Work around of clang analyzer complaining the value is never read as it is reset
+ * again by the following WT_ERR macro.
+ */
+ WT_NOT_READ(ret, 0);
orig_hs_value_buf = hs_value;
hs_value = on_disk_buf;
upd_type = WT_UPDATE_STANDARD;
@@ -380,7 +387,6 @@ __wt_hs_find_upd(WT_SESSION_IMPL *session, WT_ITEM *key, const char *value_forma
__wt_modify_vector_pop(&modifies, &mod_upd);
WT_ERR(__wt_modify_apply_item(session, value_format, hs_value, mod_upd->data));
__wt_free_update_list(session, &mod_upd);
- mod_upd = NULL;
}
WT_STAT_CONN_INCR(session, cache_hs_read_squash);
WT_STAT_DATA_INCR(session, cache_hs_read_squash);
@@ -405,28 +411,31 @@ err:
__wt_scr_free(session, &hs_value);
WT_ASSERT(session, hs_key.mem == NULL && hs_key.memsize == 0);
- WT_TRET(__wt_hs_cursor_close(session));
-
__wt_free_update_list(session, &mod_upd);
while (modifies.size > 0) {
- __wt_modify_vector_pop(&modifies, &upd);
- __wt_free_update_list(session, &upd);
+ __wt_modify_vector_pop(&modifies, &mod_upd);
+ __wt_free_update_list(session, &mod_upd);
}
__wt_modify_vector_free(&modifies);
if (ret == 0) {
- /* Couldn't find a record. */
- if (upd == NULL) {
- ret = WT_NOTFOUND;
- WT_STAT_CONN_INCR(session, cache_hs_read_miss);
- WT_STAT_DATA_INCR(session, cache_hs_read_miss);
- } else {
+ if (upd_found) {
WT_STAT_CONN_INCR(session, cache_hs_read);
WT_STAT_DATA_INCR(session, cache_hs_read);
+ } else {
+ upd_value->type = WT_UPDATE_INVALID;
+ WT_STAT_CONN_INCR(session, cache_hs_read_miss);
+ WT_STAT_DATA_INCR(session, cache_hs_read_miss);
}
}
- WT_ASSERT(session, upd != NULL || ret != 0);
+ WT_TRET(__wt_hs_cursor_close(session));
+
+ /* Mark the buffer as invalid if there is an error. */
+ if (ret != 0)
+ upd_value->type = WT_UPDATE_INVALID;
+
+ WT_ASSERT(session, ret != WT_NOTFOUND);
return (ret);
}
diff --git a/src/third_party/wiredtiger/src/include/txn_inline.h b/src/third_party/wiredtiger/src/include/txn_inline.h
index 0d75b177a58..b59606df928 100644
--- a/src/third_party/wiredtiger/src/include/txn_inline.h
+++ b/src/third_party/wiredtiger/src/include/txn_inline.h
@@ -993,8 +993,8 @@ retry:
/* If there's no visible update in the update chain or ondisk, check the history store file. */
if (F_ISSET(S2C(session), WT_CONN_HS_OPEN) && !F_ISSET(S2BT(session), WT_BTREE_HS))
- WT_RET_NOTFOUND_OK(__wt_hs_find_upd(session, key, cbt->iface.value_format, recno,
- cbt->upd_value, false, &cbt->upd_value->buf, &tw));
+ WT_RET(__wt_hs_find_upd(session, key, cbt->iface.value_format, recno, cbt->upd_value, false,
+ &cbt->upd_value->buf, &tw));
/*
* Retry if we race with prepared commit or rollback. If we race with prepared rollback, the