mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-01 22:54:12 +08:00
mdbx: avoid tsan-trap in mdbx_txn_straggler().
Change-Id: Ib62cdd5592e6001a1734c321f3801722e4dcf7e4
This commit is contained in:
parent
4e5d5ef935
commit
75ab3716fb
12
mdb.c
12
mdb.c
@ -3063,8 +3063,8 @@ mdb_dbis_update(MDB_txn *txn, int keep)
|
||||
env->me_numdbs = n;
|
||||
}
|
||||
|
||||
int
|
||||
mdbx_txn_straggler(MDB_txn *txn, int *percent)
|
||||
ATTRIBUTE_NO_SANITIZE_THREAD /* LY: avoid tsan-trap by me_txn, mm_last_pg and mt_next_pgno */
|
||||
int mdbx_txn_straggler(MDB_txn *txn, int *percent)
|
||||
{
|
||||
MDB_env *env;
|
||||
MDB_meta *meta;
|
||||
@ -3082,9 +3082,11 @@ mdbx_txn_straggler(MDB_txn *txn, int *percent)
|
||||
env = txn->mt_env;
|
||||
meta = mdb_meta_head_r(env);
|
||||
if (percent) {
|
||||
long cent = env->me_maxpg / 100;
|
||||
long last = env->me_txn ? env->me_txn0->mt_next_pgno : meta->mm_last_pg;
|
||||
*percent = (last + cent / 2) / (cent ? cent : 1);
|
||||
size_t maxpg = env->me_maxpg;
|
||||
size_t last = meta->mm_last_pg + 1;
|
||||
if (env->me_txn)
|
||||
last = env->me_txn0->mt_next_pgno;
|
||||
*percent = (last + maxpg / 2) * 100u / maxpg;
|
||||
}
|
||||
lag = meta->mm_txnid - txn->mt_u.reader->mr_txnid;
|
||||
return (0 > (long) lag) ? ~0u >> 1: lag;
|
||||
|
Loading…
x
Reference in New Issue
Block a user