summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/test/format/bulk.c
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2019-07-10 13:26:20 +1000
committerLuke Chen <luke.chen@mongodb.com>2019-07-10 13:26:20 +1000
commit1a50f90ec4418b0e2f9bdadb79ea49684911b0fb (patch)
tree37d119374d45e1f1a508cadf40b3a86ea7e31523 /src/third_party/wiredtiger/test/format/bulk.c
parent40b6fd725ccb0464644b1b9f75b113ebf7ed6a74 (diff)
downloadmongo-1a50f90ec4418b0e2f9bdadb79ea49684911b0fb.tar.gz
Import wiredtiger: 99e0760cc5f11440b21184874d8dd2ae5bde23d6 from branch mongodb-4.2
ref: d86b3a8a33..99e0760cc5 for: 4.2.0-rc3 WT-4502 Assertion checking hazard pointers on page discard is too strong WT-4733 Change test/format to do longer-term repeatable read testing WT-4743 Fix memory leaks and core dumps in page-split error handling WT-4786 Coverity: Invalid format specifiers in printf-like invocations WT-4792 Add stat to track pages queued for eviction after LRU sorting WT-4805 Modify error message verification for test_prepare04.py WT-4812 Fix the Python distribution script for Python3 changes WT-4818 Add debugging of bad read file descriptor when files are missing during recovery WT-4832 Change ordering on shutdown to close LSM and async threads earlier WT-4836 Lower scheduling frequency for endianness compatibility tests WT-4840 WT_CURSOR.modify must require explicit, snapshot-isolation transaction WT-4864 Coverity: Redundant NULL check WT-4866 Coverity: WT_SESSION.import can leak memory WT-4867 Skip assertion when reserved updates are seen WT-4882 Improve checkpoint performance when there are large metadata pages WT-4887 Skip read timestamp required assert during recovery WT-4888 Remove support for Berkeley DB WT-4891 WT_SESSION.verify memory allocation overrun WT-4892 Improve statistics about forced eviction WT-4893 Fix a race between internal page child-page eviction checks and cursors in the tree WT-4895 Fix debug eviction mode so it chooses skew more randomly WT-4898 Don't allow the eviction server to reconcile if it's busy WT-4910 Port Windows SConstruct to Python 3 WT-4918 LSM allocated mutexes leaked in readonly tests WT-4920 Add statistics tracking when eviction server is waiting for page transitions
Diffstat (limited to 'src/third_party/wiredtiger/test/format/bulk.c')
-rw-r--r--src/third_party/wiredtiger/test/format/bulk.c112
1 files changed, 75 insertions, 37 deletions
diff --git a/src/third_party/wiredtiger/test/format/bulk.c b/src/third_party/wiredtiger/test/format/bulk.c
index 196cdb6b7ac..550d5f74d38 100644
--- a/src/third_party/wiredtiger/test/format/bulk.c
+++ b/src/third_party/wiredtiger/test/format/bulk.c
@@ -28,6 +28,49 @@
#include "format.h"
+/*
+ * bulk_begin_transaction --
+ * Begin a bulk-load transaction.
+ */
+static void
+bulk_begin_transaction(WT_SESSION *session)
+{
+ uint64_t ts;
+ char buf[64];
+
+ wiredtiger_begin_transaction(session, "isolation=snapshot");
+ ts = __wt_atomic_addv64(&g.timestamp, 1);
+ testutil_check(__wt_snprintf(
+ buf, sizeof(buf), "read_timestamp=%" PRIx64, ts));
+ testutil_check(session->timestamp_transaction(session, buf));
+}
+
+/*
+ * bulk_commit_transaction --
+ * Commit a bulk-load transaction.
+ */
+static void
+bulk_commit_transaction(WT_SESSION *session)
+{
+ uint64_t ts;
+ char buf[64];
+
+ ts = __wt_atomic_addv64(&g.timestamp, 1);
+ testutil_check(__wt_snprintf(
+ buf, sizeof(buf), "commit_timestamp=%" PRIx64, ts));
+ testutil_check(session->commit_transaction(session, buf));
+}
+
+/*
+ * bulk_rollback_transaction --
+ * Rollback a bulk-load transaction.
+ */
+static void
+bulk_rollback_transaction(WT_SESSION *session)
+{
+ testutil_check(session->rollback_transaction(session, NULL));
+}
+
void
wts_load(void)
{
@@ -42,19 +85,13 @@ wts_load(void)
testutil_check(conn->open_session(conn, NULL, NULL, &session));
- if (g.logging != 0)
- (void)g.wt_api->msg_printf(g.wt_api, session,
- "=============== bulk load start ===============");
+ logop(session, "%s", "=============== bulk load start");
/*
- * No bulk load with data-sources.
- *
* No bulk load with custom collators, the order of insertion will not
* match the collation order.
*/
is_bulk = true;
- if (DATASOURCE("kvsbdb"))
- is_bulk = false;
if (g.c_reverse)
is_bulk = false;
@@ -71,6 +108,9 @@ wts_load(void)
key_gen_init(&key);
val_gen_init(&value);
+ if (g.c_txn_timestamps)
+ bulk_begin_transaction(session);
+
for (;;) {
if (++g.key_cnt > g.c_rows) {
g.key_cnt = g.rows = g.c_rows;
@@ -78,9 +118,15 @@ wts_load(void)
}
/* Report on progress every 100 inserts. */
- if (g.key_cnt % 1000 == 0)
+ if (g.key_cnt % 10000 == 0) {
track("bulk load", g.key_cnt, NULL);
+ if (g.c_txn_timestamps) {
+ bulk_commit_transaction(session);
+ bulk_begin_transaction(session);
+ }
+ }
+
key_gen(&key, g.key_cnt);
val_gen(NULL, &value, g.key_cnt);
@@ -89,34 +135,24 @@ wts_load(void)
if (!is_bulk)
cursor->set_key(cursor, g.key_cnt);
cursor->set_value(cursor, *(uint8_t *)value.data);
- if (g.logging == LOG_OPS)
- (void)g.wt_api->msg_printf(g.wt_api, session,
- "%-10s %" PRIu64 " {0x%02" PRIx8 "}",
- "bulk V",
- g.key_cnt, ((uint8_t *)value.data)[0]);
+ logop(session, "%-10s %" PRIu64 " {0x%02" PRIx8 "}",
+ "bulk", g.key_cnt, ((uint8_t *)value.data)[0]);
break;
case VAR:
if (!is_bulk)
cursor->set_key(cursor, g.key_cnt);
cursor->set_value(cursor, &value);
- if (g.logging == LOG_OPS)
- (void)g.wt_api->msg_printf(g.wt_api, session,
- "%-10s %" PRIu64 " {%.*s}", "bulk V",
- g.key_cnt,
- (int)value.size, (char *)value.data);
+ logop(session, "%-10s %" PRIu64 " {%.*s}", "bulk",
+ g.key_cnt, (int)value.size, (char *)value.data);
break;
case ROW:
cursor->set_key(cursor, &key);
- if (g.logging == LOG_OPS)
- (void)g.wt_api->msg_printf(g.wt_api, session,
- "%-10s %" PRIu64 " {%.*s}", "bulk K",
- g.key_cnt, (int)key.size, (char *)key.data);
cursor->set_value(cursor, &value);
- if (g.logging == LOG_OPS)
- (void)g.wt_api->msg_printf(g.wt_api, session,
- "%-10s %" PRIu64 " {%.*s}", "bulk V",
- g.key_cnt,
- (int)value.size, (char *)value.data);
+ logop(session,
+ "%-10s %" PRIu64 " {%.*s}, {%.*s}", "bulk",
+ g.key_cnt,
+ (int)key.size, (char *)key.data,
+ (int)value.size, (char *)value.data);
break;
}
@@ -132,8 +168,14 @@ wts_load(void)
* extra space once the run starts.
*/
if ((ret = cursor->insert(cursor)) != 0) {
- if (ret != WT_CACHE_FULL)
- testutil_die(ret, "cursor.insert");
+ testutil_assert(
+ ret == WT_CACHE_FULL || ret == WT_ROLLBACK);
+
+ if (g.c_txn_timestamps) {
+ bulk_rollback_transaction(session);
+ bulk_begin_transaction(session);
+ }
+
g.rows = --g.key_cnt;
g.c_rows = (uint32_t)g.key_cnt;
@@ -143,18 +185,14 @@ wts_load(void)
g.c_delete_pct += 20;
break;
}
-
-#ifdef HAVE_BERKELEY_DB
- if (SINGLETHREADED)
- bdb_insert(key.data, key.size, value.data, value.size);
-#endif
}
+ if (g.c_txn_timestamps)
+ bulk_commit_transaction(session);
+
testutil_check(cursor->close(cursor));
- if (g.logging != 0)
- (void)g.wt_api->msg_printf(g.wt_api, session,
- "=============== bulk load stop ===============");
+ logop(session, "%s", "=============== bulk load stop");
testutil_check(session->close(session, NULL));