mdbx: add self_latter_reader_txnid into MDBX_envinfo.

Change-Id: I17ac6e921f99df6ed61096ff0fbfbacf5a7e4608
This commit is contained in:
Leo Yuriev 2018-02-04 17:13:27 +03:00
parent 72557af2b5
commit 260c1d71dd
2 changed files with 9 additions and 3 deletions

2
mdbx.h
View File

@ -475,6 +475,8 @@ typedef struct MDBX_envinfo {
uint64_t mi_last_pgno; /* ID of the last used page */
uint64_t mi_recent_txnid; /* ID of the last committed transaction */
uint64_t mi_latter_reader_txnid; /* ID of the last reader transaction */
uint64_t mi_self_latter_reader_txnid; /* ID of the last reader transaction of
caller process */
uint64_t mi_meta0_txnid, mi_meta0_sign;
uint64_t mi_meta1_txnid, mi_meta1_sign;
uint64_t mi_meta2_txnid, mi_meta2_sign;

View File

@ -10161,15 +10161,19 @@ int __cold mdbx_env_info(MDBX_env *env, MDBX_envinfo *arg, size_t bytes) {
arg->mi_dxb_pagesize = env->me_psize;
arg->mi_sys_pagesize = env->me_os_psize;
arg->mi_latter_reader_txnid = 0;
arg->mi_self_latter_reader_txnid = arg->mi_latter_reader_txnid = 0;
if (env->me_lck) {
MDBX_reader *r = env->me_lck->mti_readers;
arg->mi_latter_reader_txnid = arg->mi_recent_txnid;
arg->mi_self_latter_reader_txnid = arg->mi_latter_reader_txnid =
arg->mi_recent_txnid;
for (unsigned i = 0; i < arg->mi_numreaders; ++i) {
if (r[i].mr_pid) {
const mdbx_pid_t pid = r[i].mr_pid;
if (pid) {
const txnid_t txnid = r[i].mr_txnid;
if (arg->mi_latter_reader_txnid > txnid)
arg->mi_latter_reader_txnid = txnid;
if (pid == env->me_pid && arg->mi_self_latter_reader_txnid > txnid)
arg->mi_self_latter_reader_txnid = txnid;
}
}
}