diff options
Diffstat (limited to 'src/third_party/wiredtiger/src/support/generation.c')
-rw-r--r-- | src/third_party/wiredtiger/src/support/generation.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/third_party/wiredtiger/src/support/generation.c b/src/third_party/wiredtiger/src/support/generation.c index e3a60621b5c..0c35bd96433 100644 --- a/src/third_party/wiredtiger/src/support/generation.c +++ b/src/third_party/wiredtiger/src/support/generation.c @@ -73,10 +73,14 @@ __wt_gen(WT_SESSION_IMPL *session, int which) * __wt_gen_next -- * Switch the resource to its next generation. */ -uint64_t -__wt_gen_next(WT_SESSION_IMPL *session, int which) +void +__wt_gen_next(WT_SESSION_IMPL *session, int which, uint64_t *genp) { - return (__wt_atomic_addv64(&S2C(session)->generations[which], 1)); + uint64_t gen; + + gen = __wt_atomic_addv64(&S2C(session)->generations[which], 1); + if (genp != NULL) + *genp = gen; } /* @@ -162,8 +166,8 @@ __wt_gen_drain(WT_SESSION_IMPL *session, int which, uint64_t generation) WT_IGNORE_RET(__wt_msg(session, "%s generation drain waited %u minutes", __gen_name(which), minutes)); ++minutes; + WT_ASSERT(session, minutes < 4); } - WT_ASSERT(session, stop - start < 3 * WT_MINUTE); } } } @@ -190,8 +194,7 @@ __gen_oldest(WT_SESSION_IMPL *session, int which) * the sessions that could have been active when we started our check. */ WT_ORDERED_READ(session_cnt, conn->session_cnt); - for (oldest = conn->generations[which] + 1, s = conn->sessions, i = 0; i < session_cnt; - ++s, ++i) { + for (oldest = conn->generations[which], s = conn->sessions, i = 0; i < session_cnt; ++s, ++i) { if (!s->active) continue; @@ -237,6 +240,12 @@ __wt_gen_active(WT_SESSION_IMPL *session, int which, uint64_t generation) return (true); } +#ifdef HAVE_DIAGNOSTIC + { + uint64_t oldest = __gen_oldest(session, which); + WT_ASSERT(session, generation < oldest); + } +#endif return (false); } @@ -262,6 +271,8 @@ __wt_session_gen_enter(WT_SESSION_IMPL *session, int which) * protected by a generation running outside one. */ WT_ASSERT(session, session->generations[which] == 0); + WT_ASSERT(session, session->active); + WT_ASSERT(session, session->id < S2C(session)->session_cnt); /* * Assign the thread's resource generation and publish it, ensuring threads waiting on a @@ -282,6 +293,9 @@ __wt_session_gen_enter(WT_SESSION_IMPL *session, int which) void __wt_session_gen_leave(WT_SESSION_IMPL *session, int which) { + WT_ASSERT(session, session->active); + WT_ASSERT(session, session->id < S2C(session)->session_cnt); + /* Ensure writes made by this thread are visible. */ WT_PUBLISH(session->generations[which], 0); |