summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2022-09-26 12:50:12 +1000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-09-26 03:36:41 +0000
commitd6ee2d1a254b3a4a7caef89b89d7d4acd3a5d67b (patch)
tree171422ee48f466a7a609dcb9a95f2bac80c8d868
parent9992580ec57ad678e59a21a564389ba66e5594e9 (diff)
downloadmongo-d6ee2d1a254b3a4a7caef89b89d7d4acd3a5d67b.tar.gz
Import wiredtiger: b4070294cdfd2df5e6a3a7f355f6c9109e094048 from branch mongodb-master
ref: 06926a917a..b4070294cd for: 6.2.0-rc0 WT-9670 Add early statistics access via a general event handler. (#8299)
-rwxr-xr-xsrc/third_party/wiredtiger/dist/s_void2
-rw-r--r--src/third_party/wiredtiger/examples/c/ex_event_handler.c1
-rw-r--r--src/third_party/wiredtiger/examples/c/ex_verbose.c1
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/src/conn/conn_api.c34
-rw-r--r--src/third_party/wiredtiger/src/include/connection.h50
-rw-r--r--src/third_party/wiredtiger/src/include/wiredtiger.in24
-rw-r--r--src/third_party/wiredtiger/src/session/session_api.c263
-rw-r--r--src/third_party/wiredtiger/src/support/err.c18
-rw-r--r--src/third_party/wiredtiger/src/utilities/util_verbose.c4
-rw-r--r--src/third_party/wiredtiger/test/checkpoint/test_checkpoint.c4
-rw-r--r--src/third_party/wiredtiger/test/csuite/schema_abort/main.c3
-rw-r--r--src/third_party/wiredtiger/test/csuite/scope/main.c2
-rw-r--r--src/third_party/wiredtiger/test/csuite/timestamp_abort/main.c110
-rw-r--r--src/third_party/wiredtiger/test/csuite/wt2719_reconfig/main.c2
-rw-r--r--src/third_party/wiredtiger/test/csuite/wt2909_checkpoint_integrity/main.c3
-rw-r--r--src/third_party/wiredtiger/test/csuite/wt3363_checkpoint_op_races/main.c2
-rw-r--r--src/third_party/wiredtiger/test/csuite/wt4105_large_doc_small_upd/main.c2
-rw-r--r--src/third_party/wiredtiger/test/csuite/wt4156_metadata_salvage/main.c2
-rw-r--r--src/third_party/wiredtiger/test/csuite/wt4803_history_store_abort/main.c2
-rw-r--r--src/third_party/wiredtiger/test/csuite/wt8057_compact_stress/main.c3
-rw-r--r--src/third_party/wiredtiger/test/cursor_order/cursor_order.c4
-rw-r--r--src/third_party/wiredtiger/test/fops/t.c4
-rw-r--r--src/third_party/wiredtiger/test/format/wts.c4
-rw-r--r--src/third_party/wiredtiger/test/thread/t.c4
25 files changed, 494 insertions, 56 deletions
diff --git a/src/third_party/wiredtiger/dist/s_void b/src/third_party/wiredtiger/dist/s_void
index 412606bea65..48690d10fc6 100755
--- a/src/third_party/wiredtiger/dist/s_void
+++ b/src/third_party/wiredtiger/dist/s_void
@@ -40,6 +40,7 @@ func_ok()
-e '/int __cursor_fix_implicit$/d' \
-e '/int __delete_redo_window_cleanup_skip$/d' \
-e '/int __handle_close_default$/d' \
+ -e '/int __handle_general_default$/d' \
-e '/int __handle_progress_default$/d' \
-e '/int __im_file_close$/d' \
-e '/int __im_file_lock$/d' \
@@ -108,6 +109,7 @@ func_ok()
-e '/int fail_fs_exist$/d' \
-e '/int fail_fs_simulate_fail$/d' \
-e '/int fail_fs_terminate$/d' \
+ -e '/int handle_general$/d' \
-e '/int handle_message$/d' \
-e '/int handle_progress$/d' \
-e '/int index_compare_S$/d' \
diff --git a/src/third_party/wiredtiger/examples/c/ex_event_handler.c b/src/third_party/wiredtiger/examples/c/ex_event_handler.c
index 002eda961ff..bbe969b6196 100644
--- a/src/third_party/wiredtiger/examples/c/ex_event_handler.c
+++ b/src/third_party/wiredtiger/examples/c/ex_event_handler.c
@@ -99,6 +99,7 @@ config_event_handler(void)
/* Set handlers to NULL to use the default handler. */
event_handler.h.handle_progress = NULL;
event_handler.h.handle_close = NULL;
+ event_handler.h.handle_general = NULL;
event_handler.app_id = "example_event_handler";
error_check(wiredtiger_open(home, (WT_EVENT_HANDLER *)&event_handler, "create", &conn));
diff --git a/src/third_party/wiredtiger/examples/c/ex_verbose.c b/src/third_party/wiredtiger/examples/c/ex_verbose.c
index b5e628a7cf2..57a0c4b3cb6 100644
--- a/src/third_party/wiredtiger/examples/c/ex_verbose.c
+++ b/src/third_party/wiredtiger/examples/c/ex_verbose.c
@@ -61,6 +61,7 @@ config_verbose(void)
event_handler.handle_error = NULL;
event_handler.handle_progress = NULL;
event_handler.handle_close = NULL;
+ event_handler.handle_general = NULL;
/*! [Configure verbose_messaging] */
error_check(wiredtiger_open(
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index 042ed27ae7a..a331fd69623 100644
--- a/src/third_party/wiredtiger/import.data
+++ b/src/third_party/wiredtiger/import.data
@@ -2,5 +2,5 @@
"vendor": "wiredtiger",
"github": "wiredtiger/wiredtiger.git",
"branch": "mongodb-master",
- "commit": "06926a917a9c92cc7407612d0638397a51cc8e44"
+ "commit": "b4070294cdfd2df5e6a3a7f355f6c9109e094048"
}
diff --git a/src/third_party/wiredtiger/src/conn/conn_api.c b/src/third_party/wiredtiger/src/conn/conn_api.c
index eb43ab1ab82..9f2f68b099e 100644
--- a/src/third_party/wiredtiger/src/conn/conn_api.c
+++ b/src/third_party/wiredtiger/src/conn/conn_api.c
@@ -1115,6 +1115,12 @@ err:
conn->cache->eviction_dirty_trigger = 1.0;
conn->cache->eviction_dirty_target = 0.1;
+ if (conn->default_session->event_handler->handle_general != NULL &&
+ F_ISSET(conn, WT_CONN_MINIMAL | WT_CONN_READY))
+ WT_TRET(conn->default_session->event_handler->handle_general(
+ conn->default_session->event_handler, &conn->iface, NULL, WT_EVENT_CONN_CLOSE));
+ F_CLR(conn, WT_CONN_MINIMAL | WT_CONN_READY);
+
/*
* Rollback all running transactions. We do this as a separate pass because an active
* transaction in one session could cause trouble when closing a file, even if that session
@@ -1139,6 +1145,15 @@ err:
WT_TRET(__wt_session_close_internal(s));
}
+ /*
+ * Set MINIMAL again and call the event handler so that statistics can monitor any end of
+ * connection activity (like the final checkpoint).
+ */
+ F_SET(conn, WT_CONN_MINIMAL);
+ if (conn->default_session->event_handler->handle_general != NULL)
+ WT_TRET(conn->default_session->event_handler->handle_general(
+ conn->default_session->event_handler, wt_conn, NULL, WT_EVENT_CONN_READY));
+
/* Wait for in-flight operations to complete. */
WT_TRET(__wt_txn_activity_drain(session));
@@ -1168,6 +1183,12 @@ err:
/* Perform a final checkpoint and shut down the global transaction state. */
WT_TRET(__wt_txn_global_shutdown(session, cfg));
+ /* We know WT_CONN_MINIMAL is set a few lines above no need to check again. */
+ if (conn->default_session->event_handler->handle_general != NULL)
+ WT_TRET(conn->default_session->event_handler->handle_general(
+ conn->default_session->event_handler, wt_conn, NULL, WT_EVENT_CONN_CLOSE));
+ F_CLR(conn, WT_CONN_MINIMAL);
+
/*
* See if close should wait for tiered storage to finish any flushing after the final
* checkpoint.
@@ -3019,6 +3040,11 @@ wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler, const char *c
*/
WT_ERR(__wt_backup_open(session));
+ F_SET(conn, WT_CONN_MINIMAL);
+ if (event_handler != NULL && event_handler->handle_general != NULL)
+ WT_ERR(
+ event_handler->handle_general(event_handler, &conn->iface, NULL, WT_EVENT_CONN_READY));
+
/* Start the worker threads and run recovery. */
WT_ERR(__wt_connection_workers(session, cfg));
@@ -3036,6 +3062,8 @@ wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler, const char *c
F_SET(session, WT_SESSION_NO_DATA_HANDLES);
WT_STATIC_ASSERT(offsetof(WT_CONNECTION_IMPL, iface) == 0);
+ F_SET(conn, WT_CONN_READY);
+ F_CLR(conn, WT_CONN_MINIMAL);
*connectionp = &conn->iface;
err:
@@ -3064,6 +3092,12 @@ err:
__wt_free(session, conn->partial_backup_remove_ids);
if (ret != 0) {
+ if (conn->default_session->event_handler->handle_general != NULL &&
+ F_ISSET(conn, WT_CONN_MINIMAL | WT_CONN_READY))
+ WT_TRET(conn->default_session->event_handler->handle_general(
+ conn->default_session->event_handler, &conn->iface, NULL, WT_EVENT_CONN_CLOSE));
+ F_CLR(conn, WT_CONN_MINIMAL | WT_CONN_READY);
+
/*
* Set panic if we're returning the run recovery error or if recovery did not complete so
* that we don't try to checkpoint data handles. We need an explicit flag instead of
diff --git a/src/third_party/wiredtiger/src/include/connection.h b/src/third_party/wiredtiger/src/include/connection.h
index 18d5ddd6e73..5a8408fb474 100644
--- a/src/third_party/wiredtiger/src/include/connection.h
+++ b/src/third_party/wiredtiger/src/include/connection.h
@@ -634,30 +634,32 @@ struct __wt_connection_impl {
uint32_t server_flags;
/* AUTOMATIC FLAG VALUE GENERATION START 0 */
-#define WT_CONN_BACKUP_PARTIAL_RESTORE 0x000001u
-#define WT_CONN_CACHE_CURSORS 0x000002u
-#define WT_CONN_CACHE_POOL 0x000004u
-#define WT_CONN_CKPT_GATHER 0x000008u
-#define WT_CONN_CKPT_SYNC 0x000010u
-#define WT_CONN_CLOSING 0x000020u
-#define WT_CONN_CLOSING_CHECKPOINT 0x000040u
-#define WT_CONN_CLOSING_NO_MORE_OPENS 0x000080u
-#define WT_CONN_COMPATIBILITY 0x000100u
-#define WT_CONN_DATA_CORRUPTION 0x000200u
-#define WT_CONN_EVICTION_RUN 0x000400u
-#define WT_CONN_HS_OPEN 0x000800u
-#define WT_CONN_INCR_BACKUP 0x001000u
-#define WT_CONN_IN_MEMORY 0x002000u
-#define WT_CONN_LEAK_MEMORY 0x004000u
-#define WT_CONN_LSM_MERGE 0x008000u
-#define WT_CONN_OPTRACK 0x010000u
-#define WT_CONN_PANIC 0x020000u
-#define WT_CONN_READONLY 0x040000u
-#define WT_CONN_RECONFIGURING 0x080000u
-#define WT_CONN_RECOVERING 0x100000u
-#define WT_CONN_SALVAGE 0x200000u
-#define WT_CONN_TIERED_FIRST_FLUSH 0x400000u
-#define WT_CONN_WAS_BACKUP 0x800000u
+#define WT_CONN_BACKUP_PARTIAL_RESTORE 0x0000001u
+#define WT_CONN_CACHE_CURSORS 0x0000002u
+#define WT_CONN_CACHE_POOL 0x0000004u
+#define WT_CONN_CKPT_GATHER 0x0000008u
+#define WT_CONN_CKPT_SYNC 0x0000010u
+#define WT_CONN_CLOSING 0x0000020u
+#define WT_CONN_CLOSING_CHECKPOINT 0x0000040u
+#define WT_CONN_CLOSING_NO_MORE_OPENS 0x0000080u
+#define WT_CONN_COMPATIBILITY 0x0000100u
+#define WT_CONN_DATA_CORRUPTION 0x0000200u
+#define WT_CONN_EVICTION_RUN 0x0000400u
+#define WT_CONN_HS_OPEN 0x0000800u
+#define WT_CONN_INCR_BACKUP 0x0001000u
+#define WT_CONN_IN_MEMORY 0x0002000u
+#define WT_CONN_LEAK_MEMORY 0x0004000u
+#define WT_CONN_LSM_MERGE 0x0008000u
+#define WT_CONN_MINIMAL 0x0010000u
+#define WT_CONN_OPTRACK 0x0020000u
+#define WT_CONN_PANIC 0x0040000u
+#define WT_CONN_READONLY 0x0080000u
+#define WT_CONN_READY 0x0100000u
+#define WT_CONN_RECONFIGURING 0x0200000u
+#define WT_CONN_RECOVERING 0x0400000u
+#define WT_CONN_SALVAGE 0x0800000u
+#define WT_CONN_TIERED_FIRST_FLUSH 0x1000000u
+#define WT_CONN_WAS_BACKUP 0x2000000u
/* AUTOMATIC FLAG VALUE GENERATION STOP 32 */
uint32_t flags;
};
diff --git a/src/third_party/wiredtiger/src/include/wiredtiger.in b/src/third_party/wiredtiger/src/include/wiredtiger.in
index 56c8e026575..c7727afcb14 100644
--- a/src/third_party/wiredtiger/src/include/wiredtiger.in
+++ b/src/third_party/wiredtiger/src/include/wiredtiger.in
@@ -3290,6 +3290,12 @@ int wiredtiger_open(const char *home,
*/
const char *wiredtiger_strerror(int error) WT_ATTRIBUTE_LIBRARY_VISIBLE;
+/*! WT_EVENT_HANDLER::special event types */
+typedef enum {
+ WT_EVENT_CONN_CLOSE, /*!< Connection closing. */
+ WT_EVENT_CONN_READY /*!< Connection is ready. */
+} WT_EVENT_TYPE;
+
/*!
* The interface implemented by applications to handle error, informational and
* progress messages. Entries set to NULL are ignored and the default handlers
@@ -3370,6 +3376,24 @@ struct __wt_event_handler {
*/
int (*handle_close)(WT_EVENT_HANDLER *handler,
WT_SESSION *session, WT_CURSOR *cursor);
+
+ /*!
+ * Callback to handle general events. The application may choose to handle
+ * only some types of events. An unhandled event should return 0.
+ *
+ * General event returns are not ignored in most cases. If the handler
+ * returns non-zero, the error may cause the WiredTiger function posting
+ * the event to fail.
+ *
+ * @param wt_conn The connection handle for the database.
+ * @param session the WiredTiger session handle in use when the
+ * progress message was generated. The handle may have been created by
+ * the application or automatically by WiredTiger or may be NULL.
+ * @param type A type indicator for what special event occurred.
+ * (see ::WT_EVENT_TYPE for available options.)
+ */
+ int (*handle_general)(WT_EVENT_HANDLER *handler,
+ WT_CONNECTION *wt_conn, WT_SESSION *session, WT_EVENT_TYPE type);
};
/*!
diff --git a/src/third_party/wiredtiger/src/session/session_api.c b/src/third_party/wiredtiger/src/session/session_api.c
index f9eefc9e536..38bafdae4b0 100644
--- a/src/third_party/wiredtiger/src/session/session_api.c
+++ b/src/third_party/wiredtiger/src/session/session_api.c
@@ -450,6 +450,25 @@ err:
}
/*
+ * __session_reconfigure_notsup --
+ * WT_SESSION->reconfigure method; not supported version.
+ */
+static int
+__session_reconfigure_notsup(WT_SESSION *wt_session, const char *config)
+{
+ WT_DECL_RET;
+ WT_SESSION_IMPL *session;
+
+ WT_UNUSED(config);
+
+ session = (WT_SESSION_IMPL *)wt_session;
+ SESSION_API_CALL_NOCONF(session, reconfigure);
+ ret = __wt_session_notsup(session);
+err:
+ API_END_RET(session, ret);
+}
+
+/*
* __session_open_cursor_int --
* Internal version of WT_SESSION::open_cursor, with second cursor arg.
*/
@@ -619,6 +638,19 @@ __session_open_cursor(WT_SESSION *wt_session, const char *uri, WT_CURSOR *to_dup
session = (WT_SESSION_IMPL *)wt_session;
SESSION_API_CALL(session, open_cursor, config, cfg);
+ /*
+ * Check for early usage of a user session to collect statistics. If the connection is not fully
+ * ready but can be used, then only allow a cursor uri of "statistics:" only. The conditional is
+ * complicated. Allow the cursor to open if any of these conditions are met:
+ * - The connection is ready
+ * - The session is an internal session
+ * - The connection is minimally ready and the URI is "statistics:"
+ */
+ if (!F_ISSET(S2C(session), WT_CONN_READY) && !F_ISSET(session, WT_SESSION_INTERNAL) &&
+ (!F_ISSET(S2C(session), WT_CONN_MINIMAL) || strcmp(uri, "statistics:") != 0))
+ WT_ERR_MSG(
+ session, EINVAL, "cannot open a non-statistics cursor before connection is opened");
+
statjoin = (to_dup != NULL && uri != NULL && strcmp(uri, "statistics:join") == 0);
if (!statjoin) {
if ((to_dup == NULL && uri == NULL) || (to_dup != NULL && uri != NULL))
@@ -1074,6 +1106,23 @@ err:
}
/*
+ * __session_reset_notsup --
+ * WT_SESSION->reset method; not supported version.
+ */
+static int
+__session_reset_notsup(WT_SESSION *wt_session)
+{
+ WT_DECL_RET;
+ WT_SESSION_IMPL *session;
+
+ session = (WT_SESSION_IMPL *)wt_session;
+ SESSION_API_CALL_NOCONF(session, reset);
+ ret = __wt_session_notsup(session);
+err:
+ API_END_RET(session, ret);
+}
+
+/*
* __session_drop --
* WT_SESSION->drop method.
*/
@@ -1278,6 +1327,28 @@ err:
}
/*
+ * __session_join_notsup --
+ * WT_SESSION->join method; not supported version.
+ */
+static int
+__session_join_notsup(
+ WT_SESSION *wt_session, WT_CURSOR *join_cursor, WT_CURSOR *ref_cursor, const char *config)
+{
+ WT_DECL_RET;
+ WT_SESSION_IMPL *session;
+
+ WT_UNUSED(join_cursor);
+ WT_UNUSED(ref_cursor);
+ WT_UNUSED(config);
+
+ session = (WT_SESSION_IMPL *)wt_session;
+ SESSION_API_CALL_NOCONF(session, join);
+ ret = __wt_session_notsup(session);
+err:
+ API_END_RET(session, ret);
+}
+
+/*
* __session_salvage_worker --
* Wrapper function for salvage processing.
*/
@@ -1639,6 +1710,26 @@ err:
}
/*
+ * __session_verify_notsup --
+ * WT_SESSION->verify method; not supported version.
+ */
+static int
+__session_verify_notsup(WT_SESSION *wt_session, const char *uri, const char *config)
+{
+ WT_DECL_RET;
+ WT_SESSION_IMPL *session;
+
+ WT_UNUSED(uri);
+ WT_UNUSED(config);
+
+ session = (WT_SESSION_IMPL *)wt_session;
+ SESSION_API_CALL_NOCONF(session, verify);
+ ret = __wt_session_notsup(session);
+err:
+ API_END_RET(session, ret);
+}
+
+/*
* __session_begin_transaction --
* WT_SESSION->begin_transaction method.
*/
@@ -1662,6 +1753,25 @@ err:
}
/*
+ * __session_begin_transaction_notsup --
+ * WT_SESSION->begin_transaction method; not supported version.
+ */
+static int
+__session_begin_transaction_notsup(WT_SESSION *wt_session, const char *config)
+{
+ WT_DECL_RET;
+ WT_SESSION_IMPL *session;
+
+ WT_UNUSED(config);
+
+ session = (WT_SESSION_IMPL *)wt_session;
+ SESSION_API_CALL_NOCONF(session, begin_transaction);
+ ret = __wt_session_notsup(session);
+err:
+ API_END_RET(session, ret);
+}
+
+/*
* __session_commit_transaction --
* WT_SESSION->commit_transaction method.
*/
@@ -1714,6 +1824,25 @@ err:
}
/*
+ * __session_commit_transaction_notsup --
+ * WT_SESSION->commit_transaction method; not supported version.
+ */
+static int
+__session_commit_transaction_notsup(WT_SESSION *wt_session, const char *config)
+{
+ WT_DECL_RET;
+ WT_SESSION_IMPL *session;
+
+ WT_UNUSED(config);
+
+ session = (WT_SESSION_IMPL *)wt_session;
+ SESSION_API_CALL_NOCONF(session, commit_transaction);
+ ret = __wt_session_notsup(session);
+err:
+ API_END_RET(session, ret);
+}
+
+/*
* __session_prepare_transaction --
* WT_SESSION->prepare_transaction method.
*/
@@ -1792,6 +1921,25 @@ err:
}
/*
+ * __session_rollback_transaction_notsup --
+ * WT_SESSION->rollback_transaction method; not supported version.
+ */
+static int
+__session_rollback_transaction_notsup(WT_SESSION *wt_session, const char *config)
+{
+ WT_DECL_RET;
+ WT_SESSION_IMPL *session;
+
+ WT_UNUSED(config);
+
+ session = (WT_SESSION_IMPL *)wt_session;
+ SESSION_API_CALL_NOCONF(session, rollback_transaction);
+ ret = __wt_session_notsup(session);
+err:
+ API_END_RET(session, ret);
+}
+
+/*
* __session_timestamp_transaction --
* WT_SESSION->timestamp_transaction method. Also see __session_timestamp_transaction_uint if
* config parsing is a performance issue.
@@ -1816,6 +1964,25 @@ err:
}
/*
+ * __session_timestamp_transaction_notsup --
+ * WT_SESSION->timestamp_transaction method; not supported version.
+ */
+static int
+__session_timestamp_transaction_notsup(WT_SESSION *wt_session, const char *config)
+{
+ WT_DECL_RET;
+ WT_SESSION_IMPL *session;
+
+ WT_UNUSED(config);
+
+ session = (WT_SESSION_IMPL *)wt_session;
+ SESSION_API_CALL_NOCONF(session, timestamp_transaction);
+ ret = __wt_session_notsup(session);
+err:
+ API_END_RET(session, ret);
+}
+
+/*
* __session_timestamp_transaction_uint --
* WT_SESSION->timestamp_transaction_uint method.
*/
@@ -1834,6 +2001,27 @@ err:
}
/*
+ * __session_timestamp_transaction_uint_notsup --
+ * WT_SESSION->timestamp_transaction_uint_ method; not supported version.
+ */
+static int
+__session_timestamp_transaction_uint_notsup(
+ WT_SESSION *wt_session, WT_TS_TXN_TYPE which, uint64_t ts)
+{
+ WT_DECL_RET;
+ WT_SESSION_IMPL *session;
+
+ WT_UNUSED(which);
+ WT_UNUSED(ts);
+
+ session = (WT_SESSION_IMPL *)wt_session;
+ SESSION_API_CALL_NOCONF(session, timestamp_transaction_uint);
+ ret = __wt_session_notsup(session);
+err:
+ API_END_RET(session, ret);
+}
+
+/*
* __session_query_timestamp --
* WT_SESSION->query_timestamp method.
*/
@@ -1852,6 +2040,26 @@ err:
}
/*
+ * __session_query_timestamp_notsup --
+ * WT_SESSION->query_timestamp method; not supported version.
+ */
+static int
+__session_query_timestamp_notsup(WT_SESSION *wt_session, char *hex_timestamp, const char *config)
+{
+ WT_DECL_RET;
+ WT_SESSION_IMPL *session;
+
+ WT_UNUSED(hex_timestamp);
+ WT_UNUSED(config);
+
+ session = (WT_SESSION_IMPL *)wt_session;
+ SESSION_API_CALL_NOCONF(session, query_timestamp);
+ ret = __wt_session_notsup(session);
+err:
+ API_END_RET(session, ret);
+}
+
+/*
* __session_reset_snapshot --
* WT_SESSION->reset_snapshot method.
*/
@@ -1880,6 +2088,23 @@ __session_reset_snapshot(WT_SESSION *wt_session)
}
/*
+ * __session_reset_snapshot_notsup --
+ * WT_SESSION->reset_snapshot method; not supported version.
+ */
+static int
+__session_reset_snapshot_notsup(WT_SESSION *wt_session)
+{
+ WT_DECL_RET;
+ WT_SESSION_IMPL *session;
+
+ session = (WT_SESSION_IMPL *)wt_session;
+ SESSION_API_CALL_NOCONF(session, reset_snapshot);
+ ret = __wt_session_notsup(session);
+err:
+ API_END_RET(session, ret);
+}
+
+/*
* __session_transaction_pinned_range --
* WT_SESSION->transaction_pinned_range method.
*/
@@ -1912,6 +2137,25 @@ err:
}
/*
+ * __session_transaction_pinned_range_notsup --
+ * WT_SESSION->transaction_pinned_range method; not supported version.
+ */
+static int
+__session_transaction_pinned_range_notsup(WT_SESSION *wt_session, uint64_t *prange)
+{
+ WT_DECL_RET;
+ WT_SESSION_IMPL *session;
+
+ WT_UNUSED(prange);
+
+ session = (WT_SESSION_IMPL *)wt_session;
+ SESSION_API_CALL_NOCONF(session, transaction_pinned_range);
+ ret = __wt_session_notsup(session);
+err:
+ API_END_RET(session, ret);
+}
+
+/*
* __session_get_rollback_reason --
* WT_SESSION->get_rollback_reason method.
*/
@@ -2069,6 +2313,19 @@ __open_session(WT_CONNECTION_IMPL *conn, WT_EVENT_HANDLER *event_handler, const
__session_query_timestamp, __session_timestamp_transaction,
__session_timestamp_transaction_uint, __session_checkpoint, __session_reset_snapshot,
__session_transaction_pinned_range, __session_get_rollback_reason, __wt_session_breakpoint},
+ stds_min = {NULL, NULL, __session_close, __session_reconfigure_notsup,
+ __session_flush_tier_readonly, __wt_session_strerror, __session_open_cursor,
+ __session_alter_readonly, __session_create_readonly, __wt_session_compact_readonly,
+ __session_drop_readonly, __session_join_notsup, __session_log_flush_readonly,
+ __session_log_printf_readonly, __session_rename_readonly, __session_reset_notsup,
+ __session_salvage_readonly, __session_truncate_readonly, __session_upgrade_readonly,
+ __session_verify_notsup, __session_begin_transaction_notsup,
+ __session_commit_transaction_notsup, __session_prepare_transaction_readonly,
+ __session_rollback_transaction_notsup, __session_query_timestamp_notsup,
+ __session_timestamp_transaction_notsup, __session_timestamp_transaction_uint_notsup,
+ __session_checkpoint_readonly, __session_reset_snapshot_notsup,
+ __session_transaction_pinned_range_notsup, __session_get_rollback_reason,
+ __wt_session_breakpoint},
stds_readonly = {NULL, NULL, __session_close, __session_reconfigure,
__session_flush_tier_readonly, __wt_session_strerror, __session_open_cursor,
__session_alter_readonly, __session_create_readonly, __wt_session_compact_readonly,
@@ -2115,7 +2372,11 @@ __open_session(WT_CONNECTION_IMPL *conn, WT_EVENT_HANDLER *event_handler, const
if (i >= conn->session_cnt) /* Defend against off-by-one errors. */
conn->session_cnt = i + 1;
- session_ret->iface = F_ISSET(conn, WT_CONN_READONLY) ? stds_readonly : stds;
+ /* Find the set of methods appropriate to this session. */
+ if (F_ISSET(conn, WT_CONN_MINIMAL) && !F_ISSET(session, WT_SESSION_INTERNAL))
+ session_ret->iface = stds_min;
+ else
+ session_ret->iface = F_ISSET(conn, WT_CONN_READONLY) ? stds_readonly : stds;
session_ret->iface.connection = &conn->iface;
session_ret->name = NULL;
diff --git a/src/third_party/wiredtiger/src/support/err.c b/src/third_party/wiredtiger/src/support/err.c
index 287a59b4c41..4b7597bad40 100644
--- a/src/third_party/wiredtiger/src/support/err.c
+++ b/src/third_party/wiredtiger/src/support/err.c
@@ -78,8 +78,24 @@ __handle_close_default(WT_EVENT_HANDLER *handler, WT_SESSION *wt_session, WT_CUR
return (0);
}
+/*
+ * __handle_general_default --
+ * Default WT_EVENT_HANDLER->handle_general implementation: ignore.
+ */
+static int
+__handle_general_default(
+ WT_EVENT_HANDLER *handler, WT_CONNECTION *wt_conn, WT_SESSION *wt_session, WT_EVENT_TYPE type)
+{
+ WT_UNUSED(handler);
+ WT_UNUSED(wt_conn);
+ WT_UNUSED(wt_session);
+ WT_UNUSED(type);
+
+ return (0);
+}
+
static WT_EVENT_HANDLER __event_handler_default = {__handle_error_default, __handle_message_default,
- __handle_progress_default, __handle_close_default};
+ __handle_progress_default, __handle_close_default, __handle_general_default};
/*
* __handler_failure --
diff --git a/src/third_party/wiredtiger/src/utilities/util_verbose.c b/src/third_party/wiredtiger/src/utilities/util_verbose.c
index 66c0420d986..7093d89ceaf 100644
--- a/src/third_party/wiredtiger/src/utilities/util_verbose.c
+++ b/src/third_party/wiredtiger/src/utilities/util_verbose.c
@@ -52,8 +52,8 @@ __handle_progress_verbose(
static WT_EVENT_HANDLER __event_handler_verbose = {
__handle_error_verbose, __handle_message_verbose, __handle_progress_verbose,
- NULL /* Close handler. */
-
+ NULL, /* Session close handler. */
+ NULL /* General handler. */
};
WT_EVENT_HANDLER *verbose_handler = &__event_handler_verbose;
diff --git a/src/third_party/wiredtiger/test/checkpoint/test_checkpoint.c b/src/third_party/wiredtiger/test/checkpoint/test_checkpoint.c
index 3ffeb0bf262..7e0f8b8b03b 100644
--- a/src/third_party/wiredtiger/test/checkpoint/test_checkpoint.c
+++ b/src/third_party/wiredtiger/test/checkpoint/test_checkpoint.c
@@ -275,9 +275,7 @@ run_complete:
static int
wt_connect(const char *config_open)
{
- static WT_EVENT_HANDLER event_handler = {
- handle_error, handle_message, NULL, NULL /* Close handler. */
- };
+ static WT_EVENT_HANDLER event_handler = {handle_error, handle_message, NULL, NULL, NULL};
WT_RAND_STATE rnd;
int ret;
char buf[512], config[1024];
diff --git a/src/third_party/wiredtiger/test/csuite/schema_abort/main.c b/src/third_party/wiredtiger/test/csuite/schema_abort/main.c
index 2f92a0a3585..5d3da58863d 100644
--- a/src/third_party/wiredtiger/test/csuite/schema_abort/main.c
+++ b/src/third_party/wiredtiger/test/csuite/schema_abort/main.c
@@ -171,7 +171,8 @@ subtest_error_handler(
static WT_EVENT_HANDLER event_handler = {
subtest_error_handler, NULL, /* Message handler */
NULL, /* Progress handler */
- NULL /* Close handler */
+ NULL, /* Close handler */
+ NULL /* General handler */
};
/*
diff --git a/src/third_party/wiredtiger/test/csuite/scope/main.c b/src/third_party/wiredtiger/test/csuite/scope/main.c
index 66e88a15c9c..78b9694ac9f 100644
--- a/src/third_party/wiredtiger/test/csuite/scope/main.c
+++ b/src/third_party/wiredtiger/test/csuite/scope/main.c
@@ -53,7 +53,7 @@ handle_error(WT_EVENT_HANDLER *handler, WT_SESSION *session, int error, const ch
return (0);
}
-static WT_EVENT_HANDLER event_handler = {handle_error, NULL, NULL, NULL};
+static WT_EVENT_HANDLER event_handler = {handle_error, NULL, NULL, NULL, NULL};
#define SET_KEY \
do { \
diff --git a/src/third_party/wiredtiger/test/csuite/timestamp_abort/main.c b/src/third_party/wiredtiger/test/csuite/timestamp_abort/main.c
index 96494830d1b..4c76a4ae2e2 100644
--- a/src/third_party/wiredtiger/test/csuite/timestamp_abort/main.c
+++ b/src/third_party/wiredtiger/test/csuite/timestamp_abort/main.c
@@ -71,6 +71,7 @@ static char home[1024]; /* Program working dir */
/* Include worker threads and prepare extra sessions */
#define SESSION_MAX (MAX_TH + 3 + MAX_TH * PREPARE_PCT)
#define STAT_WAIT 1
+#define USEC_STAT 10000
static const char *table_pfx = "table";
static const char *const uri_collection = "collection";
@@ -133,6 +134,105 @@ static wt_timestamp_t *active_timestamps; /* Oldest timestamps still in use. */
static void handler(int) WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
static void usage(void) WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
+static void handle_conn_close(void);
+static void handle_conn_ready(WT_CONNECTION *);
+static int handle_general(WT_EVENT_HANDLER *, WT_CONNECTION *, WT_SESSION *, WT_EVENT_TYPE);
+
+static WT_CONNECTION *stat_conn = NULL;
+static WT_SESSION *stat_session = NULL;
+static volatile bool stat_run = false;
+static wt_thread_t stat_th;
+
+static WT_EVENT_HANDLER my_event = {NULL, NULL, NULL, NULL, handle_general};
+/*
+ * stat_func --
+ * Function to run with the early connection and gather statistics.
+ */
+static WT_THREAD_RET
+stat_func(void *arg)
+{
+ WT_CURSOR *stat_c;
+ int64_t last, value;
+ const char *desc, *pvalue;
+
+ WT_UNUSED(arg);
+ testutil_assert(stat_conn != NULL);
+ testutil_check(stat_conn->open_session(stat_conn, NULL, NULL, &stat_session));
+ desc = pvalue = NULL;
+ /* Start last and value at different numbers so we print the first value, likely 0. */
+ last = -1;
+ value = 0;
+ while (stat_run) {
+ testutil_check(stat_session->open_cursor(stat_session, "statistics:", NULL, NULL, &stat_c));
+
+ /* Pick some statistic that is likely changed during recovery RTS. */
+ stat_c->set_key(stat_c, WT_STAT_CONN_TXN_RTS_PAGES_VISITED);
+ testutil_check(stat_c->search(stat_c));
+ testutil_check(stat_c->get_value(stat_c, &desc, &pvalue, &value));
+ testutil_check(stat_c->close(stat_c));
+ if (desc != NULL && value != last)
+ printf("%s: %" PRId64 "\n", desc, value);
+ last = value;
+ usleep(USEC_STAT);
+ }
+ testutil_check(stat_session->close(stat_session, NULL));
+ return (WT_THREAD_RET_VALUE);
+}
+
+/*
+ * handle_conn_close --
+ * Function to handle connection close callbacks from WiredTiger.
+ */
+static void
+handle_conn_close(void)
+{
+ /*
+ * Signal the statistics thread to exit and clear the global connection. This function cannot
+ * return until the user thread stops using the connection.
+ */
+ stat_run = false;
+ testutil_check(__wt_thread_join(NULL, &stat_th));
+ stat_conn = NULL;
+}
+
+/*
+ * handle_conn_ready --
+ * Function to handle connection ready callbacks from WiredTiger.
+ */
+static void
+handle_conn_ready(WT_CONNECTION *conn)
+{
+ int unused;
+
+ /*
+ * Set the global connection for statistics and then start a statistics thread.
+ */
+ unused = 0;
+ testutil_assert(stat_conn == NULL);
+ memset(&stat_th, 0, sizeof(stat_th));
+ stat_conn = conn;
+ stat_run = true;
+ testutil_check(__wt_thread_create(NULL, &stat_th, stat_func, (void *)&unused));
+}
+
+/*
+ * handle_general --
+ * Function to handle general event callbacks.
+ */
+static int
+handle_general(
+ WT_EVENT_HANDLER *handler, WT_CONNECTION *conn, WT_SESSION *session, WT_EVENT_TYPE type)
+{
+ WT_UNUSED(handler);
+ WT_UNUSED(session);
+
+ if (type == WT_EVENT_CONN_CLOSE)
+ handle_conn_close();
+ else if (type == WT_EVENT_CONN_READY)
+ handle_conn_ready(conn);
+ return (0);
+}
+
/*
* usage --
* TODO: Add a comment describing this function.
@@ -170,7 +270,8 @@ thread_ts_run(void *arg)
__wt_seconds((WT_SESSION_IMPL *)session, &last_reconfig);
/* Update the oldest/stable timestamps every 1 millisecond. */
for (last_ts = 0;; __wt_sleep(0, 1000)) {
- /* Get the last committed timestamp periodically in order to update the oldest timestamp. */
+ /* Get the last committed timestamp periodically in order to update the oldest
+ * timestamp. */
ts = maximum_stable_ts(active_timestamps, nth);
if (ts == last_ts)
continue;
@@ -797,12 +898,15 @@ main(int argc, char *argv[])
/* Copy the data to a separate folder for debugging purpose. */
testutil_copy_data(home);
- printf("Open database, run recovery and verify content\n");
+ printf("Open database and run recovery\n");
/*
* Open the connection which forces recovery to be run.
*/
- testutil_check(wiredtiger_open(NULL, NULL, ENV_CONFIG_REC, &conn));
+ testutil_check(wiredtiger_open(NULL, &my_event, ENV_CONFIG_REC, &conn));
+ printf("Connection open and recovery complete. Verify content\n");
+ /* Sleep to guarantee the statistics thread has enough time to run. */
+ usleep(USEC_STAT + 10);
testutil_check(conn->open_session(conn, NULL, NULL, &session));
/*
* Open a cursor on all the tables.
diff --git a/src/third_party/wiredtiger/test/csuite/wt2719_reconfig/main.c b/src/third_party/wiredtiger/test/csuite/wt2719_reconfig/main.c
index 195f61b05e9..610913e227d 100644
--- a/src/third_party/wiredtiger/test/csuite/wt2719_reconfig/main.c
+++ b/src/third_party/wiredtiger/test/csuite/wt2719_reconfig/main.c
@@ -111,7 +111,7 @@ handle_message(WT_EVENT_HANDLER *handler, WT_SESSION *session, const char *messa
return (0);
}
-static WT_EVENT_HANDLER event_handler = {NULL, handle_message, NULL, NULL};
+static WT_EVENT_HANDLER event_handler = {NULL, handle_message, NULL, NULL, NULL};
static const char *current; /* Current test configuration */
diff --git a/src/third_party/wiredtiger/test/csuite/wt2909_checkpoint_integrity/main.c b/src/third_party/wiredtiger/test/csuite/wt2909_checkpoint_integrity/main.c
index afbb3ca5986..abff8420eed 100644
--- a/src/third_party/wiredtiger/test/csuite/wt2909_checkpoint_integrity/main.c
+++ b/src/third_party/wiredtiger/test/csuite/wt2909_checkpoint_integrity/main.c
@@ -485,7 +485,8 @@ subtest_error_handler(
static WT_EVENT_HANDLER event_handler = {
subtest_error_handler, NULL, /* Message handler */
NULL, /* Progress handler */
- NULL /* Close handler */
+ NULL, /* Close handler */
+ NULL /* General handler */
};
/*
diff --git a/src/third_party/wiredtiger/test/csuite/wt3363_checkpoint_op_races/main.c b/src/third_party/wiredtiger/test/csuite/wt3363_checkpoint_op_races/main.c
index 9e6205935d8..24db947628b 100644
--- a/src/third_party/wiredtiger/test/csuite/wt3363_checkpoint_op_races/main.c
+++ b/src/third_party/wiredtiger/test/csuite/wt3363_checkpoint_op_races/main.c
@@ -66,7 +66,7 @@ static WT_THREAD_RET monitor(void *);
*/
#define RUNTIME 900.0
-static WT_EVENT_HANDLER event_handler = {handle_op_error, handle_op_message, NULL, NULL};
+static WT_EVENT_HANDLER event_handler = {handle_op_error, handle_op_message, NULL, NULL, NULL};
/*
* main --
diff --git a/src/third_party/wiredtiger/test/csuite/wt4105_large_doc_small_upd/main.c b/src/third_party/wiredtiger/test/csuite/wt4105_large_doc_small_upd/main.c
index 5c236c65e5d..cab313f515d 100644
--- a/src/third_party/wiredtiger/test/csuite/wt4105_large_doc_small_upd/main.c
+++ b/src/third_party/wiredtiger/test/csuite/wt4105_large_doc_small_upd/main.c
@@ -74,7 +74,7 @@ handle_error(WT_EVENT_HANDLER *handler, WT_SESSION *session, int error, const ch
return (0);
}
-static WT_EVENT_HANDLER event_handler = {handle_error, NULL, NULL, NULL};
+static WT_EVENT_HANDLER event_handler = {handle_error, NULL, NULL, NULL, NULL};
/*
* main --
diff --git a/src/third_party/wiredtiger/test/csuite/wt4156_metadata_salvage/main.c b/src/third_party/wiredtiger/test/csuite/wt4156_metadata_salvage/main.c
index 72362888423..e8879bbcad6 100644
--- a/src/third_party/wiredtiger/test/csuite/wt4156_metadata_salvage/main.c
+++ b/src/third_party/wiredtiger/test/csuite/wt4156_metadata_salvage/main.c
@@ -67,7 +67,7 @@ handle_message(WT_EVENT_HANDLER *handler, WT_SESSION *session, int error, const
return (0);
}
-static WT_EVENT_HANDLER event_handler = {handle_message, NULL, NULL, NULL};
+static WT_EVENT_HANDLER event_handler = {handle_message, NULL, NULL, NULL, NULL};
typedef struct table_info {
const char *name;
diff --git a/src/third_party/wiredtiger/test/csuite/wt4803_history_store_abort/main.c b/src/third_party/wiredtiger/test/csuite/wt4803_history_store_abort/main.c
index 6efbd3b51d4..963f6527b9e 100644
--- a/src/third_party/wiredtiger/test/csuite/wt4803_history_store_abort/main.c
+++ b/src/third_party/wiredtiger/test/csuite/wt4803_history_store_abort/main.c
@@ -76,7 +76,7 @@ handle_message(WT_EVENT_HANDLER *handler, WT_SESSION *session, int error, const
return (0);
}
-static WT_EVENT_HANDLER event_handler = {handle_message, NULL, NULL, NULL};
+static WT_EVENT_HANDLER event_handler = {handle_message, NULL, NULL, NULL, NULL};
/*
* hs_workload --
diff --git a/src/third_party/wiredtiger/test/csuite/wt8057_compact_stress/main.c b/src/third_party/wiredtiger/test/csuite/wt8057_compact_stress/main.c
index dfcbe95c23b..91e3529cc33 100644
--- a/src/third_party/wiredtiger/test/csuite/wt8057_compact_stress/main.c
+++ b/src/third_party/wiredtiger/test/csuite/wt8057_compact_stress/main.c
@@ -76,7 +76,8 @@ subtest_error_handler(
static WT_EVENT_HANDLER event_handler = {
subtest_error_handler, NULL, /* Message handler */
NULL, /* Progress handler */
- NULL /* Close handler */
+ NULL, /* Close handler */
+ NULL /* Special handler */
};
static void sig_handler(int) WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
diff --git a/src/third_party/wiredtiger/test/cursor_order/cursor_order.c b/src/third_party/wiredtiger/test/cursor_order/cursor_order.c
index 4cf99d20c5a..2b4c1bc20e4 100644
--- a/src/third_party/wiredtiger/test/cursor_order/cursor_order.c
+++ b/src/third_party/wiredtiger/test/cursor_order/cursor_order.c
@@ -168,9 +168,7 @@ main(int argc, char *argv[])
static void
wt_connect(SHARED_CONFIG *cfg, char *config_open)
{
- static WT_EVENT_HANDLER event_handler = {
- handle_error, handle_message, NULL, NULL /* Close handler. */
- };
+ static WT_EVENT_HANDLER event_handler = {handle_error, handle_message, NULL, NULL, NULL};
char config[512];
testutil_clean_work_dir(home);
diff --git a/src/third_party/wiredtiger/test/fops/t.c b/src/third_party/wiredtiger/test/fops/t.c
index aa96682cd74..92de1f37e01 100644
--- a/src/third_party/wiredtiger/test/fops/t.c
+++ b/src/third_party/wiredtiger/test/fops/t.c
@@ -147,9 +147,7 @@ main(int argc, char *argv[])
static void
wt_startup(char *config_open)
{
- static WT_EVENT_HANDLER event_handler = {
- handle_error, handle_message, NULL, NULL /* Close handler. */
- };
+ static WT_EVENT_HANDLER event_handler = {handle_error, handle_message, NULL, NULL, NULL};
char config_buf[128];
testutil_make_work_dir(home);
diff --git a/src/third_party/wiredtiger/test/format/wts.c b/src/third_party/wiredtiger/test/format/wts.c
index 14417ff309f..d1096347971 100644
--- a/src/third_party/wiredtiger/test/format/wts.c
+++ b/src/third_party/wiredtiger/test/format/wts.c
@@ -137,9 +137,7 @@ handle_progress(
return (0);
}
-static WT_EVENT_HANDLER event_handler = {
- NULL, handle_message, handle_progress, NULL /* Close handler. */
-};
+static WT_EVENT_HANDLER event_handler = {NULL, handle_message, handle_progress, NULL, NULL};
#define CONFIG_APPEND(p, ...) \
do { \
diff --git a/src/third_party/wiredtiger/test/thread/t.c b/src/third_party/wiredtiger/test/thread/t.c
index 9a0dd5fba20..ab6d0b3e92c 100644
--- a/src/third_party/wiredtiger/test/thread/t.c
+++ b/src/third_party/wiredtiger/test/thread/t.c
@@ -174,9 +174,7 @@ main(int argc, char *argv[])
static void
wt_connect(char *config_open)
{
- static WT_EVENT_HANDLER event_handler = {
- handle_error, handle_message, NULL, NULL /* Close handler. */
- };
+ static WT_EVENT_HANDLER event_handler = {handle_error, handle_message, NULL, NULL, NULL};
char config[512];
testutil_clean_work_dir(home);