summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/btree/bt_ret.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/src/btree/bt_ret.c')
-rw-r--r--src/third_party/wiredtiger/src/btree/bt_ret.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/third_party/wiredtiger/src/btree/bt_ret.c b/src/third_party/wiredtiger/src/btree/bt_ret.c
index 120daed3935..49a2481062e 100644
--- a/src/third_party/wiredtiger/src/btree/bt_ret.c
+++ b/src/third_party/wiredtiger/src/btree/bt_ret.c
@@ -129,9 +129,17 @@ __value_return(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt)
}
/*
+ * When threads race modifying a record, we can end up with more than the usual
+ * maximum number of modifications in an update list. We'd prefer not to
+ * allocate memory in a return path, so add a few additional slots to the array
+ * we use to build up a list of modify records to apply.
+ */
+#define WT_MODIFY_ARRAY_SIZE (WT_MAX_MODIFY_UPDATE + 10)
+
+/*
* __value_return_upd --
* Change the cursor to reference an internal update structure return
- * value.
+ * value.
*/
static inline int
__value_return_upd(
@@ -139,7 +147,7 @@ __value_return_upd(
{
WT_CURSOR *cursor;
WT_DECL_RET;
- WT_UPDATE **listp, *list[WT_MAX_MODIFY_UPDATE];
+ WT_UPDATE **listp, *list[WT_MODIFY_ARRAY_SIZE];
u_int i;
size_t allocated_bytes;
@@ -178,12 +186,12 @@ __value_return_upd(
* avoid memory allocation in normal cases, but we have
* to handle the edge cases too.
*/
- if (i >= WT_MAX_MODIFY_UPDATE) {
- if (i == WT_MAX_MODIFY_UPDATE)
+ if (i >= WT_MODIFY_ARRAY_SIZE) {
+ if (i == WT_MODIFY_ARRAY_SIZE)
listp = NULL;
WT_ERR(__wt_realloc_def(
session, &allocated_bytes, i + 1, &listp));
- if (i == WT_MAX_MODIFY_UPDATE)
+ if (i == WT_MODIFY_ARRAY_SIZE)
memcpy(listp, list, sizeof(list));
}
listp[i++] = upd;