summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gorrod <alexg@wiredtiger.com>2014-10-27 11:04:17 +1100
committerAlex Gorrod <alexg@wiredtiger.com>2014-10-27 11:04:17 +1100
commitad7743846f5e9216400bef74a58c6d0cc1dd4570 (patch)
tree64cb4f31d1a390329f6410e32243ef4226c61173
parent8d810882480c8f50d342a5aa9ada8693d32d7d43 (diff)
downloadmongo-ad7743846f5e9216400bef74a58c6d0cc1dd4570.tar.gz
Add a new WT_SESSION::transaction_range_pin method.
Can be used by applications to identify sessions that are keeping transaction IDs pinned.
-rw-r--r--src/docs/upgrading.dox5
-rw-r--r--src/include/wiredtiger.in16
-rw-r--r--src/session/session_api.c27
3 files changed, 47 insertions, 1 deletions
diff --git a/src/docs/upgrading.dox b/src/docs/upgrading.dox
index d9346faa170..c3294e34bab 100644
--- a/src/docs/upgrading.dox
+++ b/src/docs/upgrading.dox
@@ -9,6 +9,11 @@ The \c WT_DEADLOCK error return has been deprecated in favor of ::WT_ROLLBACK
to clarify that WT_SESSION::rollback_transaction should be called; no program
changes are required.
</dd>
+<dt>Add a new WT_SESSION::transaction_range_pin method</dt>
+<dd>
+Add a new WT_SESSION::transaction_range_pin method that helps users identify
+when a session is keeping a transaction ID pinned for a long time.
+</dd>
</dl>
@section version_240 Upgrading to Version 2.4.0
diff --git a/src/include/wiredtiger.in b/src/include/wiredtiger.in
index c033ebc06e7..5b19d63c4a7 100644
--- a/src/include/wiredtiger.in
+++ b/src/include/wiredtiger.in
@@ -1359,6 +1359,22 @@ struct __wt_session {
*/
int __F(checkpoint)(WT_SESSION *session, const char *config);
+ /*!
+ * Return the transaction ID range pinned by the session handle.
+ *
+ * The ID range is approximate and is calculated based on the oldest
+ * ID needed for the active transaction in this session, compared
+ * to the newest transaction in the system.
+ *
+ * @snippet ex_all.c Transaction range pin
+ *
+ * @param session the session handle
+ * @param range the range of IDs pinned by this session. Zero if
+ * there is no active transaction.
+ * @errors
+ */
+ int __F(transaction_range_pin)(WT_SESSION* session, uint64_t *range);
+
/*! @} */
};
diff --git a/src/session/session_api.c b/src/session/session_api.c
index 092bcad3f73..3fb1d444d9d 100644
--- a/src/session/session_api.c
+++ b/src/session/session_api.c
@@ -772,6 +772,30 @@ err: API_END_RET(session, ret);
}
/*
+ * __session_transaction_range_pin --
+ * WT_SESSION->transaction_range_pin method.
+ */
+static int
+__session_transaction_range_pin(WT_SESSION *wt_session, uint64_t *prange)
+{
+ WT_SESSION_IMPL *session;
+ WT_TXN_STATE *txn_state;
+
+ session = (WT_SESSION_IMPL *)wt_session;
+
+ *prange = 0;
+ txn_state = WT_SESSION_TXN_STATE(session);
+ if (txn_state->snap_min == 0 && txn_state->id == 0)
+ return (0);
+
+ *prange = S2C(session)->txn_global.current -
+ WT_MIN(txn_state->snap_min, txn_state->id);
+
+ return (0);
+
+}
+
+/*
* __session_checkpoint --
* WT_SESSION->checkpoint method.
*/
@@ -916,7 +940,8 @@ __wt_open_session(WT_CONNECTION_IMPL *conn,
__session_begin_transaction,
__session_commit_transaction,
__session_rollback_transaction,
- __session_checkpoint
+ __session_checkpoint,
+ __session_transaction_range_pin
};
WT_DECL_RET;
WT_SESSION_IMPL *session, *session_ret;