diff options
Diffstat (limited to 'src/third_party/wiredtiger/src/lsm/lsm_cursor.c')
-rw-r--r-- | src/third_party/wiredtiger/src/lsm/lsm_cursor.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/third_party/wiredtiger/src/lsm/lsm_cursor.c b/src/third_party/wiredtiger/src/lsm/lsm_cursor.c index 4d9f6f92832..5dd3122d41c 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_cursor.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_cursor.c @@ -265,6 +265,12 @@ open: WT_WITH_SCHEMA_LOCK(session, } if (!F_ISSET(clsm, WT_CLSM_ACTIVE)) { + /* + * Opening this LSM cursor has opened a number of btree + * cursors, ensure other code doesn't think this is the first + * cursor in a session. + */ + ++session->ncursors; WT_RET(__cursor_enter(session)); F_SET(clsm, WT_CLSM_ACTIVE); } @@ -284,6 +290,7 @@ __clsm_leave(WT_CURSOR_LSM *clsm) session = (WT_SESSION_IMPL *)clsm->iface.session; if (F_ISSET(clsm, WT_CLSM_ACTIVE)) { + --session->ncursors; __cursor_leave(session); F_CLR(clsm, WT_CLSM_ACTIVE); } @@ -365,12 +372,17 @@ __clsm_deleted_decode(WT_CURSOR_LSM *clsm, WT_ITEM *value) * Close any btree cursors that are not needed. */ static int -__clsm_close_cursors(WT_CURSOR_LSM *clsm, u_int start, u_int end) +__clsm_close_cursors( + WT_SESSION_IMPL *session, WT_CURSOR_LSM *clsm, u_int start, u_int end) { WT_BLOOM *bloom; WT_CURSOR *c; u_int i; + __wt_verbose(session, WT_VERB_LSM, + "LSM closing cursor session(%p):clsm(%p), start: %u, end: %u", + (void *)session, (void *)clsm, start, end); + if (clsm->chunks == NULL || clsm->nchunks == 0) return (0); @@ -609,7 +621,7 @@ retry: if (F_ISSET(clsm, WT_CLSM_MERGE)) { saved_gen = lsm_tree->dsk_gen; locked = false; __wt_lsm_tree_readunlock(session, lsm_tree); - WT_ERR(__clsm_close_cursors( + WT_ERR(__clsm_close_cursors(session, clsm, close_range_start, close_range_end)); __wt_lsm_tree_readlock(session, lsm_tree); locked = true; @@ -626,6 +638,10 @@ retry: if (F_ISSET(clsm, WT_CLSM_MERGE)) { clsm->nchunks = nchunks; /* Open the cursors for chunks that have changed. */ + __wt_verbose(session, WT_VERB_LSM, + "LSM opening cursor session(%p):clsm(%p)%s, chunks: %u, good: %u", + (void *)session, (void *)clsm, + update ? ", update" : "", nchunks, ngood); for (i = ngood; i != nchunks; i++) { chunk = lsm_tree->chunk[i + start_chunk]; /* Copy the maximum transaction ID. */ @@ -1736,7 +1752,9 @@ __wt_clsm_close(WT_CURSOR *cursor) */ clsm = (WT_CURSOR_LSM *)cursor; CURSOR_API_CALL_PREPARE_ALLOWED(cursor, session, close, NULL); - WT_TRET(__clsm_close_cursors(clsm, 0, clsm->nchunks)); +err: + + WT_TRET(__clsm_close_cursors(session, clsm, 0, clsm->nchunks)); __clsm_free_chunks(session, clsm); /* In case we were somehow left positioned, clear that. */ @@ -1744,9 +1762,9 @@ __wt_clsm_close(WT_CURSOR *cursor) if (clsm->lsm_tree != NULL) __wt_lsm_tree_release(session, clsm->lsm_tree); - WT_TRET(__wt_cursor_close(cursor)); + __wt_cursor_close(cursor); -err: API_END_RET(session, ret); + API_END_RET(session, ret); } /* @@ -1821,10 +1839,9 @@ __wt_clsm_open(WT_SESSION_IMPL *session, WT_ASSERT(session, !bulk || lsm_tree->excl_session != NULL); WT_ERR(__wt_calloc_one(session, &clsm)); - - cursor = &clsm->iface; + cursor = (WT_CURSOR *)clsm; *cursor = iface; - cursor->session = &session->iface; + cursor->session = (WT_SESSION *)session; WT_ERR(__wt_strdup(session, lsm_tree->name, &cursor->uri)); cursor->key_format = lsm_tree->key_format; cursor->value_format = lsm_tree->value_format; |