summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/btree/row_modify.c
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2021-08-16 14:53:17 +1000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-08-16 05:21:34 +0000
commite00b31ac8a5509ebca265178daa3a1d1e2ab3bb2 (patch)
treeef6a7224febfdc095e6f7251d605f3a373b7639b /src/third_party/wiredtiger/src/btree/row_modify.c
parent5a20195efb81fa18645498eac5a0865372b8a663 (diff)
downloadmongo-e00b31ac8a5509ebca265178daa3a1d1e2ab3bb2.tar.gz
Import wiredtiger: 4fed751669a4ca66b882f73a8e8d555174a4da66 from branch mongodb-master
ref: 8099896388..4fed751669 for: 5.1.0 WT-7928 VLCS checkpoint and additional test suite improvements
Diffstat (limited to 'src/third_party/wiredtiger/src/btree/row_modify.c')
-rw-r--r--src/third_party/wiredtiger/src/btree/row_modify.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/third_party/wiredtiger/src/btree/row_modify.c b/src/third_party/wiredtiger/src/btree/row_modify.c
index c96b963cb1f..779f5112c12 100644
--- a/src/third_party/wiredtiger/src/btree/row_modify.c
+++ b/src/third_party/wiredtiger/src/btree/row_modify.c
@@ -109,8 +109,8 @@ __wt_row_modify(WT_CURSOR_BTREE *cbt, const WT_ITEM *key, const WT_ITEM *value,
upd_entry = &cbt->ins->upd;
if (upd_arg == NULL) {
- /* Make sure the update can proceed. */
- WT_ERR(__wt_txn_update_check(session, cbt, old_upd = *upd_entry, &prev_upd_ts));
+ /* Make sure the modify can proceed. */
+ WT_ERR(__wt_txn_modify_check(session, cbt, old_upd = *upd_entry, &prev_upd_ts));
/* Allocate a WT_UPDATE structure and transaction ID. */
WT_ERR(__wt_upd_alloc(session, value, modify_type, &upd, &upd_size));
@@ -139,6 +139,7 @@ __wt_row_modify(WT_CURSOR_BTREE *cbt, const WT_ITEM *key, const WT_ITEM *value,
upd_arg->next == NULL) ||
(upd_arg->type == WT_UPDATE_TOMBSTONE && upd_arg->next != NULL &&
upd_arg->next->type == WT_UPDATE_STANDARD && upd_arg->next->next == NULL));
+
upd_size = __wt_update_list_memsize(upd);
/* If there are existing updates, append them after the new updates. */
@@ -182,7 +183,6 @@ __wt_row_modify(WT_CURSOR_BTREE *cbt, const WT_ITEM *key, const WT_ITEM *value,
* slot. That's hard, so we set a flag.
*/
WT_PAGE_ALLOC_AND_SWAP(session, page, mod->mod_row_insert, ins_headp, page->entries + 1);
-
ins_slot = F_ISSET(cbt, WT_CBT_SEARCH_SMALLEST) ? page->entries : cbt->slot;
ins_headp = &mod->mod_row_insert[ins_slot];
@@ -218,6 +218,7 @@ __wt_row_modify(WT_CURSOR_BTREE *cbt, const WT_ITEM *key, const WT_ITEM *value,
(upd_arg->type == WT_UPDATE_TOMBSTONE && upd_arg->next != NULL &&
upd_arg->next->type == WT_UPDATE_STANDARD && upd_arg->next->next == NULL) ||
(upd_arg->type == WT_UPDATE_STANDARD && upd_arg->next == NULL));
+
upd_size = __wt_update_list_memsize(upd);
}
@@ -250,8 +251,10 @@ __wt_row_modify(WT_CURSOR_BTREE *cbt, const WT_ITEM *key, const WT_ITEM *value,
inserted_to_update_chain = true;
+ /* If the update was successful, add it to the in-memory log. */
if (logged && modify_type != WT_UPDATE_RESERVE) {
WT_ERR(__wt_txn_log_op(session, cbt));
+
/*
* Set the key in the transaction operation to be used in case this transaction is prepared
* to retrieve the update corresponding to this operation.
@@ -261,15 +264,23 @@ __wt_row_modify(WT_CURSOR_BTREE *cbt, const WT_ITEM *key, const WT_ITEM *value,
if (0) {
err:
- /*
- * Remove the update from the current transaction, so we don't try to modify it on rollback.
- */
+ /* Remove the update from the current transaction, don't try to modify it on rollback. */
if (logged)
__wt_txn_unmodify(session);
+
+ /* Free any allocated insert list object. */
__wt_free(session, ins);
+
cbt->ins = NULL;
+
+ /* Discard any allocated update, unless we failed after linking it into page memory. */
if (upd_arg == NULL && !inserted_to_update_chain)
__wt_free(session, upd);
+
+ /*
+ * When prepending a list of updates to an update chain, we link them together; sever that
+ * link so our callers list doesn't point into page memory.
+ */
if (last_upd != NULL)
last_upd->next = NULL;
}