diff options
author | Keith Bostic <keith.bostic@mongodb.com> | 2016-09-22 19:46:41 -0400 |
---|---|---|
committer | Alex Gorrod <alexander.gorrod@mongodb.com> | 2016-09-23 09:46:41 +1000 |
commit | 8ef98127b1fbf1d8a0fc8c2e97ad9b06b7d3517a (patch) | |
tree | 4867e34f4d5c8a031ae346bd70aca7b4553afbd1 | |
parent | 1c2c9268e122c4da1e49f14b7b17f20183b1a991 (diff) | |
download | mongo-8ef98127b1fbf1d8a0fc8c2e97ad9b06b7d3517a.tar.gz |
WT-2864 Update reconfigure test to detect hangs (#3051)
Set an alarm when running reconfiguration tests so we can detect hangs;
if the alarm goes off, output the current configuration string and drop
core.
We've seen cases where reconfiguring causes a hang, but haven't been able to identify the root cause.
-rw-r--r-- | test/csuite/wt2719_reconfig/main.c | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/test/csuite/wt2719_reconfig/main.c b/test/csuite/wt2719_reconfig/main.c index 1ff7b10e1c6..b67dae6d647 100644 --- a/test/csuite/wt2719_reconfig/main.c +++ b/test/csuite/wt2719_reconfig/main.c @@ -27,6 +27,8 @@ */ #include "test_util.h" +#include <signal.h> + /* * JIRA ticket reference: WT-2719 * Test case description: Fuzz testing for WiredTiger reconfiguration. @@ -191,6 +193,41 @@ handle_message(WT_EVENT_HANDLER *handler, static WT_EVENT_HANDLER event_handler = { NULL, handle_message, NULL, NULL }; +static const char *current; /* Current test configuration */ + +static void on_alarm(int) WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn)); +static void +on_alarm(int signo) +{ + (void)signo; /* Unused parameter */ + + fprintf(stderr, "configuration timed out: %s\n", current); + abort(); + + /* NOTREACHED */ +} + +static void +reconfig(TEST_OPTS *opts, WT_SESSION *session, const char *config) +{ + int ret; + + current = config; + + /* + * Reconfiguration starts and stops servers, so hangs are more likely + * here than in other tests. Don't let the test run too long and get + * a core dump when it happens. + */ + (void)alarm(60); + if ((ret = opts->conn->reconfigure(opts->conn, config)) != 0) { + fprintf(stderr, "%s: %s\n", + config, session->strerror(session, ret)); + exit (EXIT_FAILURE); + } + (void)alarm(0); +} + int main(int argc, char *argv[]) { @@ -200,7 +237,6 @@ main(int argc, char *argv[]) WT_SESSION *session; size_t len; u_int i, j; - int ret; const char *p; char *config; @@ -226,13 +262,12 @@ main(int argc, char *argv[]) len = WT_ELEMENTS(list) * 64; config = dmalloc(len); + /* Set an alarm so we can debug hangs. */ + (void)signal(SIGALRM, on_alarm); + /* A linear pass through the list. */ for (i = 0; i < WT_ELEMENTS(list); ++i) - if ((ret = opts->conn->reconfigure(opts->conn, list[i])) != 0) { - fprintf(stderr, "%s: %s\n", - list[i], session->strerror(session, ret)); - return (EXIT_FAILURE); - } + reconfig(opts, session, list[i]); /* * A linear pass through the list, adding random elements. @@ -264,11 +299,7 @@ main(int argc, char *argv[]) } strcat(config, p); } - if ((ret = opts->conn->reconfigure(opts->conn, config)) != 0) { - fprintf(stderr, "%s: %s\n", - config, session->strerror(session, ret)); - return (EXIT_FAILURE); - } + reconfig(opts, session, config); } /* |