mdbx-test: add --random-writemap[=YES|no] option.

Change-Id: Ie83f64d4a7e199f828540f029c2c47deddb05c01
This commit is contained in:
Leonid Yuriev 2020-07-05 02:25:52 +03:00
parent 6439a95b65
commit 0fb127b935
5 changed files with 20 additions and 5 deletions

View File

@ -373,6 +373,8 @@ void dump(const char *title) {
i->params.pagesize);
dump_verbs("mode", i->params.mode_flags, mode_bits);
log_verbose("random-writemap: %s\n",
i->params.random_writemap ? "Yes" : "No");
dump_verbs("table", i->params.table_flags, table_bits);
if (i->params.test_nops)

View File

@ -265,9 +265,10 @@ struct actor_params_pod {
keygen_params_pod keygen;
uint8_t loglevel{0};
bool drop_table{0};
bool ignore_dbfull{0};
bool speculum{0};
bool drop_table{false};
bool ignore_dbfull{false};
bool speculum{false};
bool random_writemap{true};
};
struct actor_config_pod {

View File

@ -101,6 +101,7 @@ void __noreturn usage(void) {
" notls == MDBX_NOTLS\n"
" nordahead == MDBX_NORDAHEAD\n"
" nomeminit == MDBX_NOMEMINIT\n"
" --random-writemap[=YES|no] Toggle MDBX_WRITEMAP randomly\n"
"Key-value space/table options:\n"
" --table={[+-]FLAG}[,[+-]FLAG]...\n"
" key.reverse == MDBX_REVERSEKEY\n"
@ -165,6 +166,7 @@ void actor_params::set_defaults(const std::string &tmpdir) {
drop_table = false;
ignore_dbfull = false;
speculum = false;
random_writemap = true;
max_readers = 42;
max_tables = 42;
@ -259,6 +261,9 @@ int main(int argc, char *const argv[]) {
if (config::parse_option(argc, argv, narg, "mode", params.mode_flags,
config::mode_bits))
continue;
if (config::parse_option(argc, argv, narg, "random-writemap",
params.random_writemap))
continue;
if (config::parse_option(argc, argv, narg, "table", params.table_flags,
config::table_bits)) {
if ((params.table_flags & MDBX_DUPFIXED) == 0)

View File

@ -144,8 +144,14 @@ void testcase::db_open() {
db_prepare();
jitter_delay(true);
unsigned mode = (unsigned)config.params.mode_flags;
if (config.params.random_writemap && flipcoin())
mode ^= MDBX_WRITEMAP;
actual_db_mode = mode;
int rc = mdbx_env_open(db_guard.get(), config.params.pathname_db.c_str(),
(unsigned)config.params.mode_flags, 0640);
mode, 0640);
if (unlikely(rc != MDBX_SUCCESS))
failure_perror("mdbx_env_open()", rc);

View File

@ -169,8 +169,9 @@ protected:
static int oom_callback(MDBX_env *env, mdbx_pid_t pid, mdbx_tid_t tid,
uint64_t txn, unsigned gap, size_t space, int retry);
unsigned actual_db_mode{0};
bool is_nested_txn_available() const {
return (config.params.mode_flags & MDBX_WRITEMAP) == 0;
return (actual_db_mode & MDBX_WRITEMAP) == 0;
}
void kick_progress(bool active) const;
void db_prepare();