diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2016-07-29 16:33:39 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-29 16:33:39 +1000 |
commit | 8f3e5f31da8dbe2e388ae42afc602dd982808792 (patch) | |
tree | cf2aced7248fc01e739b0f4776e75ed80209cb14 | |
parent | 7c7b555004fcab8d2bbc8f0dec828bd760e61b2d (diff) | |
download | mongo-8f3e5f31da8dbe2e388ae42afc602dd982808792.tar.gz |
WT-2802 Copy values during commit before releasing snapshot. (#2917)
-rw-r--r-- | src/session/session_api.c | 5 | ||||
-rw-r--r-- | src/txn/txn.c | 18 |
2 files changed, 15 insertions, 8 deletions
diff --git a/src/session/session_api.c b/src/session/session_api.c index 253a5b7a147..b34f4fd5a73 100644 --- a/src/session/session_api.c +++ b/src/session/session_api.c @@ -66,6 +66,11 @@ __wt_session_copy_values(WT_SESSION_IMPL *session) TAILQ_FOREACH(cursor, &session->cursors, q) if (F_ISSET(cursor, WT_CURSTD_VALUE_INT)) { + /* We have to do this with a transaction ID pinned. */ + WT_ASSERT(session, + WT_SESSION_TXN_STATE(session)->snap_min != + WT_TXN_NONE); + F_CLR(cursor, WT_CURSTD_VALUE_INT); WT_RET(__wt_buf_set(session, &cursor->value, cursor->value.data, cursor->value.size)); diff --git a/src/txn/txn.c b/src/txn/txn.c index 31d9aef4cbc..d6d5760ea15 100644 --- a/src/txn/txn.c +++ b/src/txn/txn.c @@ -550,6 +550,16 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[]) WT_TRET(txn->notify->notify(txn->notify, (WT_SESSION *)session, txn->id, 1)); + /* + * We are about to release the snapshot: copy values into any + * positioned cursors so they don't point to updates that could be + * freed once we don't have a snapshot. + */ + if (session->ncursors > 0) { + WT_DIAGNOSTIC_YIELD; + WT_RET(__wt_session_copy_values(session)); + } + /* If we are logging, write a commit log record. */ if (ret == 0 && txn->mod_count > 0 && FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED) && @@ -579,14 +589,6 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[]) __wt_txn_op_free(session, op); txn->mod_count = 0; - /* - * We are about to release the snapshot: copy values into any - * positioned cursors so they don't point to updates that could be - * freed once we don't have a transaction ID pinned. - */ - if (session->ncursors > 0) - WT_RET(__wt_session_copy_values(session)); - __wt_txn_release(session); return (0); } |