diff options
author | Alex Gorrod <alexander.gorrod@mongodb.com> | 2017-02-17 11:22:16 +1100 |
---|---|---|
committer | Alex Gorrod <alexander.gorrod@mongodb.com> | 2017-02-17 11:22:16 +1100 |
commit | 9c8c662a9213b16ae206f495c875594f5f0454f0 (patch) | |
tree | 7c9e527eec0fc5d99119ed5bf080660e96d20405 /src/third_party/wiredtiger/src/os_posix | |
parent | 22ec4be075233d425f21349854b5ceac6baa5289 (diff) | |
download | mongo-9c8c662a9213b16ae206f495c875594f5f0454f0.tar.gz |
Import wiredtiger: e1bcc30da91eedd0b17cebb725cc7e607ffa2340 from branch mongodb-3.6
ref: 48a3cbc17f..e1bcc30da9
for: 3.5.4
WT-2790 Fix a text case false positive in test_sweep01
WT-2909 Create automatable test verifying checkpoint integrity after errors
WT-3088 bug: Don't evict a page with refs visible to readers after a split
WT-3097 Race on reconfigure or shutdown can lead to waiting for statistics log server
WT-3111 util_create() doesnt free memory assigned to "uri"
WT-3113 Add a verbose mode to dump the cache when eviction is stuck
WT-3115 Change the dhandle lock to a read/write lock
WT-3120 Fix ordering problem in connection_close for filesystem loaded in an extension
WT-3135 search_near() for index with custom collator
WT-3137 Hang in __log_slot_join/__log_slot_switch_internal
WT-3139 Enhance wtperf to support periodic table scans
WT-3144 bug fix: random cursor returns not-found when descending to an empty page
WT-3148 Improve eviction efficiency with many small trees
WT-3149 Change eviction to start new walks from a random place in the tree
WT-3150 Reduce impact of checkpoints on eviction server
WT-3152 Convert table lock from a spinlock to a read write lock
WT-3156 Assertion in log_write fires after write failure
WT-3157 checkpoint/transaction integrity issue when writes fail.
WT-3159 Incorrect key for index containing multiple variable sized entries
WT-3161 checkpoint hang after write failure injection.
WT-3164 Ensure all relevant btree fields are reset on checkpoint error
WT-3170 Clear the eviction walk point while populating from a tree
WT-3173 Add runtime detection for s390x CRC32 hardware support
WT-3174 Coverity/lint cleanup
WT-3175 New hang in internal page split
WT-3179 Test bug: clang sanitizer failure in fail_fs
WT-3180 Fault injection tests should only run as "long" tests and should not create core files
WT-3184 Problem duplicating index cursor with custom collator
WT-3186 Fix error path and panic detection in logging loops
Diffstat (limited to 'src/third_party/wiredtiger/src/os_posix')
-rw-r--r-- | src/third_party/wiredtiger/src/os_posix/os_mtx_cond.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/third_party/wiredtiger/src/os_posix/os_mtx_cond.c b/src/third_party/wiredtiger/src/os_posix/os_mtx_cond.c index be8b1abda31..a5ee78f9e3e 100644 --- a/src/third_party/wiredtiger/src/os_posix/os_mtx_cond.c +++ b/src/third_party/wiredtiger/src/os_posix/os_mtx_cond.c @@ -13,8 +13,7 @@ * Allocate and initialize a condition variable. */ int -__wt_cond_alloc(WT_SESSION_IMPL *session, - const char *name, bool is_signalled, WT_CONDVAR **condp) +__wt_cond_alloc(WT_SESSION_IMPL *session, const char *name, WT_CONDVAR **condp) { WT_CONDVAR *cond; WT_DECL_RET; @@ -27,7 +26,7 @@ __wt_cond_alloc(WT_SESSION_IMPL *session, WT_ERR(pthread_cond_init(&cond->cond, NULL)); cond->name = name; - cond->waiters = is_signalled ? -1 : 0; + cond->waiters = 0; *condp = cond; return (0); @@ -42,8 +41,8 @@ err: __wt_free(session, cond); * out period expires, let the caller know. */ void -__wt_cond_wait_signal( - WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs, bool *signalled) +__wt_cond_wait_signal(WT_SESSION_IMPL *session, WT_CONDVAR *cond, + uint64_t usecs, bool (*run_func)(WT_SESSION_IMPL *), bool *signalled) { struct timespec ts; WT_DECL_RET; @@ -62,6 +61,23 @@ __wt_cond_wait_signal( WT_ERR(pthread_mutex_lock(&cond->mtx)); locked = true; + /* + * It's possible to race with threads waking us up. That's not a problem + * if there are multiple wakeups because the next wakeup will get us, or + * if we're only pausing for a short period. It's a problem if there's + * only a single wakeup, our waker is likely waiting for us to exit. + * After acquiring the mutex (so we're guaranteed to be awakened by any + * future wakeup call), optionally check if we're OK to keep running. + * This won't ensure our caller won't just loop and call us again, but + * at least it's not our fault. + * + * Assert we're not waiting longer than a second if not checking the + * run status. + */ + WT_ASSERT(session, run_func != NULL || usecs <= WT_MILLION); + if (run_func != NULL && !run_func(session)) + goto skipping; + if (usecs > 0) { __wt_epoch(session, &ts); ts.tv_sec += (time_t) @@ -81,7 +97,7 @@ __wt_cond_wait_signal( ret == ETIME || #endif ret == ETIMEDOUT) { - *signalled = false; +skipping: *signalled = false; ret = 0; } |