mirror of
https://github.com/isar/libmdbx.git
synced 2025-02-01 10:28:22 +08:00
mdbx: fix assertion regression.
Fixes https://github.com/ledgerwatch/erigon/issues/3874. This was a minor regression after the c4a5325aafd3f03ce7520731b9da7253d7d178f0 that affects only debug builgs (with enabled assertions) and only when the added code catch a incoherency of unified page/buffer cache.
This commit is contained in:
parent
3872c0ab74
commit
9fa4e21165
20
src/core.c
20
src/core.c
@ -5046,13 +5046,21 @@ static int mdbx_iov_write(MDBX_txn *const txn, struct mdbx_iov_ctx *ctx) {
|
|||||||
ctx->iov_bytes);
|
ctx->iov_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned iov_items = ctx->iov_items;
|
||||||
|
#if MDBX_ENABLE_PGOP_STAT
|
||||||
|
txn->mt_env->me_lck->mti_pgop_stat.wops.weak += iov_items;
|
||||||
|
#endif /* MDBX_ENABLE_PGOP_STAT */
|
||||||
|
ctx->iov_items = 0;
|
||||||
|
ctx->iov_bytes = 0;
|
||||||
|
|
||||||
uint64_t timestamp = 0;
|
uint64_t timestamp = 0;
|
||||||
for (unsigned i = 0; i < ctx->iov_items; i++) {
|
for (unsigned i = 0; i < iov_items; i++) {
|
||||||
MDBX_page *wp = (MDBX_page *)ctx->iov[i].iov_base;
|
MDBX_page *wp = (MDBX_page *)ctx->iov[i].iov_base;
|
||||||
const MDBX_page *rp = pgno2page(txn->mt_env, wp->mp_pgno);
|
const MDBX_page *rp = pgno2page(txn->mt_env, wp->mp_pgno);
|
||||||
/* check with timeout as the workaround
|
/* check with timeout as the workaround
|
||||||
* for https://github.com/erthink/libmdbx/issues/269 */
|
* for https://github.com/erthink/libmdbx/issues/269 */
|
||||||
while (unlikely(memcmp(wp, rp, ctx->iov[i].iov_len) != 0)) {
|
while (likely(rc == MDBX_SUCCESS) &&
|
||||||
|
unlikely(memcmp(wp, rp, ctx->iov[i].iov_len) != 0)) {
|
||||||
if (!timestamp) {
|
if (!timestamp) {
|
||||||
timestamp = mdbx_osal_monotime();
|
timestamp = mdbx_osal_monotime();
|
||||||
mdbx_iov_done(txn, ctx);
|
mdbx_iov_done(txn, ctx);
|
||||||
@ -5063,7 +5071,7 @@ static int mdbx_iov_write(MDBX_txn *const txn, struct mdbx_iov_ctx *ctx) {
|
|||||||
mdbx_error(
|
mdbx_error(
|
||||||
"bailout waiting for %" PRIaPGNO " page arrival %s", wp->mp_pgno,
|
"bailout waiting for %" PRIaPGNO " page arrival %s", wp->mp_pgno,
|
||||||
"(workaround for incoherent flaw of unified page/buffer cache)");
|
"(workaround for incoherent flaw of unified page/buffer cache)");
|
||||||
return MDBX_CORRUPTED;
|
rc = MDBX_CORRUPTED;
|
||||||
}
|
}
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
SwitchToThread();
|
SwitchToThread();
|
||||||
@ -5077,12 +5085,6 @@ static int mdbx_iov_write(MDBX_txn *const txn, struct mdbx_iov_ctx *ctx) {
|
|||||||
}
|
}
|
||||||
mdbx_dpage_free(env, wp, bytes2pgno(env, ctx->iov[i].iov_len));
|
mdbx_dpage_free(env, wp, bytes2pgno(env, ctx->iov[i].iov_len));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MDBX_ENABLE_PGOP_STAT
|
|
||||||
txn->mt_env->me_lck->mti_pgop_stat.wops.weak += ctx->iov_items;
|
|
||||||
#endif /* MDBX_ENABLE_PGOP_STAT */
|
|
||||||
ctx->iov_items = 0;
|
|
||||||
ctx->iov_bytes = 0;
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user