246246WorkloadRunner::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);
467470WorkloadRunner::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 ;
594598WorkloadRunner::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)
13591368int
13601369ThreadRunner::run ()
13611370{
1362- WT_DECL_RET ;
1371+ int ret = 0 ;
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)
15981607int
15991608ThreadRunner::op_run_setup (Operation *op)
16001609{
1601- WT_DECL_RET ;
1610+ int ret = 0 ;
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;
@@ -1714,6 +1723,7 @@ ThreadRunner::op_run(Operation *op)
17141723 track = nullptr ;
17151724 cursor = nullptr ;
17161725 own_cursor = false ;
1726+ ret = 0 ;
17171727 retry_op = true ;
17181728
17191729 switch (op->_optype ) {
@@ -3159,7 +3169,7 @@ WorkloadRunner::~WorkloadRunner()
31593169int
31603170WorkloadRunner::run (WT_CONNECTION *conn)
31613171{
3162- WT_DECL_RET ;
3172+ int ret = 0 ;
31633173 WorkloadOptions *options = &_workload->options ;
31643174
31653175 _wt_home = conn->get_home (conn);
@@ -3291,7 +3301,7 @@ WorkloadRunner::final_report(timespec &totalsecs)
32913301int
32923302WorkloadRunner::run_all (WT_CONNECTION *conn)
32933303{
3294- WT_DECL_RET ;
3304+ int ret = 0 ;
32953305
32963306 // Register signal handlers for SIGINT (Ctrl-C) and SIGTERM.
32973307 std::signal (SIGINT, signal_handler);
@@ -3447,17 +3457,19 @@ WorkloadRunner::run_all(WT_CONNECTION *conn)
34473457 if (options->background_compact > 0 ) {
34483458 WT_SESSION *session;
34493459
3450- if (conn->open_session (conn, nullptr , nullptr , &session) != 0 )
3451- THROW (" Error opening a session." );
3460+ int ret = conn->open_session (conn, nullptr , nullptr , &session);
3461+ if (ret != 0 )
3462+ THROW_ERRNO (ret, " Error opening a session." );
34523463
34533464 const std::string bg_compact_cfg (" background=true,free_space_target=" +
34543465 std::to_string (options->background_compact ) + " MB" );
3455- int ret = session->compact (session, nullptr , bg_compact_cfg.c_str ());
3466+ ret = session->compact (session, nullptr , bg_compact_cfg.c_str ());
34563467 if (ret != 0 )
34573468 THROW_ERRNO (ret, " WT_SESSION->compact background compaction could not be enabled." );
34583469
3459- if ((ret = session->close (session, NULL )) != 0 )
3460- THROW (" Session close failed." );
3470+ ret = session->close (session, NULL );
3471+ if (ret != 0 )
3472+ THROW_ERRNO (ret, " Session close failed." );
34613473 }
34623474
34633475 timespec now;
0 commit comments