diff --cc test/format/ops.c index e03f97cc2,348e37a38..000000000 --- a/test/format/ops.c +++ b/test/format/ops.c @@@ -26,6 -26,6 +26,7 @@@ * OTHER DEALINGS IN THE SOFTWARE. */ ++#define BDB 1 #include "format.h" static int col_insert(TINFO *, WT_CURSOR *); @@@ -1070,6 -1080,8 +1081,7 @@@ update_instead_of_chosen_op * a random direction. */ if (positioned) { - testutil_assert(F_ISSET(cursor, WT_CURSTD_KEY_INT)); + next = mmrand(&tinfo->rnd, 0, 1) == 1; j = mmrand(&tinfo->rnd, 1, 100); for (i = 0; i < j; ++i) { @@@ -1270,10 -1287,10 +1287,11 @@@ read_row_worker /* Log the operation */ if (g.logging == LOG_OPS) (void)g.wt_api->msg_printf(g.wt_api, -- session, "%-10s%" PRIu64, "read", keyno); ++ session, "%-10s:%s:%" PRIu64, "read", ret ? "n" : "y", ++ keyno); #ifdef HAVE_BERKELEY_DB - if (!USE_BERKELEY_DB) + if (!SINGLETHREADED) return (ret); /* Retrieve the BDB value. */ @@@ -1310,7 -1327,47 +1328,87 @@@ read_row(TINFO *tinfo, WT_CURSOR *curso { /* 25% of the time we call search-near. */ return (read_row_worker(cursor, tinfo->keyno, - tinfo->key, tinfo->value, mmrand(&tinfo->rnd, 0, 3) == 1)); + tinfo->key, tinfo->value, mmrand(&tinfo->rnd, 0, 3))); + } + + /* + * compare_db -- + * Compare the content of BerkeleyDB and WiredTiger databases. + */ + static int + compare_db(TINFO *tinfo, WT_CURSOR *wt_cursor) + { ++ DB *db = g.bdb; ++ //DBC *dbc = g.dbc; ++ DBC *dbc = NULL; ++ DBT key,value; + WT_ITEM wt_key; ++ ++ bool start = true; ++ char *p; + int ret, step_count = 0; ++ size_t i, len; + - if (!SINGLETHREADED) ++ WT_UNUSED(tinfo); ++ ++ if (!SINGLETHREADED || db == NULL) + return (0); + ++ /* Initialize BerkeleyDB key and value. */ ++ len = (100 * 1024); ++ p = dmalloc(len); ++ for (i =0; i < len; ++i) ++ p[i] = "abcdefghijklmnopqrstuvwxyz"[i%26]; ++ key.data = p; ++ key.ulen = (u_int32_t)len; ++ key.flags = DB_DBT_USERMEM; ++ ++ p = dmalloc(len); ++ for (i =0; i < len; ++i) ++ p[i] = "abcdefghijklmnopqrstuvwxyz"[i%26]; ++ value.data = p; ++ value.ulen = (u_int32_t)len; ++ value.flags = DB_DBT_USERMEM; ++ + /* + * Move to the start of the tree, and setup cursors to do comparison + * of the content between WiredTiger and BerkeleyDB. + */ + testutil_check(wt_cursor->reset(wt_cursor)); - testutil_check(wt_cursor->next(wt_cursor)); - testutil_check(wt_cursor->get_key(wt_cursor, &wt_key)); - testutil_check(__wt_buf_set((WT_SESSION_IMPL *) - wt_cursor->session, tinfo->key, wt_key.data, wt_key.size)); - tinfo->keyno = strtoul((char*)tinfo->key->data, NULL, 10); - (void)g.wt_api->msg_printf(g.wt_api, wt_cursor->session, - "Setting the key number to: %" PRIu64 "\n", tinfo->keyno); - /* Do a read operation so the last key is setup. */ - ret = read_row(tinfo, wt_cursor); - if (ret == WT_NOTFOUND) { - (void)g.wt_api->msg_printf(g.wt_api, - wt_cursor->session, "comparison failed with WT_NOTFOUND\n"); - ret = 0; ++ ret = db->cursor(db, NULL, &dbc, 0); ++ assert(ret == 0); ++ ++ while (wt_cursor->next(wt_cursor) == 0) { ++ wt_cursor->get_key(wt_cursor, &wt_key); ++ ret = dbc->get(dbc, &key, &value, start ? DB_FIRST : DB_NEXT); ++ if (wt_key.size != key.size || ++ memcmp(wt_key.data, key.data, key.size) != 0) { ++ (void)g.wt_api->msg_printf(g.wt_api, wt_cursor->session, ++ "compare_db MISMATCH-1 : {%s.*s}, {%s.*s}\n", ++ (int)wt_key.size, wt_key.data, ++ (int)key.size, key.data); ++ ++ abort(); ++ } ++ start = false; ++ ++step_count; ++ } ++ ++ /* Verify Berkeley DB has no more records. */ ++ if (DB_NOTFOUND != dbc->get(dbc, &key, &value, DB_NEXT)) { ++ (void)g.wt_api->msg_printf(g.wt_api, wt_cursor->session, ++ "compare_db Berkeley DB has more keys : {%s.*s}\n", ++ (int)key.size, key.data); ++ abort(); + } - testutil_check(ret); - while (nextprev(tinfo, wt_cursor, 1) == 0) { ++step_count; } + - (void)g.wt_api->msg_printf(g.wt_api, wt_cursor->session, - "format compare_db check step count: %d\n", step_count); ++ if (g.logging == LOG_OPS) ++ (void)g.wt_api->msg_printf(g.wt_api, wt_cursor->session, ++ "compare_db : %d \n", step_count); ++ free(key.data); ++ free(value.data); ++ assert(dbc->close(dbc) == 0); + return (0); } /* @@@ -1331,6 -1388,6 +1429,7 @@@ nextprev(TINFO *tinfo, WT_CURSOR *curso keyno = 0; which = next ? "WT_CURSOR.next" : "WT_CURSOR.prev"; ++ testutil_assert(F_ISSET(cursor, WT_CURSTD_KEY_INT)); switch (ret = (next ? cursor->next(cursor) : cursor->prev(cursor))) { case 0: switch (g.type) { @@@ -1691,6 -1748,6 +1790,15 @@@ row_truncate(TINFO *tinfo, WT_CURSOR *c */ testutil_assert(tinfo->keyno != 0 || tinfo->last != 0); ++ if (tinfo->keyno != 0 && tinfo->last != 0) ++ switch(mmrand(NULL, 1, 3)) { ++ case 1: ++ tinfo->keyno = 0; ++ case 2: ++ case 3: ++ break; ++ } ++ c2 = NULL; if (tinfo->keyno == 0) { key_gen(tinfo->key, tinfo->last); diff --git a/test/format/bdb.c b/test/format/bdb.c index f174fb63f..df0a9ff78 100644 --- a/test/format/bdb.c +++ b/test/format/bdb.c @@ -129,7 +129,7 @@ bdb_np(bool next, *notfoundp = 0; /* Match WT reset behavior so nextprev keeps working. */ - if (g.dbc_reset) { + if ((0) && g.dbc_reset) { ret = dbc->get(dbc, &key, &value, next ? DB_FIRST : DB_LAST); g.dbc_reset = false; } else diff --git a/test/format/bulk.c b/test/format/bulk.c index 5ee89ce05..4f2070374 100644 --- a/test/format/bulk.c +++ b/test/format/bulk.c @@ -145,7 +145,7 @@ wts_load(void) } #ifdef HAVE_BERKELEY_DB - if (USE_BERKELEY_DB) + if (SINGLETHREADED) bdb_insert(key.data, key.size, value.data, value.size); #endif } diff --git a/test/format/format.h b/test/format/format.h index fddce386b..e1d84cfd8 100644 --- a/test/format/format.h +++ b/test/format/format.h @@ -85,10 +85,10 @@ * The problem with deleting records is salvage restores deleted records if a * page splits leaving a deleted record on one side of the split, so we cannot * depend on correctness in that case. - */ #define USE_BERKELEY_DB \ ((g.c_threads == 1) && \ (!g.c_salvage || (g.c_delete_pct == 0 && g.c_truncate == 0))) +*/ #define FORMAT_OPERATION_REPS 3 /* 3 thread operations sets */ diff --git a/test/format/t.c b/test/format/t.c index 86e9ea513..e7a8352c0 100644 --- a/test/format/t.c +++ b/test/format/t.c @@ -185,7 +185,7 @@ main(int argc, char *argv[]) track("starting up", 0ULL, NULL); #ifdef HAVE_BERKELEY_DB - if (USE_BERKELEY_DB) + if (SINGLETHREADED) bdb_open(); /* Initial file config */ #endif wts_open(g.home, true, &g.wts_conn); @@ -226,7 +226,7 @@ main(int argc, char *argv[]) track("shutting down", 0ULL, NULL); #ifdef HAVE_BERKELEY_DB - if (USE_BERKELEY_DB) + if (SINGLETHREADED) bdb_close(); #endif wts_close(); diff --git a/test/format/wts.c b/test/format/wts.c index 5957fd863..9cac605f5 100644 --- a/test/format/wts.c +++ b/test/format/wts.c @@ -515,7 +515,7 @@ wts_dump_bdb_compare(const char *tag) if (g.c_in_memory != 0) return; /* Check whether data content can be compared with Berkeley DB. */ - if (!USE_BERKELEY_DB) + if (!SINGLETHREADED || g.c_delete_pct != 0) return; if (DATASOURCE("helium") || DATASOURCE("kvsbdb")) return;