diff options
author | Luke Chen <luke.chen@mongodb.com> | 2019-08-21 05:23:37 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-08-21 05:23:37 +0000 |
commit | ac41c65f6355f83aac70136324c98561ac79daa1 (patch) | |
tree | a7c3f7ef090b59c6a06838a02c96bd1d49e1c729 /src/third_party/wiredtiger/test/fops | |
parent | f54709196711c63a429b71f47c584661286d675f (diff) | |
download | mongo-ac41c65f6355f83aac70136324c98561ac79daa1.tar.gz |
Import wiredtiger: 7dfd9391862bc9a6d84868c4dc51689c45a3aacf from branch mongodb-4.4
ref: c809757d8b..7dfd939186
for: 4.3.1
WT-4658 Apply Clang Format
WT-4810 Adding WT_ERR_ASSERT and WT_RET_ASSERT macros
WT-5046 Prepared transactions aren't properly cleared from global table with WT_CONN_LOG_DEBUG_MODE enabled
Diffstat (limited to 'src/third_party/wiredtiger/test/fops')
-rw-r--r-- | src/third_party/wiredtiger/test/fops/file.c | 385 | ||||
-rw-r--r-- | src/third_party/wiredtiger/test/fops/fops.c | 208 | ||||
-rw-r--r-- | src/third_party/wiredtiger/test/fops/t.c | 310 | ||||
-rw-r--r-- | src/third_party/wiredtiger/test/fops/thread.h | 12 |
4 files changed, 439 insertions, 476 deletions
diff --git a/src/third_party/wiredtiger/test/fops/file.c b/src/third_party/wiredtiger/test/fops/file.c index c0a6fd699b7..96faf5fb9b6 100644 --- a/src/third_party/wiredtiger/test/fops/file.c +++ b/src/third_party/wiredtiger/test/fops/file.c @@ -33,263 +33,244 @@ static u_int uid = 1; void obj_bulk(void) { - WT_CURSOR *c; - WT_SESSION *session; - int ret; - bool create; - - testutil_check(conn->open_session(conn, NULL, NULL, &session)); - - if (use_txn) - testutil_check(session->begin_transaction(session, NULL)); - create = false; - if ((ret = session->create(session, uri, config)) != 0) - if (ret != EEXIST && ret != EBUSY) - testutil_die(ret, "session.create"); - - if (ret == 0) { - create = true; - __wt_yield(); - if ((ret = session->open_cursor( - session, uri, NULL, "bulk", &c)) == 0) { - testutil_check(c->close(c)); - } else if (ret != ENOENT && ret != EBUSY && ret != EINVAL) - testutil_die(ret, "session.open_cursor bulk"); - } - - if (use_txn) { - /* If create fails, rollback else will commit.*/ - if (!create) - ret = session->rollback_transaction(session, NULL); - else - ret = session->commit_transaction(session, NULL); - - if (ret == EINVAL) - testutil_die(ret, "session.commit bulk"); - } - testutil_check(session->close(session, NULL)); + WT_CURSOR *c; + WT_SESSION *session; + int ret; + bool create; + + testutil_check(conn->open_session(conn, NULL, NULL, &session)); + + if (use_txn) + testutil_check(session->begin_transaction(session, NULL)); + create = false; + if ((ret = session->create(session, uri, config)) != 0) + if (ret != EEXIST && ret != EBUSY) + testutil_die(ret, "session.create"); + + if (ret == 0) { + create = true; + __wt_yield(); + if ((ret = session->open_cursor(session, uri, NULL, "bulk", &c)) == 0) { + testutil_check(c->close(c)); + } else if (ret != ENOENT && ret != EBUSY && ret != EINVAL) + testutil_die(ret, "session.open_cursor bulk"); + } + + if (use_txn) { + /* If create fails, rollback else will commit.*/ + if (!create) + ret = session->rollback_transaction(session, NULL); + else + ret = session->commit_transaction(session, NULL); + + if (ret == EINVAL) + testutil_die(ret, "session.commit bulk"); + } + testutil_check(session->close(session, NULL)); } void obj_bulk_unique(int force) { - WT_CURSOR *c; - WT_SESSION *session; - int ret; - char new_uri[64]; - - testutil_check(conn->open_session(conn, NULL, NULL, &session)); - - /* Generate a unique object name. */ - testutil_check(pthread_rwlock_wrlock(&single)); - testutil_check(__wt_snprintf( - new_uri, sizeof(new_uri), "%s.%u", uri, ++uid)); - testutil_check(pthread_rwlock_unlock(&single)); - - if (use_txn) - testutil_check(session->begin_transaction(session, NULL)); - testutil_check(session->create(session, new_uri, config)); - - __wt_yield(); - /* - * Opening a bulk cursor may have raced with a forced checkpoint - * which created a checkpoint of the empty file, and triggers an EINVAL - */ - if ((ret = session->open_cursor( - session, new_uri, NULL, "bulk", &c)) == 0) - testutil_check(c->close(c)); - else if (ret != EINVAL) - testutil_die(ret, - "session.open_cursor bulk unique: %s, new_uri"); - - while ((ret = session->drop( - session, new_uri, force ? "force" : NULL)) != 0) - if (ret != EBUSY) - testutil_die(ret, "session.drop: %s", new_uri); - - if (use_txn && - (ret = session->commit_transaction(session, NULL)) != 0 && - ret != EINVAL) - testutil_die(ret, "session.commit bulk unique"); - testutil_check(session->close(session, NULL)); + WT_CURSOR *c; + WT_SESSION *session; + int ret; + char new_uri[64]; + + testutil_check(conn->open_session(conn, NULL, NULL, &session)); + + /* Generate a unique object name. */ + testutil_check(pthread_rwlock_wrlock(&single)); + testutil_check(__wt_snprintf(new_uri, sizeof(new_uri), "%s.%u", uri, ++uid)); + testutil_check(pthread_rwlock_unlock(&single)); + + if (use_txn) + testutil_check(session->begin_transaction(session, NULL)); + testutil_check(session->create(session, new_uri, config)); + + __wt_yield(); + /* + * Opening a bulk cursor may have raced with a forced checkpoint which created a checkpoint of + * the empty file, and triggers an EINVAL + */ + if ((ret = session->open_cursor(session, new_uri, NULL, "bulk", &c)) == 0) + testutil_check(c->close(c)); + else if (ret != EINVAL) + testutil_die(ret, "session.open_cursor bulk unique: %s, new_uri"); + + while ((ret = session->drop(session, new_uri, force ? "force" : NULL)) != 0) + if (ret != EBUSY) + testutil_die(ret, "session.drop: %s", new_uri); + + if (use_txn && (ret = session->commit_transaction(session, NULL)) != 0 && ret != EINVAL) + testutil_die(ret, "session.commit bulk unique"); + testutil_check(session->close(session, NULL)); } void obj_cursor(void) { - WT_CURSOR *cursor; - WT_SESSION *session; - int ret; - - testutil_check(conn->open_session(conn, NULL, NULL, &session)); - - if (use_txn) - testutil_check(session->begin_transaction(session, NULL)); - if ((ret = - session->open_cursor(session, uri, NULL, NULL, &cursor)) != 0) { - if (ret != ENOENT && ret != EBUSY) - testutil_die(ret, "session.open_cursor"); - } else - testutil_check(cursor->close(cursor)); - - if (use_txn && - (ret = session->commit_transaction(session, NULL)) != 0 && - ret != EINVAL) - testutil_die(ret, "session.commit cursor"); - testutil_check(session->close(session, NULL)); + WT_CURSOR *cursor; + WT_SESSION *session; + int ret; + + testutil_check(conn->open_session(conn, NULL, NULL, &session)); + + if (use_txn) + testutil_check(session->begin_transaction(session, NULL)); + if ((ret = session->open_cursor(session, uri, NULL, NULL, &cursor)) != 0) { + if (ret != ENOENT && ret != EBUSY) + testutil_die(ret, "session.open_cursor"); + } else + testutil_check(cursor->close(cursor)); + + if (use_txn && (ret = session->commit_transaction(session, NULL)) != 0 && ret != EINVAL) + testutil_die(ret, "session.commit cursor"); + testutil_check(session->close(session, NULL)); } void obj_create(void) { - WT_SESSION *session; - int ret; - - testutil_check(conn->open_session(conn, NULL, NULL, &session)); - - if (use_txn) - testutil_check(session->begin_transaction(session, NULL)); - if ((ret = session->create(session, uri, config)) != 0) - if (ret != EEXIST && ret != EBUSY) - testutil_die(ret, "session.create"); - - if (use_txn && - (ret = session->commit_transaction(session, NULL)) != 0 && - ret != EINVAL) - testutil_die(ret, "session.commit create"); - testutil_check(session->close(session, NULL)); + WT_SESSION *session; + int ret; + + testutil_check(conn->open_session(conn, NULL, NULL, &session)); + + if (use_txn) + testutil_check(session->begin_transaction(session, NULL)); + if ((ret = session->create(session, uri, config)) != 0) + if (ret != EEXIST && ret != EBUSY) + testutil_die(ret, "session.create"); + + if (use_txn && (ret = session->commit_transaction(session, NULL)) != 0 && ret != EINVAL) + testutil_die(ret, "session.commit create"); + testutil_check(session->close(session, NULL)); } void obj_create_unique(int force) { - WT_SESSION *session; - int ret; - char new_uri[64]; - - testutil_check(conn->open_session(conn, NULL, NULL, &session)); - - /* Generate a unique object name. */ - testutil_check(pthread_rwlock_wrlock(&single)); - testutil_check(__wt_snprintf( - new_uri, sizeof(new_uri), "%s.%u", uri, ++uid)); - testutil_check(pthread_rwlock_unlock(&single)); - - if (use_txn) - testutil_check(session->begin_transaction(session, NULL)); - testutil_check(session->create(session, new_uri, config)); - if (use_txn && - (ret = session->commit_transaction(session, NULL)) != 0 && - ret != EINVAL) - testutil_die(ret, "session.commit create unique"); - - __wt_yield(); - if (use_txn) - testutil_check(session->begin_transaction(session, NULL)); - while ((ret = session->drop( - session, new_uri, force ? "force" : NULL)) != 0) - if (ret != EBUSY) - testutil_die(ret, "session.drop: %s", new_uri); - if (use_txn && - (ret = session->commit_transaction(session, NULL)) != 0 && - ret != EINVAL) - testutil_die(ret, "session.commit create unique"); - - testutil_check(session->close(session, NULL)); + WT_SESSION *session; + int ret; + char new_uri[64]; + + testutil_check(conn->open_session(conn, NULL, NULL, &session)); + + /* Generate a unique object name. */ + testutil_check(pthread_rwlock_wrlock(&single)); + testutil_check(__wt_snprintf(new_uri, sizeof(new_uri), "%s.%u", uri, ++uid)); + testutil_check(pthread_rwlock_unlock(&single)); + + if (use_txn) + testutil_check(session->begin_transaction(session, NULL)); + testutil_check(session->create(session, new_uri, config)); + if (use_txn && (ret = session->commit_transaction(session, NULL)) != 0 && ret != EINVAL) + testutil_die(ret, "session.commit create unique"); + + __wt_yield(); + if (use_txn) + testutil_check(session->begin_transaction(session, NULL)); + while ((ret = session->drop(session, new_uri, force ? "force" : NULL)) != 0) + if (ret != EBUSY) + testutil_die(ret, "session.drop: %s", new_uri); + if (use_txn && (ret = session->commit_transaction(session, NULL)) != 0 && ret != EINVAL) + testutil_die(ret, "session.commit create unique"); + + testutil_check(session->close(session, NULL)); } void obj_drop(int force) { - WT_SESSION *session; - int ret; - - testutil_check(conn->open_session(conn, NULL, NULL, &session)); - - if (use_txn) - testutil_check(session->begin_transaction(session, NULL)); - if ((ret = session->drop(session, uri, force ? "force" : NULL)) != 0) - if (ret != ENOENT && ret != EBUSY) - testutil_die(ret, "session.drop"); - - if (use_txn) { - /* - * As the operations are being performed concurrently, - * return value can be ENOENT or EBUSY will set - * error to transaction opened by session. In these - * cases the transaction has to be aborted. - */ - if (ret != ENOENT && ret != EBUSY) - ret = session->commit_transaction(session, NULL); - else - ret = session->rollback_transaction(session, NULL); - if (ret == EINVAL) - testutil_die(ret, "session.commit drop"); - } - testutil_check(session->close(session, NULL)); + WT_SESSION *session; + int ret; + + testutil_check(conn->open_session(conn, NULL, NULL, &session)); + + if (use_txn) + testutil_check(session->begin_transaction(session, NULL)); + if ((ret = session->drop(session, uri, force ? "force" : NULL)) != 0) + if (ret != ENOENT && ret != EBUSY) + testutil_die(ret, "session.drop"); + + if (use_txn) { + /* + * As the operations are being performed concurrently, return value can be ENOENT or EBUSY + * will set error to transaction opened by session. In these cases the transaction has to be + * aborted. + */ + if (ret != ENOENT && ret != EBUSY) + ret = session->commit_transaction(session, NULL); + else + ret = session->rollback_transaction(session, NULL); + if (ret == EINVAL) + testutil_die(ret, "session.commit drop"); + } + testutil_check(session->close(session, NULL)); } void obj_checkpoint(void) { - WT_SESSION *session; - int ret; + WT_SESSION *session; + int ret; - testutil_check(conn->open_session(conn, NULL, NULL, &session)); + testutil_check(conn->open_session(conn, NULL, NULL, &session)); - /* - * Force the checkpoint so it has to be taken. Forced checkpoints can - * race with other metadata operations and return EBUSY - we'd expect - * applications using forced checkpoints to retry on EBUSY. - */ - if ((ret = session->checkpoint(session, "force")) != 0) - if (ret != EBUSY && ret != ENOENT) - testutil_die(ret, "session.checkpoint"); + /* + * Force the checkpoint so it has to be taken. Forced checkpoints can race with other metadata + * operations and return EBUSY - we'd expect applications using forced checkpoints to retry on + * EBUSY. + */ + if ((ret = session->checkpoint(session, "force")) != 0) + if (ret != EBUSY && ret != ENOENT) + testutil_die(ret, "session.checkpoint"); - testutil_check(session->close(session, NULL)); + testutil_check(session->close(session, NULL)); } void obj_rebalance(void) { - WT_SESSION *session; - int ret; + WT_SESSION *session; + int ret; - testutil_check(conn->open_session(conn, NULL, NULL, &session)); + testutil_check(conn->open_session(conn, NULL, NULL, &session)); - if ((ret = session->rebalance(session, uri, NULL)) != 0) - if (ret != ENOENT && ret != EBUSY) - testutil_die(ret, "session.rebalance"); + if ((ret = session->rebalance(session, uri, NULL)) != 0) + if (ret != ENOENT && ret != EBUSY) + testutil_die(ret, "session.rebalance"); - testutil_check(session->close(session, NULL)); + testutil_check(session->close(session, NULL)); } void obj_upgrade(void) { - WT_SESSION *session; - int ret; + WT_SESSION *session; + int ret; - testutil_check(conn->open_session(conn, NULL, NULL, &session)); + testutil_check(conn->open_session(conn, NULL, NULL, &session)); - if ((ret = session->upgrade(session, uri, NULL)) != 0) - if (ret != ENOENT && ret != EBUSY) - testutil_die(ret, "session.upgrade"); + if ((ret = session->upgrade(session, uri, NULL)) != 0) + if (ret != ENOENT && ret != EBUSY) + testutil_die(ret, "session.upgrade"); - testutil_check(session->close(session, NULL)); + testutil_check(session->close(session, NULL)); } void obj_verify(void) { - WT_SESSION *session; - int ret; + WT_SESSION *session; + int ret; - testutil_check(conn->open_session(conn, NULL, NULL, &session)); + testutil_check(conn->open_session(conn, NULL, NULL, &session)); - if ((ret = session->verify(session, uri, NULL)) != 0) - if (ret != ENOENT && ret != EBUSY) - testutil_die(ret, "session.verify"); + if ((ret = session->verify(session, uri, NULL)) != 0) + if (ret != ENOENT && ret != EBUSY) + testutil_die(ret, "session.verify"); - testutil_check(session->close(session, NULL)); + testutil_check(session->close(session, NULL)); } diff --git a/src/third_party/wiredtiger/test/fops/fops.c b/src/third_party/wiredtiger/test/fops/fops.c index 507a8b8838b..e30702ab876 100644 --- a/src/third_party/wiredtiger/test/fops/fops.c +++ b/src/third_party/wiredtiger/test/fops/fops.c @@ -29,19 +29,19 @@ #include "thread.h" static WT_THREAD_RET fop(void *); -static void print_stats(u_int); +static void print_stats(u_int); typedef struct { - int bulk; /* bulk load */ - int bulk_unique; /* bulk load of new file */ - int ckpt; /* session.checkpoint */ - int create; /* session.create */ - int create_unique; /* session.create of new file */ - int cursor; /* session.open_cursor */ - int drop; /* session.drop */ - int rebalance; /* session.rebalance */ - int upgrade; /* session.upgrade */ - int verify; /* session.verify */ + int bulk; /* bulk load */ + int bulk_unique; /* bulk load of new file */ + int ckpt; /* session.checkpoint */ + int create; /* session.create */ + int create_unique; /* session.create of new file */ + int cursor; /* session.open_cursor */ + int drop; /* session.drop */ + int rebalance; /* session.rebalance */ + int upgrade; /* session.upgrade */ + int verify; /* session.verify */ } STATS; static STATS *run_stats; @@ -49,122 +49,120 @@ static STATS *run_stats; void fop_start(u_int nthreads) { - struct timeval start, stop; - wt_thread_t *tids; - double seconds; - u_int i; + struct timeval start, stop; + wt_thread_t *tids; + double seconds; + u_int i; - tids = NULL; /* Silence GCC 4.1 warning. */ + tids = NULL; /* Silence GCC 4.1 warning. */ - /* Create statistics and thread structures. */ - run_stats = dcalloc((size_t)(nthreads), sizeof(*run_stats)); - tids = dcalloc((size_t)(nthreads), sizeof(*tids)); + /* Create statistics and thread structures. */ + run_stats = dcalloc((size_t)(nthreads), sizeof(*run_stats)); + tids = dcalloc((size_t)(nthreads), sizeof(*tids)); - (void)gettimeofday(&start, NULL); + (void)gettimeofday(&start, NULL); - /* Create threads. */ - for (i = 0; i < nthreads; ++i) - testutil_check(__wt_thread_create( - NULL, &tids[i], fop, (void *)(uintptr_t)i)); + /* Create threads. */ + for (i = 0; i < nthreads; ++i) + testutil_check(__wt_thread_create(NULL, &tids[i], fop, (void *)(uintptr_t)i)); - /* Wait for the threads. */ - for (i = 0; i < nthreads; ++i) - testutil_check(__wt_thread_join(NULL, &tids[i])); + /* Wait for the threads. */ + for (i = 0; i < nthreads; ++i) + testutil_check(__wt_thread_join(NULL, &tids[i])); - (void)gettimeofday(&stop, NULL); - seconds = (stop.tv_sec - start.tv_sec) + - (stop.tv_usec - start.tv_usec) * 1e-6; + (void)gettimeofday(&stop, NULL); + seconds = (stop.tv_sec - start.tv_sec) + (stop.tv_usec - start.tv_usec) * 1e-6; - print_stats(nthreads); - printf("timer: %.2lf seconds (%d ops/second)\n", - seconds, (int)((nthreads * nops) / seconds)); + print_stats(nthreads); + printf("timer: %.2lf seconds (%d ops/second)\n", seconds, (int)((nthreads * nops) / seconds)); - free(run_stats); - free(tids); + free(run_stats); + free(tids); } /* * fop -- - * File operation function. + * File operation function. */ static WT_THREAD_RET fop(void *arg) { - STATS *s; - uintptr_t id; - WT_RAND_STATE rnd; - u_int i; - - id = (uintptr_t)arg; - __wt_yield(); /* Get all the threads created. */ - - s = &run_stats[id]; - __wt_random_init(&rnd); - - for (i = 0; i < nops; ++i, __wt_yield()) - switch (__wt_random(&rnd) % 10) { - case 0: - ++s->bulk; - obj_bulk(); - break; - case 1: - ++s->create; - obj_create(); - break; - case 2: - ++s->cursor; - obj_cursor(); - break; - case 3: - ++s->drop; - obj_drop(__wt_random(&rnd) & 1); - break; - case 4: - ++s->ckpt; - obj_checkpoint(); - break; - case 5: - ++s->upgrade; - obj_upgrade(); - break; - case 6: - ++s->rebalance; - obj_rebalance(); - break; - case 7: - ++s->verify; - obj_verify(); - break; - case 8: - ++s->bulk_unique; - obj_bulk_unique(__wt_random(&rnd) & 1); - break; - case 9: - ++s->create_unique; - obj_create_unique(__wt_random(&rnd) & 1); - break; - } - - return (WT_THREAD_RET_VALUE); + STATS *s; + uintptr_t id; + WT_RAND_STATE rnd; + u_int i; + + id = (uintptr_t)arg; + __wt_yield(); /* Get all the threads created. */ + + s = &run_stats[id]; + __wt_random_init(&rnd); + + for (i = 0; i < nops; ++i, __wt_yield()) + switch (__wt_random(&rnd) % 10) { + case 0: + ++s->bulk; + obj_bulk(); + break; + case 1: + ++s->create; + obj_create(); + break; + case 2: + ++s->cursor; + obj_cursor(); + break; + case 3: + ++s->drop; + obj_drop(__wt_random(&rnd) & 1); + break; + case 4: + ++s->ckpt; + obj_checkpoint(); + break; + case 5: + ++s->upgrade; + obj_upgrade(); + break; + case 6: + ++s->rebalance; + obj_rebalance(); + break; + case 7: + ++s->verify; + obj_verify(); + break; + case 8: + ++s->bulk_unique; + obj_bulk_unique(__wt_random(&rnd) & 1); + break; + case 9: + ++s->create_unique; + obj_create_unique(__wt_random(&rnd) & 1); + break; + } + + return (WT_THREAD_RET_VALUE); } /* * print_stats -- - * Display file operation thread stats. + * Display file operation thread stats. */ static void print_stats(u_int nthreads) { - STATS *s; - u_int id; - - s = run_stats; - for (id = 0; id < nthreads; ++id, ++s) - printf( - "%2u:" - "\t" "bulk %3d, checkpoint %3d, create %3d, cursor %3d,\n" - "\t" "drop %3d, rebalance %3d, upgrade %3d, verify %3d\n", - id, s->bulk + s->bulk_unique, s->ckpt, - s->create + s->create_unique, s->cursor, - s->drop, s->rebalance, s->upgrade, s->verify); + STATS *s; + u_int id; + + s = run_stats; + for (id = 0; id < nthreads; ++id, ++s) + printf( + "%2u:" + "\t" + "bulk %3d, checkpoint %3d, create %3d, cursor %3d,\n" + "\t" + "drop %3d, rebalance %3d, upgrade %3d, verify %3d\n", + id, s->bulk + s->bulk_unique, s->ckpt, s->create + s->create_unique, s->cursor, s->drop, + s->rebalance, s->upgrade, s->verify); } diff --git a/src/third_party/wiredtiger/test/fops/t.c b/src/third_party/wiredtiger/test/fops/t.c index ed95c4e29be..6da4a7e748b 100644 --- a/src/third_party/wiredtiger/test/fops/t.c +++ b/src/third_party/wiredtiger/test/fops/t.c @@ -28,23 +28,22 @@ #include "thread.h" -bool use_txn; /* Operations with user txn */ -WT_CONNECTION *conn; /* WiredTiger connection */ -pthread_rwlock_t single; /* Single thread */ -u_int nops; /* Operations */ -const char *uri; /* Object */ -const char *config; /* Object config */ +bool use_txn; /* Operations with user txn */ +WT_CONNECTION *conn; /* WiredTiger connection */ +pthread_rwlock_t single; /* Single thread */ +u_int nops; /* Operations */ +const char *uri; /* Object */ +const char *config; /* Object config */ -static FILE *logfp; /* Log file */ +static FILE *logfp; /* Log file */ static char home[512]; -static int handle_error(WT_EVENT_HANDLER *, WT_SESSION *, int, const char *); -static int handle_message(WT_EVENT_HANDLER *, WT_SESSION *, const char *); -static void onint(int) - WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn)); +static int handle_error(WT_EVENT_HANDLER *, WT_SESSION *, int, const char *); +static int handle_message(WT_EVENT_HANDLER *, WT_SESSION *, const char *); +static void onint(int) WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn)); static void shutdown(void); -static int usage(void); +static int usage(void); static void wt_startup(char *); static void wt_shutdown(void); @@ -54,212 +53,197 @@ extern char *__wt_optarg; int main(int argc, char *argv[]) { - static struct config { - const char *uri; - const char *desc; - const char *config; - } *cp, configs[] = { - { "file:wt", NULL, NULL }, - { "table:wt", NULL, NULL }, + static struct config { + const char *uri; + const char *desc; + const char *config; + } * cp, configs[] = {{"file:wt", NULL, NULL}, {"table:wt", NULL, NULL}, /* Configure for a modest cache size. */ -#define LSM_CONFIG "lsm=(chunk_size=1m,merge_max=2),leaf_page_max=4k" - { "lsm:wt", NULL, LSM_CONFIG }, - { "table:wt", " [lsm]", "type=lsm," LSM_CONFIG }, - { NULL, NULL, NULL } - }; - u_int nthreads; - int ch, cnt, runs; - char *config_open, *working_dir; - - (void)testutil_set_progname(argv); - - testutil_check(pthread_rwlock_init(&single, NULL)); - - nops = 1000; - nthreads = 10; - runs = 1; - use_txn = false; - config_open = working_dir = NULL; - while ((ch = __wt_getopt(progname, argc, argv, "C:h:l:n:r:t:x")) != EOF) - switch (ch) { - case 'C': /* wiredtiger_open config */ - config_open = __wt_optarg; - break; - case 'h': - working_dir = __wt_optarg; - break; - case 'l': /* log */ - if ((logfp = fopen(__wt_optarg, "w")) == NULL) { - fprintf(stderr, - "%s: %s\n", __wt_optarg, strerror(errno)); - return (EXIT_FAILURE); - } - break; - case 'n': /* operations */ - nops = (u_int)atoi(__wt_optarg); - break; - case 'r': /* runs */ - runs = atoi(__wt_optarg); - break; - case 't': - nthreads = (u_int)atoi(__wt_optarg); - break; - case 'x': - use_txn = true; - break; - default: - return (usage()); - } - - argc -= __wt_optind; - if (argc != 0) - return (usage()); - - testutil_work_dir_from_path(home, 512, working_dir); - - /* Clean up on signal. */ - (void)signal(SIGINT, onint); - - printf("%s: process %" PRIu64 "\n", progname, (uint64_t)getpid()); - for (cnt = 1; runs == 0 || cnt <= runs; ++cnt) { - shutdown(); /* Clean up previous runs */ - - for (cp = configs; cp->uri != NULL; ++cp) { - uri = cp->uri; - config = cp->config; - printf("%5d: %u threads on %s%s\n", cnt, nthreads, uri, - cp->desc == NULL ? "" : cp->desc); - - wt_startup(config_open); - - fop_start(nthreads); - - wt_shutdown(); - printf("\n"); - } - } - return (0); +#define LSM_CONFIG "lsm=(chunk_size=1m,merge_max=2),leaf_page_max=4k" + {"lsm:wt", NULL, LSM_CONFIG}, {"table:wt", " [lsm]", "type=lsm," LSM_CONFIG}, + {NULL, NULL, NULL}}; + u_int nthreads; + int ch, cnt, runs; + char *config_open, *working_dir; + + (void)testutil_set_progname(argv); + + testutil_check(pthread_rwlock_init(&single, NULL)); + + nops = 1000; + nthreads = 10; + runs = 1; + use_txn = false; + config_open = working_dir = NULL; + while ((ch = __wt_getopt(progname, argc, argv, "C:h:l:n:r:t:x")) != EOF) + switch (ch) { + case 'C': /* wiredtiger_open config */ + config_open = __wt_optarg; + break; + case 'h': + working_dir = __wt_optarg; + break; + case 'l': /* log */ + if ((logfp = fopen(__wt_optarg, "w")) == NULL) { + fprintf(stderr, "%s: %s\n", __wt_optarg, strerror(errno)); + return (EXIT_FAILURE); + } + break; + case 'n': /* operations */ + nops = (u_int)atoi(__wt_optarg); + break; + case 'r': /* runs */ + runs = atoi(__wt_optarg); + break; + case 't': + nthreads = (u_int)atoi(__wt_optarg); + break; + case 'x': + use_txn = true; + break; + default: + return (usage()); + } + + argc -= __wt_optind; + if (argc != 0) + return (usage()); + + testutil_work_dir_from_path(home, 512, working_dir); + + /* Clean up on signal. */ + (void)signal(SIGINT, onint); + + printf("%s: process %" PRIu64 "\n", progname, (uint64_t)getpid()); + for (cnt = 1; runs == 0 || cnt <= runs; ++cnt) { + shutdown(); /* Clean up previous runs */ + + for (cp = configs; cp->uri != NULL; ++cp) { + uri = cp->uri; + config = cp->config; + printf( + "%5d: %u threads on %s%s\n", cnt, nthreads, uri, cp->desc == NULL ? "" : cp->desc); + + wt_startup(config_open); + + fop_start(nthreads); + + wt_shutdown(); + printf("\n"); + } + } + return (0); } /* * wt_startup -- - * Configure the WiredTiger connection. + * Configure the WiredTiger connection. */ static void wt_startup(char *config_open) { - static WT_EVENT_HANDLER event_handler = { - handle_error, - handle_message, - NULL, - NULL /* Close handler. */ - }; - char config_buf[128]; - - testutil_make_work_dir(home); - - testutil_check(__wt_snprintf(config_buf, sizeof(config_buf), - "create,error_prefix=\"%s\",cache_size=5MB%s%s," - "operation_tracking=(enabled=false)", - progname, - config_open == NULL ? "" : ",", - config_open == NULL ? "" : config_open)); - testutil_check( - wiredtiger_open(home, &event_handler, config_buf, &conn)); + static WT_EVENT_HANDLER event_handler = { + handle_error, handle_message, NULL, NULL /* Close handler. */ + }; + char config_buf[128]; + + testutil_make_work_dir(home); + + testutil_check(__wt_snprintf(config_buf, sizeof(config_buf), + "create,error_prefix=\"%s\",cache_size=5MB%s%s," + "operation_tracking=(enabled=false)", + progname, config_open == NULL ? "" : ",", config_open == NULL ? "" : config_open)); + testutil_check(wiredtiger_open(home, &event_handler, config_buf, &conn)); } /* * wt_shutdown -- - * Flush the file to disk and shut down the WiredTiger connection. + * Flush the file to disk and shut down the WiredTiger connection. */ static void wt_shutdown(void) { - testutil_check(conn->close(conn, NULL)); + testutil_check(conn->close(conn, NULL)); } /* * shutdown -- - * Clean up from previous runs. + * Clean up from previous runs. */ static void shutdown(void) { - testutil_clean_work_dir(home); + testutil_clean_work_dir(home); } static int -handle_error(WT_EVENT_HANDLER *handler, - WT_SESSION *session, int error, const char *errmsg) +handle_error(WT_EVENT_HANDLER *handler, WT_SESSION *session, int error, const char *errmsg) { - (void)(handler); - (void)(session); - (void)(error); + (void)(handler); + (void)(session); + (void)(error); - /* Ignore complaints about missing files. */ - if (error == ENOENT) - return (0); + /* Ignore complaints about missing files. */ + if (error == ENOENT) + return (0); - /* Ignore complaints about failure to open bulk cursors. */ - if (strstr( - errmsg, "bulk-load is only supported on newly created") != NULL) - return (0); + /* Ignore complaints about failure to open bulk cursors. */ + if (strstr(errmsg, "bulk-load is only supported on newly created") != NULL) + return (0); - return (fprintf(stderr, "%s\n", errmsg) < 0 ? -1 : 0); + return (fprintf(stderr, "%s\n", errmsg) < 0 ? -1 : 0); } static int -handle_message(WT_EVENT_HANDLER *handler, - WT_SESSION *session, const char *message) +handle_message(WT_EVENT_HANDLER *handler, WT_SESSION *session, const char *message) { - (void)(handler); - (void)(session); + (void)(handler); + (void)(session); - /* Ignore messages about failing to create forced checkpoints. */ - if (strstr( - message, "forced or named checkpoint") != NULL) - return (0); + /* Ignore messages about failing to create forced checkpoints. */ + if (strstr(message, "forced or named checkpoint") != NULL) + return (0); - if (logfp != NULL) - return (fprintf(logfp, "%s\n", message) < 0 ? -1 : 0); + if (logfp != NULL) + return (fprintf(logfp, "%s\n", message) < 0 ? -1 : 0); - return (printf("%s\n", message) < 0 ? -1 : 0); + return (printf("%s\n", message) < 0 ? -1 : 0); } /* * onint -- - * Interrupt signal handler. + * Interrupt signal handler. */ static void onint(int signo) { - (void)(signo); + (void)(signo); - shutdown(); + shutdown(); - fprintf(stderr, "\n"); - exit(EXIT_FAILURE); + fprintf(stderr, "\n"); + exit(EXIT_FAILURE); } /* * usage -- - * Display usage statement and exit failure. + * Display usage statement and exit failure. */ static int usage(void) { - fprintf(stderr, - "usage: %s " - "[-C wiredtiger-config] [-l log] [-n ops] [-r runs] [-t threads] " - "[-x] \n", - progname); - fprintf(stderr, "%s", - "\t-C specify wiredtiger_open configuration arguments\n" - "\t-h home (default 'WT_TEST')\n" - "\t-l specify a log file\n" - "\t-n set number of operations each thread does\n" - "\t-r set number of runs\n" - "\t-t set number of threads\n" - "\t-x operations within user transaction \n"); - return (EXIT_FAILURE); + fprintf(stderr, + "usage: %s " + "[-C wiredtiger-config] [-l log] [-n ops] [-r runs] [-t threads] " + "[-x] \n", + progname); + fprintf(stderr, "%s", + "\t-C specify wiredtiger_open configuration arguments\n" + "\t-h home (default 'WT_TEST')\n" + "\t-l specify a log file\n" + "\t-n set number of operations each thread does\n" + "\t-r set number of runs\n" + "\t-t set number of threads\n" + "\t-x operations within user transaction \n"); + return (EXIT_FAILURE); } diff --git a/src/third_party/wiredtiger/test/fops/thread.h b/src/third_party/wiredtiger/test/fops/thread.h index d63e882f1f0..feaa795fdc8 100644 --- a/src/third_party/wiredtiger/test/fops/thread.h +++ b/src/third_party/wiredtiger/test/fops/thread.h @@ -30,15 +30,15 @@ #include <signal.h> -extern bool use_txn; /* Operations with user txn */ -extern WT_CONNECTION *conn; /* WiredTiger connection */ +extern bool use_txn; /* Operations with user txn */ +extern WT_CONNECTION *conn; /* WiredTiger connection */ -extern u_int nops; /* Operations per thread */ +extern u_int nops; /* Operations per thread */ -extern const char *uri; /* Object */ -extern const char *config; /* Object config */ +extern const char *uri; /* Object */ +extern const char *config; /* Object config */ -extern pthread_rwlock_t single; /* Single-thread */ +extern pthread_rwlock_t single; /* Single-thread */ void fop_start(u_int); void obj_bulk(void); |