diff --git a/test/jitter.cc b/test/jitter.cc index c0f31a64..c7b8bccb 100644 --- a/test/jitter.cc +++ b/test/jitter.cc @@ -15,22 +15,15 @@ #include "test.h" bool testcase_jitter::run() { + int err; + size_t upper_limit = config.params.size_upper; + if (upper_limit < 1) + upper_limit = config.params.size_now * 2; + while (should_continue()) { jitter_delay(); db_open(); - if (flipcoin()) { - jitter_delay(); - txn_begin(true); - fetch_canary(); - jitter_delay(); - txn_end(flipcoin()); - } - - int err; - intptr_t upper_limit = config.params.size_upper; - if (upper_limit < 1) - upper_limit = config.params.size_now; if (upper_limit < 1) { MDBX_envinfo info; err = mdbx_env_info_ex(db_guard.get(), txn_guard.get(), &info, @@ -42,30 +35,33 @@ bool testcase_jitter::run() { : INTPTR_MAX; } - const bool xcoin = flipcoin(); - err = mdbx_env_set_geometry(db_guard.get(), -1, -1, - xcoin ? upper_limit / 2 : upper_limit * 3 / 2, - -1, -1, -1); - if (err != MDBX_SUCCESS && err != MDBX_RESULT_TRUE && - err != MDBX_MAP_FULL && err != MDBX_TOO_LARGE) - failure_perror("mdbx_env_set_geometry-1", err); + if (flipcoin()) { + jitter_delay(); + txn_begin(true); + fetch_canary(); + jitter_delay(); + txn_end(flipcoin()); + } + const bool coin4size = flipcoin(); jitter_delay(); txn_begin(mode_readonly()); jitter_delay(); if (!mode_readonly()) { fetch_canary(); update_canary(1); - /* TODO: - * - db_setsize() - * ... - */ + err = mdbx_env_set_geometry( + db_guard.get(), -1, -1, + coin4size ? upper_limit * 2 / 3 : upper_limit * 3 / 2, -1, -1, -1); + if (err != MDBX_SUCCESS && err != MDBX_RESULT_TRUE && + err != MDBX_MAP_FULL && err != MDBX_TOO_LARGE) + failure_perror("mdbx_env_set_geometry-1", err); } txn_end(flipcoin()); - err = mdbx_env_set_geometry(db_guard.get(), -1, -1, - !xcoin ? upper_limit / 2 : upper_limit * 3 / 2, - -1, -1, -1); + err = mdbx_env_set_geometry( + db_guard.get(), -1, -1, + !coin4size ? upper_limit * 2 / 3 : upper_limit * 3 / 2, -1, -1, -1); if (err != MDBX_SUCCESS && err != MDBX_RESULT_TRUE && err != MDBX_MAP_FULL && err != MDBX_TOO_LARGE) failure_perror("mdbx_env_set_geometry-2", err);