mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 16:34:14 +08:00
mdbx: fix mtest1 for backlog-autosync.
After the ae324984cbdf6297f63586dd0fae286909be23dd steady checkpoint(s) could be created automatically while reserve a pages for deletion from freeDB. In other words, some (beginning of list) of modify-ops were "unexpectedly" synced to disk, despite of the no-sync closing of DB by the mtest1 - therefore testcase could fail. Now required rollback at least one of transactions after the last explicit sync, but not all of ones. Change-Id: I6ca6dba8a62a30f12f370fa91325efdf4fe35772
This commit is contained in:
parent
bfd82b5830
commit
f57a54a301
14
mtest1.c
14
mtest1.c
@ -120,22 +120,21 @@ int main(int argc,char * argv[])
|
|||||||
mdb_txn_abort(txn);
|
mdb_txn_abort(txn);
|
||||||
mdb_env_sync(env, 1);
|
mdb_env_sync(env, 1);
|
||||||
|
|
||||||
j=0;
|
int deleted = 0;
|
||||||
key.mv_data = sval;
|
key.mv_data = sval;
|
||||||
for (i= count - 1; i > -1; i-= (rand()%5)) {
|
for (i = count - 1; i > -1; i -= (rand()%5)) {
|
||||||
j++;
|
|
||||||
txn=NULL;
|
txn=NULL;
|
||||||
E(mdb_txn_begin(env, NULL, 0, &txn));
|
E(mdb_txn_begin(env, NULL, 0, &txn));
|
||||||
sprintf(sval, "%03x ", values[i]);
|
sprintf(sval, "%03x ", values[i]);
|
||||||
if (RES(MDB_NOTFOUND, mdb_del(txn, dbi, &key, NULL))) {
|
if (RES(MDB_NOTFOUND, mdb_del(txn, dbi, &key, NULL))) {
|
||||||
j--;
|
|
||||||
mdb_txn_abort(txn);
|
mdb_txn_abort(txn);
|
||||||
} else {
|
} else {
|
||||||
E(mdb_txn_commit(txn));
|
E(mdb_txn_commit(txn));
|
||||||
|
deleted++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(values);
|
free(values);
|
||||||
printf("Deleted %d values\n", j);
|
printf("Deleted %d values\n", deleted);
|
||||||
|
|
||||||
printf("check-preset-b.cursor-next\n");
|
printf("check-preset-b.cursor-next\n");
|
||||||
E(mdb_env_stat(env, &mst));
|
E(mdb_env_stat(env, &mst));
|
||||||
@ -149,7 +148,7 @@ int main(int argc,char * argv[])
|
|||||||
++present_b;
|
++present_b;
|
||||||
}
|
}
|
||||||
CHECK(rc == MDB_NOTFOUND, "mdb_cursor_get");
|
CHECK(rc == MDB_NOTFOUND, "mdb_cursor_get");
|
||||||
CHECK(present_b == present_a - j, "mismatch");
|
CHECK(present_b == present_a - deleted, "mismatch");
|
||||||
|
|
||||||
printf("check-preset-b.cursor-prev\n");
|
printf("check-preset-b.cursor-prev\n");
|
||||||
j = 1;
|
j = 1;
|
||||||
@ -184,7 +183,8 @@ int main(int argc,char * argv[])
|
|||||||
++present_c;
|
++present_c;
|
||||||
}
|
}
|
||||||
CHECK(rc == MDB_NOTFOUND, "mdb_cursor_get");
|
CHECK(rc == MDB_NOTFOUND, "mdb_cursor_get");
|
||||||
CHECK(present_c == present_a, "mismatch");
|
printf("Rolled back %d deletion(s)\n", present_c - (present_a - deleted));
|
||||||
|
CHECK(present_c > present_a - deleted, "mismatch");
|
||||||
|
|
||||||
printf("check-preset-d.cursor-prev\n");
|
printf("check-preset-d.cursor-prev\n");
|
||||||
j = 1;
|
j = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user