summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/btree/row_modify.c
diff options
context:
space:
mode:
authorAlex Gorrod <alexander.gorrod@mongodb.com>2017-06-07 07:20:49 +1000
committerAlex Gorrod <alexander.gorrod@mongodb.com>2017-06-07 07:20:49 +1000
commit60341ff5b540ed35c8378910d92fe6c128f398e6 (patch)
tree989cb325f5ea6e335fda4852ae6cfca6a13d3b11 /src/third_party/wiredtiger/src/btree/row_modify.c
parenta85685ce5ed0e07107476e1f4098034452cf7d6a (diff)
downloadmongo-60341ff5b540ed35c8378910d92fe6c128f398e6.tar.gz
Import wiredtiger: 7aaeaaa054d1ac27a95c79984f7ca69ba739caae from branch mongodb-3.6
ref: 78109ca3fe..7aaeaaa054 for: 3.5.9 SERVER-28820 Recovery failed: WT_NOTFOUND: item not found SERVER-28835 Fix a memory leak in WiredTiger on error when creating thread group WT-2972 Add interface allowing partial updates to existing values WT-3041 Failure of test_perf01 on PPC WT-3063 Reserve records for read-modify-write WT-3076 Add a general-purpose epoch manager WT-3123 Thread group holding lock across thread join WT-3142 Add a workload generator application WT-3158 Fix structure layout on Windows. WT-3160 Improve eviction of internal pages from idle trees WT-3197 aarch64 CRC32C support fails to compile on non-linux ARM platforms WT-3219 Make the clang-analyzer job fail when lint is introduced WT-3222 Review and enhance log statistics WT-3245 Avoid hangs on shutdown when a utility thread encounters an error WT-3247 Test should exit instead of abort to avoid a core dump WT-3248 Performance degradation in workload with large overflow items WT-3253 txn07 test problem WT-3258 Improve visibility into thread wait time due to pages exceeding memory_page_max WT-3261 add a checkpoint epoch to avoid draining the eviction queue WT-3262 Schema operations shouldn't wait for cache WT-3263 Allow archive on restart/recovery if clean shutdown WT-3264 Permanent change to disable logging should eventually remove all logs WT-3265 Verify hits assertion in eviction when transiting handle to exclusive mode WT-3266 Thread group deadlock WT-3267 Upgrade copyright notices from 2016 to 2017. WT-3268 Failure to close cursor can get wiredtiger stuck in a cursor-close loop WT-3269 Miscellaneous cleanup changes WT-3271 Eviction tuning stuck in a loop WT-3275 stress test sanitizer failure WT-3278 log the row-store cursor key instead of page key WT-3281 stress test sanitizer failure WT-3282 Stuck in conn cache pool destroy join WT-3284 tree-walk restart bug WT-3287 review WiredTiger internal panic checks WT-3288 fix error codes for event_handler to be consistent in file operations WT-3292 review/cleanup full-barrier calls in WiredTiger WT-3293 Make internal symbols externally visible WT-3296 LAS table fixes/improvements WT-3297 support the gcc/clang -fvisibility=hidden flag WT-3300 Coverity 1374542: Dereference after null check WT-3302 Failure to create cache pool manager thread results in crash when destroying cache pool WT-3303 Deadlock during first access to lookaside table WT-3307 FI testing: segfault in python test test_bug013 when fault introduced reading turtle file WT-3312 encryption btree configuration test WT-3313 Replace calls to the deprecated LZ4_compress function WT-3314 clarify error handling WT-3327 Checkpoints can hang if time runs backward WT-3331 Test format aborted due to time rollback WT-3333 Make it possible to store 0 bytes into a 'u' format via Python WT-3334 static test suite's BaseDataSet class has 'u' value format bugs WT-3339 The CURSOR_UPDATE_API_CALL macro will dump core on a NULL btree handle WT-3342 Create a new WiredTiger 2.9.2 release WT-3343 WiredTiger database close can attempt unlock of a lock that's not held. WT-3345 Improve rwlock scaling WT-3348 Lint, Windows warnings. WT-3351 Recovery assertion failure: old_lognum < lognum WT-3354 Coverity issues 1375904-1375907 WT-3356 rwlock assertion failure on PPC
Diffstat (limited to 'src/third_party/wiredtiger/src/btree/row_modify.c')
-rw-r--r--src/third_party/wiredtiger/src/btree/row_modify.c62
1 files changed, 28 insertions, 34 deletions
diff --git a/src/third_party/wiredtiger/src/btree/row_modify.c b/src/third_party/wiredtiger/src/btree/row_modify.c
index b1a81ca3d9f..cab07341a1c 100644
--- a/src/third_party/wiredtiger/src/btree/row_modify.c
+++ b/src/third_party/wiredtiger/src/btree/row_modify.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2014-2016 MongoDB, Inc.
+ * Copyright (c) 2014-2017 MongoDB, Inc.
* Copyright (c) 2008-2014 WiredTiger, Inc.
* All rights reserved.
*
@@ -15,18 +15,13 @@
int
__wt_page_modify_alloc(WT_SESSION_IMPL *session, WT_PAGE *page)
{
- WT_CONNECTION_IMPL *conn;
+ WT_DECL_RET;
WT_PAGE_MODIFY *modify;
- conn = S2C(session);
-
WT_RET(__wt_calloc_one(session, &modify));
- /*
- * Select a spinlock for the page; let the barrier immediately below
- * keep things from racing too badly.
- */
- modify->page_lock = ++conn->page_lock_cnt % WT_PAGE_LOCKS;
+ /* Initialize the spinlock for the page. */
+ WT_ERR(__wt_spin_init(session, &modify->page_lock, "btree page"));
/*
* Multiple threads of control may be searching and deciding to modify
@@ -37,8 +32,8 @@ __wt_page_modify_alloc(WT_SESSION_IMPL *session, WT_PAGE *page)
if (__wt_atomic_cas_ptr(&page->modify, NULL, modify))
__wt_cache_page_inmem_incr(session, page, sizeof(*modify));
else
- __wt_free(session, modify);
- return (0);
+err: __wt_free(session, modify);
+ return (ret);
}
/*
@@ -47,7 +42,8 @@ __wt_page_modify_alloc(WT_SESSION_IMPL *session, WT_PAGE *page)
*/
int
__wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt,
- WT_ITEM *key, WT_ITEM *value, WT_UPDATE *upd_arg, bool is_remove)
+ const WT_ITEM *key, const WT_ITEM *value,
+ WT_UPDATE *upd_arg, u_int modify_type, bool exclusive)
{
WT_DECL_RET;
WT_INSERT *ins;
@@ -65,10 +61,6 @@ __wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt,
upd = upd_arg;
logged = false;
- /* This code expects a remove to have a NULL value. */
- if (is_remove)
- value = NULL;
-
/* If we don't yet have a modify structure, we'll need one. */
WT_RET(__wt_page_modify_init(session, page));
mod = page->modify;
@@ -99,8 +91,8 @@ __wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt,
session, old_upd = *upd_entry));
/* Allocate a WT_UPDATE structure and transaction ID. */
- WT_ERR(
- __wt_update_alloc(session, value, &upd, &upd_size));
+ WT_ERR(__wt_update_alloc(session,
+ value, &upd, &upd_size, modify_type));
WT_ERR(__wt_txn_modify(session, upd));
logged = true;
@@ -132,7 +124,7 @@ __wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt,
/* Serialize the update. */
WT_ERR(__wt_update_serial(
- session, page, upd_entry, &upd, upd_size));
+ session, page, upd_entry, &upd, upd_size, exclusive));
} else {
/*
* Allocate the insert array as necessary.
@@ -170,8 +162,8 @@ __wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt,
cbt->ins = ins;
if (upd_arg == NULL) {
- WT_ERR(
- __wt_update_alloc(session, value, &upd, &upd_size));
+ WT_ERR(__wt_update_alloc(session,
+ value, &upd, &upd_size, modify_type));
WT_ERR(__wt_txn_modify(session, upd));
logged = true;
@@ -207,10 +199,10 @@ __wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt,
/* Insert the WT_INSERT structure. */
WT_ERR(__wt_insert_serial(
session, page, cbt->ins_head, cbt->ins_stack,
- &ins, ins_size, skipdepth));
+ &ins, ins_size, skipdepth, exclusive));
}
- if (logged)
+ if (logged && modify_type != WT_UPDATE_RESERVED)
WT_ERR(__wt_txn_log_op(session, cbt));
if (0) {
@@ -235,7 +227,7 @@ err: /*
*/
int
__wt_row_insert_alloc(WT_SESSION_IMPL *session,
- WT_ITEM *key, u_int skipdepth, WT_INSERT **insp, size_t *ins_sizep)
+ const WT_ITEM *key, u_int skipdepth, WT_INSERT **insp, size_t *ins_sizep)
{
WT_INSERT *ins;
size_t ins_size;
@@ -263,11 +255,10 @@ __wt_row_insert_alloc(WT_SESSION_IMPL *session,
* Allocate a WT_UPDATE structure and associated value and fill it in.
*/
int
-__wt_update_alloc(
- WT_SESSION_IMPL *session, WT_ITEM *value, WT_UPDATE **updp, size_t *sizep)
+__wt_update_alloc(WT_SESSION_IMPL *session, const WT_ITEM *value,
+ WT_UPDATE **updp, size_t *sizep, u_int modify_type)
{
WT_UPDATE *upd;
- size_t size;
*updp = NULL;
@@ -275,15 +266,18 @@ __wt_update_alloc(
* Allocate the WT_UPDATE structure and room for the value, then copy
* the value into place.
*/
- size = value == NULL ? 0 : value->size;
- WT_RET(__wt_calloc(session, 1, sizeof(WT_UPDATE) + size, &upd));
- if (value == NULL)
- WT_UPDATE_DELETED_SET(upd);
+ if (modify_type == WT_UPDATE_DELETED ||
+ modify_type == WT_UPDATE_RESERVED)
+ WT_RET(__wt_calloc(session, 1, sizeof(WT_UPDATE), &upd));
else {
- upd->size = WT_STORE_SIZE(size);
- if (size != 0)
- memcpy(WT_UPDATE_DATA(upd), value->data, size);
+ WT_RET(__wt_calloc(
+ session, 1, sizeof(WT_UPDATE) + value->size, &upd));
+ if (value->size != 0) {
+ upd->size = WT_STORE_SIZE(value->size);
+ memcpy(WT_UPDATE_DATA(upd), value->data, value->size);
+ }
}
+ upd->type = (uint8_t)modify_type;
*updp = upd;
*sizep = WT_UPDATE_MEMSIZE(upd);