Skip to content

Commit f7f28d5

Browse files
etienneptlEvergreen Agent
authored andcommitted
Import wiredtiger: 7813885d2cf3b975d03bfcb7499defb16cae26fc from branch mongodb-master
ref: b97d0cdf23..7813885d2c for: 5.1.0 WT-8121 Create a long running stress test which inserts a large amount of data over a long period
1 parent e07873f commit f7f28d5

File tree

11 files changed

+296
-44
lines changed

11 files changed

+296
-44
lines changed

src/third_party/wiredtiger/dist/test_data.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@ def __ge__(self, other):
214214
]
215215

216216
methods = {
217+
'base_test' : Method(test_config),
218+
'burst_inserts' : Method(test_config + [
219+
Config("burst_duration", 90, r'''
220+
How long the insertions will occur for.''')]),
217221
'example_test' : Method(test_config),
218222
'hs_cleanup' : Method(test_config),
219-
'base_test' : Method(test_config),
220223
}

src/third_party/wiredtiger/import.data

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"vendor": "wiredtiger",
33
"github": "wiredtiger/wiredtiger.git",
44
"branch": "mongodb-master",
5-
"commit": "b97d0cdf23ad071e6dc02902293942ec3f9d07a3"
5+
"commit": "7813885d2cf3b975d03bfcb7499defb16cae26fc"
66
}

src/third_party/wiredtiger/src/config/test_config.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,20 @@ static const WT_CONFIG_CHECK confchk_base_test[] = {
8585
{"workload_tracking", "category", NULL, NULL, confchk_workload_tracking_subconfigs, 2},
8686
{NULL, NULL, NULL, NULL, NULL, 0}};
8787

