Skip to content

Commit 9a8d3ac

Browse files
lukechEvergreen Agent
authored andcommitted
Import wiredtiger: 2214855bafc4d9d60d853fb58273558a7b5fed7e from branch mongodb-master
ref: 150ef060dc..2214855baf for: 7.3.0-rc0 WT-12009 Add error code in Workgen exceptions
1 parent 7d7fdaf commit 9a8d3ac

File tree

2 files changed

+51
-40
lines changed

2 files changed

+51
-40
lines changed

src/third_party/wiredtiger/bench/workgen/workgen.cpp

Lines changed: 50 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,9 @@ int
246246
WorkloadRunner::start_table_idle_cycle(WT_CONNECTION *conn)
247247
{
248248
WT_SESSION *session;
249-
if (conn->open_session(conn, nullptr, nullptr, &session) != 0) {
250-
THROW("Error opening a session.");
249+
int ret = conn->open_session(conn, nullptr, nullptr, &session);
250+
if (ret != 0) {
251+
THROW_ERRNO(ret, "Error opening a session.");
251252
}
252253

253254
for (int cycle_count = 0; !stopping; ++cycle_count) {
@@ -258,11 +259,11 @@ WorkloadRunner::start_table_idle_cycle(WT_CONNECTION *conn)
258259
workgen_clock(&start);
259260

260261
/* Create a table. */
261-
int ret;
262-
if ((ret = session->create(session, uri, "key_format=S,value_format=S")) != 0) {
262+
int ret = session->create(session, uri, "key_format=S,value_format=S");
263+
if (ret != 0) {
263264
if (ret == EBUSY)
264265
continue;
265-
THROW("Table create failed in start_table_idle_cycle.");
266+
THROW_ERRNO(ret, "Table create failed in start_table_idle_cycle.");
266267
}
267268

268269
uint64_t stop;
@@ -276,11 +277,13 @@ WorkloadRunner::start_table_idle_cycle(WT_CONNECTION *conn)
276277

277278
/* Open and close cursor. */
278279
WT_CURSOR *cursor;
279-
if ((ret = session->open_cursor(session, uri, nullptr, nullptr, &cursor)) != 0) {
280-
THROW("Cursor open failed.");
280+
ret = session->open_cursor(session, uri, nullptr, nullptr, &cursor);
281+
if (ret != 0) {
282+
THROW_ERRNO(ret, "Cursor open failed.");
281283
}
282-
if ((ret = cursor->close(cursor)) != 0) {
283-
THROW("Cursor close failed.");
284+
ret = cursor->close(cursor);
285+
if (ret != 0) {
286+
THROW_ERRNO(ret, "Cursor close failed.");
284287
}
285288

286289
workgen_clock(&stop);
@@ -300,7 +303,7 @@ WorkloadRunner::start_table_idle_cycle(WT_CONNECTION *conn)
300303
}
301304

302305
if (ret != 0) {
303-
THROW("Table drop failed in cycle_idle_tables.");
306+
THROW_ERRNO(ret, "Table drop failed in cycle_idle_tables.");
304307
}
305308
workgen_clock(&stop);
306309
last_interval = ns_to_sec(stop - start);
@@ -467,8 +470,9 @@ int
467470
WorkloadRunner::start_tables_create(WT_CONNECTION *conn)
468471
{
469472
WT_SESSION *session;
470-
if (conn->open_session(conn, nullptr, nullptr, &session) != 0) {
471-
THROW("Error opening a session.");
473+
int ret = conn->open_session(conn, nullptr, nullptr, &session);
474+
if (ret != 0) {
475+
THROW_ERRNO(ret, "Error opening a session.");
472476
}
473477

474478
ContextInternal *icontext = _workload->_context->_internal;
@@ -594,8 +598,9 @@ int
594598
WorkloadRunner::start_tables_drop(WT_CONNECTION *conn)
595599
{
596600
WT_SESSION *session;
597-
if (conn->open_session(conn, nullptr, nullptr, &session) != 0) {
598-
THROW("Error opening a session.");
601+
int ret = conn->open_session(conn, nullptr, nullptr, &session);
602+
if (ret != 0) {
603+
THROW_ERRNO(ret, "Error opening a session.");
599604
}
600605

601606
ContextInternal *icontext = _workload->_context->_internal;
@@ -689,7 +694,7 @@ WorkloadRunner::start_tables_drop(WT_CONNECTION *conn)
689694
* removed from the shared data structures, and we know no thread is operating on them.
690695
*/
691696
for (auto uri : drop_files) {
692-
WT_DECL_RET;
697+
int ret;
693698
// Spin on EBUSY. We do not expect to get stuck.
694699
while ((ret = session->drop(session, uri.c_str(), "checkpoint_wait=false")) == EBUSY) {
695700
if (stopping)
@@ -698,7 +703,7 @@ WorkloadRunner::start_tables_drop(WT_CONNECTION *conn)
698703
sleep(1);
699704
}
700705
if (ret != 0)
701-
THROW("Table drop failed for '" << uri << "' in start_tables_drop.");
706+
THROW_ERRNO(ret, "Table drop failed for '" << uri << "' in start_tables_drop.");
702707

703708
VERBOSE(*_workload, "Dropped table: " << uri);
704709
}
@@ -910,28 +915,31 @@ ContextInternal::create_all(WT_CONNECTION *conn)
910915
* dynamic set of tables are marked separately during creation.
911916
*/
912917
WT_SESSION *session;
913-
if (conn->open_session(conn, nullptr, nullptr, &session) != 0) {
914-
THROW("Error opening a session.");
918+
int ret = conn->open_session(conn, nullptr, nullptr, &session);
919+
if (ret != 0) {
920+
THROW_ERRNO(ret, "Error opening a session.");
915921
}
916922

917-
WT_DECL_RET;
918923
WT_CURSOR *cursor;
919-
if ((ret = session->open_cursor(session, "metadata:", NULL, NULL, &cursor)) != 0) {
924+
ret = session->open_cursor(session, "metadata:", NULL, NULL, &cursor);
925+
if (ret != 0) {
920926
/* If there is no metadata (yet), this will return ENOENT. */
921927
if (ret == ENOENT) {
922-
THROW("No metadata found while extracting dynamic set of tables.");
928+
THROW_ERRNO(ret, "No metadata found while extracting dynamic set of tables.");
923929
}
924930
}
925931

926932
/* Walk the entries in the metadata and extract the dynamic set. */
927933
while ((ret = cursor->next(cursor)) == 0) {
928934
const char *key, *v;
929-
if ((ret = cursor->get_key(cursor, &key)) != 0) {
930-
THROW(
935+
ret = cursor->get_key(cursor, &key);
936+
if (ret != 0) {
937+
THROW_ERRNO(ret,
931938
"Error getting the key for a metadata entry while extracting dynamic set of tables.");
932939
}
933-
if ((ret = cursor->get_value(cursor, &v)) != 0) {
934-
THROW(
940+
ret = cursor->get_value(cursor, &v);
941+
if (ret != 0) {
942+
THROW_ERRNO(ret,
935943
"Error getting the value for a metadata entry while extracting dynamic set of "
936944
"tables.");
937945
}
@@ -974,7 +982,7 @@ ContextInternal::create_all(WT_CONNECTION *conn)
974982
}
975983
}
976984
if (ret != WT_NOTFOUND) {
977-
THROW("Error extracting dynamic set of tables from the metadata.");
985+
THROW_ERRNO(ret, "Error extracting dynamic set of tables from the metadata.");
978986
}
979987

980988
/* Make sure each base has its mirror and vice-versa. */
@@ -997,11 +1005,12 @@ ContextInternal::create_all(WT_CONNECTION *conn)
9971005
sleep(1);
9981006
}
9991007
if (ret != 0)
1000-
THROW("Table drop failed for '" << uri << "' in create_all.");
1008+
THROW_ERRNO(ret, "Table drop failed for '" << uri << "' in create_all.");
10011009
}
10021010

1003-
if ((ret = session->close(session, NULL)) != 0) {
1004-
THROW("Session close failed.");
1011+
ret = session->close(session, NULL);
1012+
if (ret != 0) {
1013+
THROW_ERRNO(ret, "Session close failed.");
10051014
}
10061015

10071016
return (0);
@@ -1359,7 +1368,7 @@ ThreadRunner::cross_check(std::vector<ThreadRunner> &runners)
13591368
int
13601369
ThreadRunner::run()
13611370
{
1362-
WT_DECL_RET;
1371+
int ret;
13631372
ThreadOptions *options = &_thread->options;
13641373
std::string name = options->name;
13651374

@@ -1598,7 +1607,7 @@ ThreadRunner::op_kv_gen(Operation *op, const tint_t tint)
15981607
int
15991608
ThreadRunner::op_run_setup(Operation *op)
16001609
{
1601-
WT_DECL_RET;
1610+
int ret;
16021611

16031612
if (_throttle != nullptr) {
16041613
while (_throttle_ops >= _throttle_limit && !_in_transaction && !_stop) {
@@ -1703,7 +1712,7 @@ ThreadRunner::op_run(Operation *op)
17031712
Track *track;
17041713
WT_CURSOR *cursor;
17051714
WT_ITEM item;
1706-
WT_DECL_RET;
1715+
int ret;
17071716
bool measure_latency, own_cursor, retry_op;
17081717
timespec start_time;
17091718
uint64_t time_us;
@@ -3159,7 +3168,7 @@ WorkloadRunner::~WorkloadRunner()
31593168
int
31603169
WorkloadRunner::run(WT_CONNECTION *conn)
31613170
{
3162-
WT_DECL_RET;
3171+
int ret;
31633172
WorkloadOptions *options = &_workload->options;
31643173

31653174
_wt_home = conn->get_home(conn);
@@ -3291,7 +3300,7 @@ WorkloadRunner::final_report(timespec &totalsecs)
32913300
int
32923301
WorkloadRunner::run_all(WT_CONNECTION *conn)
32933302
{
3294-
WT_DECL_RET;
3303+
int ret;
32953304

32963305
// Register signal handlers for SIGINT (Ctrl-C) and SIGTERM.
32973306
std::signal(SIGINT, signal_handler);
@@ -3447,17 +3456,19 @@ WorkloadRunner::run_all(WT_CONNECTION *conn)
34473456
if (options->background_compact > 0) {
34483457
WT_SESSION *session;
34493458

3450-
if (conn->open_session(conn, nullptr, nullptr, &session) != 0)
3451-
THROW("Error opening a session.");
3459+
int ret = conn->open_session(conn, nullptr, nullptr, &session);
3460+
if (ret != 0)
3461+
THROW_ERRNO(ret, "Error opening a session.");
34523462

34533463
const std::string bg_compact_cfg("background=true,free_space_target=" +
34543464
std::to_string(options->background_compact) + "MB");
3455-
int ret = session->compact(session, nullptr, bg_compact_cfg.c_str());
3465+
ret = session->compact(session, nullptr, bg_compact_cfg.c_str());
34563466
if (ret != 0)
34573467
THROW_ERRNO(ret, "WT_SESSION->compact background compaction could not be enabled.");
34583468

3459-
if ((ret = session->close(session, NULL)) != 0)
3460-
THROW("Session close failed.");
3469+
ret = session->close(session, NULL);
3470+
if (ret != 0)
3471+
THROW_ERRNO(ret, "Session close failed.");
34613472
}
34623473

34633474
timespec now;

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": "150ef060dc9a3d02542eb6c4270d66d637ae02fb"
5+
"commit": "2214855bafc4d9d60d853fb58273558a7b5fed7e"
66
}

0 commit comments

Comments
 (0)