From dddca656066f10e71cc7a7485698e0ce0798eb12 Mon Sep 17 00:00:00 2001 From: Michael Cahill Date: Fri, 29 Jul 2016 16:33:39 +1000 Subject: WT-2802 Copy values during commit before releasing snapshot. (#2917) (cherry picked from commit 8f3e5f31da8dbe2e388ae42afc602dd982808792) --- src/session/session_api.c | 5 +++++ 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 77d1dc74c84..85d0fb1151c 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); } -- cgit v1.2.1