diff options
Diffstat (limited to 'src/third_party/wiredtiger/test/format/hs.c')
-rw-r--r-- | src/third_party/wiredtiger/test/format/hs.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/third_party/wiredtiger/test/format/hs.c b/src/third_party/wiredtiger/test/format/hs.c index e5d40e6256b..55b298f20e7 100644 --- a/src/third_party/wiredtiger/test/format/hs.c +++ b/src/third_party/wiredtiger/test/format/hs.c @@ -38,7 +38,7 @@ hs_cursor(void *arg) WT_CONNECTION *conn; WT_CURSOR *cursor; WT_DECL_RET; - WT_ITEM hs_key, hs_value; + WT_ITEM hs_key, hs_value, key; WT_SESSION *session; wt_timestamp_t hs_durable_timestamp, hs_start_ts, hs_stop_durable_ts; uint64_t hs_counter, hs_upd_type; @@ -61,6 +61,7 @@ hs_cursor(void *arg) memset(&hs_key, 0, sizeof(hs_key)); memset(&hs_value, 0, sizeof(hs_value)); + memset(&key, 0, sizeof(key)); hs_start_ts = 0; /* [-Wconditional-uninitialized] */ hs_counter = 0; /* [-Wconditional-uninitialized] */ hs_btree_id = 0; /* [-Wconditional-uninitialized] */ @@ -81,13 +82,16 @@ hs_cursor(void *arg) /* Search to the last-known location. */ if (!restart) { - cursor->set_key(cursor, hs_btree_id, &hs_key, hs_start_ts, hs_counter); + cursor->set_key(cursor, hs_btree_id, &key, hs_start_ts, hs_counter); ret = cursor->search_near(cursor, &exact); testutil_assert(ret == 0 || ret == WT_NOTFOUND); } - /* Get some more key/value pairs. */ - for (i = mmrand(NULL, 0, 1000); i > 0; --i) { + /* + * Get some more key/value pairs. Always retrieve at least one key, that ensures we have a + * valid key when we copy it to start the next run. + */ + for (i = mmrand(NULL, 1, 1000); i > 0; --i) { if ((ret = cursor->next(cursor)) == 0) { testutil_check( cursor->get_key(cursor, &hs_btree_id, &hs_key, &hs_start_ts, &hs_counter)); @@ -104,7 +108,7 @@ hs_cursor(void *arg) * Otherwise, reset so we'll start over. */ if (ret == 0) { - testutil_check(__wt_buf_grow(CUR2S(cursor), &hs_key, hs_key.size)); + testutil_check(__wt_buf_set(CUR2S(cursor), &key, hs_key.data, hs_key.size)); restart = false; } else restart = true; @@ -118,6 +122,7 @@ hs_cursor(void *arg) break; } + __wt_buf_free(CUR2S(cursor), &key); testutil_check(session->close(session, NULL)); return (WT_THREAD_RET_VALUE); |