diff --git a/examples/c/ex_access.c b/examples/c/ex_access.c index df8b0b4..b913da2 100644 --- a/examples/c/ex_access.c +++ b/examples/c/ex_access.c @@ -32,6 +32,29 @@ static const char *home; +void *checkpoint_thread(void *); + +void * +checkpoint_thread(void *arg) +{ + WT_CONNECTION *conn; + WT_SESSION *session; + int ret; + + conn = (WT_CONNECTION *)arg; + + conn->open_session(conn, NULL, NULL, &session); + + while (1) { + fprintf(stderr, "Calling checkpoint!!!\n"); + if ((ret = session->checkpoint(session, NULL)) != 0) { + fprintf(stderr, "Error from checkpoint: %d\n", ret); + exit (1); + } + } + return (NULL); +} + static void access_example(void) { @@ -40,19 +63,35 @@ access_example(void) WT_CURSOR *cursor; WT_SESSION *session; const char *key, *value; - int ret; + int i, ret; + char uri[512]; + pthread_t tid; /* Open a connection to the database, creating it if necessary. */ error_check(wiredtiger_open(home, NULL, "create", &conn)); + pthread_create(&tid, NULL, checkpoint_thread, conn); /* Open a session handle for the database. */ error_check(conn->open_session(conn, NULL, NULL, &session)); /*! [access example connection] */ /*! [access example table create] */ - error_check(session->create( - session, "table:access", "key_format=S,value_format=S")); + for (i = 0; i < 5; i++) { + printf("About to call create!!!\n"); +#define ENABLE_TRANSACTIONS 1 +#if ENABLE_TRANSACTIONS + session->begin_transaction(session, "isolation=snapshot"); +#endif + memset(uri, 0, sizeof(uri)); + sprintf(uri, "table:access%d", i); + error_check(session->create( + session, uri, "key_format=q,value_format=u,type=file")); +#if ENABLE_TRANSACTIONS + session->commit_transaction(session, NULL); +#endif + } /*! [access example table create] */ + return ; /*! [access example cursor open] */ error_check(session->open_cursor( diff --git a/src/schema/schema_create.c b/src/schema/schema_create.c index 596975e..7ff8091 100644 --- a/src/schema/schema_create.c +++ b/src/schema/schema_create.c @@ -691,21 +691,27 @@ __wt_schema_create( */ WT_RET(__wt_meta_track_on(session)); - if (WT_PREFIX_MATCH(uri, "colgroup:")) + if (WT_PREFIX_MATCH(uri, "colgroup:")) { + __wt_yield(); ret = __create_colgroup(session, uri, exclusive, config); - else if (WT_PREFIX_MATCH(uri, "file:")) + } else if (WT_PREFIX_MATCH(uri, "file:")) { + __wt_yield(); ret = __create_file(session, uri, exclusive, config); - else if (WT_PREFIX_MATCH(uri, "lsm:")) + } else if (WT_PREFIX_MATCH(uri, "lsm:")) { + __wt_yield(); ret = __wt_lsm_tree_create(session, uri, exclusive, config); - else if (WT_PREFIX_MATCH(uri, "index:")) + } else if (WT_PREFIX_MATCH(uri, "index:")) { + __wt_yield(); ret = __create_index(session, uri, exclusive, config); - else if (WT_PREFIX_MATCH(uri, "table:")) + } else if (WT_PREFIX_MATCH(uri, "table:")) { + __wt_yield(); ret = __create_table(session, uri, exclusive, config); - else if ((dsrc = __wt_schema_get_source(session, uri)) != NULL) + } else if ((dsrc = __wt_schema_get_source(session, uri)) != NULL) { + __wt_yield(); ret = dsrc->create == NULL ? __wt_object_unsupported(session, uri) : __create_data_source(session, uri, config, dsrc); - else + } else ret = __wt_bad_object_type(session, uri); session->dhandle = NULL; diff --git a/src/txn/txn_ckpt.c b/src/txn/txn_ckpt.c index e54ec99..b01d07a 100644 --- a/src/txn/txn_ckpt.c +++ b/src/txn/txn_ckpt.c @@ -304,12 +304,17 @@ __wt_checkpoint_get_handles(WT_SESSION_IMPL *session, const char *cfg[]) bool metadata_race; WT_ASSERT(session, !F_ISSET(&session->txn, WT_TXN_ERROR)); + __wt_sleep(0, 1000); WT_RET(__wt_metadata_cursor(session, &meta_cursor)); meta_cursor->set_key(meta_cursor, session->dhandle->name); ret = __wt_curfile_insert_check(meta_cursor); if (ret == WT_ROLLBACK) { metadata_race = true; + fprintf(stderr, "Danger Will Robinson!\n"); + exit(1); +#if 0 ret = 0; +#endif } else metadata_race = false; WT_TRET(__wt_metadata_cursor_release(session, &meta_cursor));