88+
static const WT_CONFIG_CHECK confchk_burst_inserts[] = {
89+
{"burst_duration", "string", NULL, NULL, NULL, 0},
90+
{"cache_size_mb", "int", NULL, "min=0,max=100000000000", NULL, 0},
91+
{"checkpoint_manager", "category", NULL, NULL, confchk_checkpoint_manager_subconfigs, 2},
92+
{"compression_enabled", "boolean", NULL, NULL, NULL, 0},
93+
{"duration_seconds", "int", NULL, "min=0,max=1000000", NULL, 0},
94+
{"enable_logging", "boolean", NULL, NULL, NULL, 0},
95+
{"runtime_monitor", "category", NULL, NULL, confchk_runtime_monitor_subconfigs, 5},
96+
{"statistics_config", "category", NULL, NULL, confchk_statistics_config_subconfigs, 2},
97+
{"timestamp_manager", "category", NULL, NULL, confchk_timestamp_manager_subconfigs, 4},
98+
{"workload_generator", "category", NULL, NULL, confchk_workload_generator_subconfigs, 6},
99+
{"workload_tracking", "category", NULL, NULL, confchk_workload_tracking_subconfigs, 2},
100+
{NULL, NULL, NULL, NULL, NULL, 0}};
101+
88102
static const WT_CONFIG_CHECK confchk_example_test[] = {
89103
{"cache_size_mb", "int", NULL, "min=0,max=100000000000", NULL, 0},
90104
{"checkpoint_manager", "category", NULL, NULL, confchk_checkpoint_manager_subconfigs, 2},
@@ -130,6 +144,25 @@ static const WT_CONFIG_ENTRY config_entries[] = {
130144
"min=0),thread_count=0,value_size=5)),"
131145
"workload_tracking=(enabled=true,op_rate=1s)",
132146
confchk_base_test, 10},
147+
{"burst_inserts",
148+
"burst_duration=90,cache_size_mb=0,"
149+
"checkpoint_manager=(enabled=false,op_rate=1s),"
150+
"compression_enabled=false,duration_seconds=0,"
151+
"enable_logging=false,runtime_monitor=(enabled=true,op_rate=1s,"
152+
"postrun_statistics=[],stat_cache_size=(enabled=false,limit=0),"
153+
"stat_db_size=(enabled=false,limit=0)),"
154+
"statistics_config=(enable_logging=true,type=all),"
155+
"timestamp_manager=(enabled=true,oldest_lag=1,op_rate=1s,"
156+
"stable_lag=1),workload_generator=(enabled=true,"
157+
"insert_config=(key_size=5,op_rate=1s,ops_per_transaction=(max=1,"
158+
"min=0),thread_count=0,value_size=5),op_rate=1s,"
159+
"populate_config=(collection_count=1,key_count_per_collection=0,"
160+
"key_size=5,thread_count=1,value_size=5),read_config=(op_rate=1s,"
161+
"ops_per_transaction=(max=1,min=0),thread_count=0),"
162+
"update_config=(key_size=5,op_rate=1s,ops_per_transaction=(max=1,"
163+
"min=0),thread_count=0,value_size=5)),"
164+
"workload_tracking=(enabled=true,op_rate=1s)",
165+
confchk_burst_inserts, 11},
133166
{"example_test",
134167
"cache_size_mb=0,checkpoint_manager=(enabled=false,op_rate=1s),"
135168
"compression_enabled=false,duration_seconds=0,"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Configuration for burst_inserts.
2+
# need to be defined.
3+
duration_seconds=5,
4+
cache_size_mb=250
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Used as a stress test for the framework.
2+
duration_seconds=14400,
3+
cache_size_mb=2000,
4+
checkpoint_manager=
5+
(
6+
enabled=true,
7+
op_rate=60s
8+
),
9+
runtime_monitor=
10+
(
11+
enabled=false
12+
),
13+
timestamp_manager=
14+
(
15+
enabled=true,
16+
oldest_lag=10,
17+
stable_lag=10
18+
),
19+
workload_generator=
20+
(
21+
populate_config=
22+
(
23+
collection_count=160,
24+
key_count_per_collection=500,
25+
key_size=200,
26+
thread_count=40,
27+
value_size=20000
28+
),
29+
insert_config=
30+
(
31+
key_size=200,
32+
op_rate=10s,
33+
ops_per_transaction=(max=2000,min=1000),
34+
thread_count=40,
35+
value_size=20000
36+
)
37+
),
38+
workload_tracking=
39+
(
40+
enabled=false,
41+
)

src/third_party/wiredtiger/test/cppsuite/test_harness/test.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,12 @@ class test : public database_operation {
8080
timestamp_manager *get_timestamp_manager();
8181
thread_manager *get_thread_manager();
8282

83+
protected:
84+
configuration *_config;
85+
8386
private:
8487
const test_args &_args;
8588
std::vector<component *> _components;
86-
configuration *_config;
8789
checkpoint_manager *_checkpoint_manager = nullptr;
8890
runtime_monitor *_runtime_monitor = nullptr;
8991
thread_manager *_thread_manager = nullptr;

src/third_party/wiredtiger/test/cppsuite/test_harness/workload/database_operation.cxx

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ populate_worker(thread_context *tc)
4949
* is closed, WiredTiger APIs close the cursors too.
5050
*/
5151
scoped_cursor cursor = tc->session.open_scoped_cursor(coll.name.c_str());
52-
for (uint64_t i = 0; i < tc->key_count; ++i) {
53-
/* Start a txn. */
52+
uint64_t j = 0;
53+
while (j < tc->key_count) {
5454
tc->transaction.begin();
55-
if (tc->insert(cursor, coll.id, i)) {
56-
/* We failed to insert, rollback our transaction and retry. */
55+
if (tc->insert(cursor, coll.id, j)) {
56+
if (tc->transaction.commit()) {
57+
++j;
58+
}
59+
} else {
5760
tc->transaction.rollback();
58-
--i;
59-
continue;
6061
}
61-
tc->transaction.commit();
6262
}
6363
}
6464
logger::log_msg(LOG_TRACE, "Populate: thread {" + std::to_string(tc->id) + "} finished");
@@ -161,35 +161,35 @@ database_operation::insert_operation(thread_context *tc)
161161
/* Collection cursor. */
162162
auto &cc = ccv[counter];
163163
while (tc->transaction.active() && tc->running()) {
164-
/* Insert a key value pair. */
165-
bool rollback_required = tc->insert(cc.cursor, cc.coll.id, start_key + added_count);
166-
if (!rollback_required) {
164+
/* Insert a key value pair, rolling back the transaction if required. */
165+
if (!tc->insert(cc.cursor, cc.coll.id, start_key + added_count)) {
166+
added_count = 0;
167+
tc->transaction.rollback();
168+
} else {
167169
added_count++;
168170
if (tc->transaction.can_commit()) {
169-
rollback_required = tc->transaction.commit();
170-
if (!rollback_required)
171+
if (tc->transaction.commit()) {
171172
/*
172173
* We need to inform the database model that we've added these keys as some
173174
* other thread may rely on the key_count data. Only do so if we
174175
* successfully committed.
175176
*/
176177
cc.coll.increase_key_count(added_count);
178+
} else {
179+
added_count = 0;
180+
}
177181
}
178182
}
179183

180-
if (rollback_required) {
181-
added_count = 0;
182-
tc->transaction.rollback();
183-
}
184-
185184
/* Sleep the duration defined by the op_rate. */
186185
tc->sleep();
187186
}
188187
/* Reset our cursor to avoid pinning content. */
189188
testutil_check(cc.cursor->reset(cc.cursor.get()));
190189
counter++;
191-
if (counter >= collections_per_thread)
190+
if (counter == collections_per_thread)
192191
counter = 0;
192+
testutil_assert(counter < collections_per_thread);
193193
}
194194
/* Make sure the last transaction is rolled back now the work is finished. */
195195
if (tc->transaction.active())
@@ -278,17 +278,16 @@ database_operation::update_operation(thread_context *tc)
278278
/* Choose a random key to update. */
279279
uint64_t key_id =
280280
random_generator::instance().generate_integer<uint64_t>(0, coll.get_key_count() - 1);
281-
bool rollback_required = tc->update(cursor, coll.id, tc->key_to_string(key_id));
281+
if (!tc->update(cursor, coll.id, tc->key_to_string(key_id))) {
282+
tc->transaction.rollback();
283+
}
282284

283285
/* Reset our cursor to avoid pinning content. */
284286
testutil_check(cursor->reset(cursor.get()));
285287

286288
/* Commit the current transaction if we're able to. */
287-
if (!rollback_required && tc->transaction.can_commit())
288-
rollback_required = tc->transaction.commit();
289-
290-
if (rollback_required)
291-
tc->transaction.rollback();
289+
if (tc->transaction.can_commit())
290+
tc->transaction.commit();
292291
}
293292

294293
/* Make sure the last operation is rolled back now the work is finished. */

src/third_party/wiredtiger/test/cppsuite/test_harness/workload/thread_context.cxx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "../core/configuration.h"
3030
#include "../timestamp_manager.h"
3131
#include "../util/api_const.h"
32+
#include "../util/logger.h"
3233
#include "workload_tracking.h"
3334
#include "random_generator.h"
3435
#include "thread_context.h"
@@ -81,22 +82,23 @@ transaction_context::try_begin(const std::string &config)
8182
begin(config);
8283
}
8384

84-
/* It's possible to receive rollback in commit which is handled internally. */
85+
/*
86+
* It's possible to receive rollback in commit, when this happens the API will rollback the
87+
* transaction internally.
88+
*/
8589
bool
8690
transaction_context::commit(const std::string &config)
8791
{
8892
WT_DECL_RET;
89-
testutil_assert(_in_txn);
93+
testutil_assert(_in_txn && !_needs_rollback);
9094
if ((ret = _session->commit_transaction(_session, config.empty() ? nullptr : config.c_str())) !=
9195
0) {
9296
logger::log_msg(LOG_WARN,
9397
"Failed to commit transaction in commit, received error code: " + std::to_string(ret));
94-
_needs_rollback = true;
95-
} else {
96-
_op_count = 0;
97-
_in_txn = false;
9898
}
99-
return (_needs_rollback);
99+
_op_count = 0;
100+
_in_txn = false;
101+
return (ret == 0);
100102
}
101103

102104
void
@@ -200,7 +202,7 @@ thread_context::update(scoped_cursor &cursor, uint64_t collection_id, const std:
200202
if (ret != 0) {
201203
if (ret == WT_ROLLBACK) {
202204
transaction.set_needs_rollback(true);
203-
return (true);
205+
return (false);
204206
} else
205207
testutil_die(ret, "unhandled error while trying to update a key");
206208
}
@@ -209,13 +211,13 @@ thread_context::update(scoped_cursor &cursor, uint64_t collection_id, const std:
209211
if (ret != 0) {
210212
if (ret == WT_ROLLBACK) {
211213
transaction.set_needs_rollback(true);
212-
return (true);
214+
return (false);
213215
} else
214216
testutil_die(
215217
ret, "unhandled error while trying to save an update to the tracking table");
216218
}
217219
transaction.add_op();
218-
return (false);
220+
return (true);
219221
}
220222

221223
bool
@@ -250,7 +252,7 @@ thread_context::insert(
250252
if (ret != 0) {
251253
if (ret == WT_ROLLBACK) {
252254
transaction.set_needs_rollback(true);
253-
return (true);
255+
return (false);
254256
} else
255257
testutil_die(ret, "unhandled error while trying to insert a key");
256258
}
@@ -259,13 +261,13 @@ thread_context::insert(
259261
if (ret != 0) {
260262
if (ret == WT_ROLLBACK) {
261263
transaction.set_needs_rollback(true);
262-
return (true);
264+
return (false);
263265
} else
264266
testutil_die(
265267
ret, "unhandled error while trying to save an insert to the tracking table");
266268
}
267269
transaction.add_op();
268-
return (false);
270+
return (true);
269271
}
270272

271273
void

src/third_party/wiredtiger/test/cppsuite/test_harness/workload/thread_context.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class transaction_context {
7272
/* Begin a transaction if we are not currently in one. */
7373
void try_begin(const std::string &config = "");
7474
/*
75-
* Commit a transaction and return true if a rollback is required.
75+
* Commit a transaction and return true if the commit was successful.
7676
*/
7777
bool commit(const std::string &config = "");
7878
/* Rollback a transaction, failure will abort the test. */
@@ -136,15 +136,17 @@ class thread_context {
136136
/*
137137
* Generic update function, takes a collection_id and key, will generate the value.
138138
*
139-
* Returns true if a rollback is required.
139+
* Return true if the operation was successful, a return value of false implies the transaction
140+
* needs to be rolled back.
140141
*/
141142
bool update(scoped_cursor &cursor, uint64_t collection_id, const std::string &key);
142143

143144
/*
144145
* Generic insert function, takes a collection_id and key_id, will generate the value. If a
145146
* timestamp is not specified, the timestamp manager will generate one.
146147
*
147-
* Returns true if a rollback is required.
148+
* Return true if the operation was successful, a return value of false implies the transaction
149+
* needs to be rolled back.
148150
*/
149151
bool insert(
150152
scoped_cursor &cursor, uint64_t collection_id, uint64_t key_id, wt_timestamp_t ts = 0);

0 commit comments

Comments
 (0)