mirror of
https://github.com/isar/libmdbx.git
synced 2024-10-29 23:19:20 +08:00
mdbx: add MDBX_DBG_LEGACY_OVERLAP.
Change-Id: I7aecb925b553587efd6698dc3d52682ca98aa950
This commit is contained in:
parent
01f65bc872
commit
e475db7ade
32
mdbx.h
32
mdbx.h
@ -833,13 +833,24 @@ typedef struct iovec MDBX_val;
|
|||||||
* but MDBX_DBG_ASSERT, MDBX_DBG_AUDIT and MDBX_DBG_JITTER only if libmdbx
|
* but MDBX_DBG_ASSERT, MDBX_DBG_AUDIT and MDBX_DBG_JITTER only if libmdbx
|
||||||
* builded with MDBX_DEBUG. */
|
* builded with MDBX_DEBUG. */
|
||||||
|
|
||||||
#define MDBX_DBG_ASSERT 1 /* Enable assertion checks */
|
/* Enable assertion checks */
|
||||||
#define MDBX_DBG_AUDIT 2 /* Enable pages usage audit at commit transactions */
|
#define MDBX_DBG_ASSERT 1
|
||||||
#define MDBX_DBG_JITTER 4 /* Enable small random delays in critical points */
|
|
||||||
#define MDBX_DBG_DUMP /* Include or not meta-pages in coredump files, MAY \
|
/* Enable pages usage audit at commit transactions */
|
||||||
affect performance in MDBX_WRITEMAP mode */ \
|
#define MDBX_DBG_AUDIT 2
|
||||||
8
|
|
||||||
#define MDBX_DBG_LEGACY_MULTIOPEN 16 /* Enable multi-opening environment(s) */
|
/* Enable small random delays in critical points */
|
||||||
|
#define MDBX_DBG_JITTER 4
|
||||||
|
|
||||||
|
/* Include or not meta-pages in coredump files,
|
||||||
|
* MAY affect performance in MDBX_WRITEMAP mode */
|
||||||
|
#define MDBX_DBG_DUMP 8
|
||||||
|
|
||||||
|
/* Allow multi-opening environment(s) */
|
||||||
|
#define MDBX_DBG_LEGACY_MULTIOPEN 16
|
||||||
|
|
||||||
|
/* Allow read and write transactions overlapping for the same thread */
|
||||||
|
#define MDBX_DBG_LEGACY_OVERLAP 32
|
||||||
|
|
||||||
/* A debug-logger callback function,
|
/* A debug-logger callback function,
|
||||||
* called before printing the message and aborting.
|
* called before printing the message and aborting.
|
||||||
@ -849,7 +860,12 @@ typedef struct iovec MDBX_val;
|
|||||||
typedef void MDBX_debug_func(int loglevel, const char *function, int line,
|
typedef void MDBX_debug_func(int loglevel, const char *function, int line,
|
||||||
const char *msg, va_list args);
|
const char *msg, va_list args);
|
||||||
|
|
||||||
/* FIXME: Complete description */
|
/* Don't change current settings */
|
||||||
|
#define MDBX_LOG_DONTCHANGE (-1)
|
||||||
|
#define MDBX_DBG_DONTCHANGE (-1)
|
||||||
|
#define MDBX_LOGGER_DONTCHANGE ((MDBX_debug_func *)(intptr_t)-1)
|
||||||
|
|
||||||
|
/* Setup global log-level, debug options and debug logger. */
|
||||||
LIBMDBX_API int mdbx_setup_debug(int loglevel, int flags,
|
LIBMDBX_API int mdbx_setup_debug(int loglevel, int flags,
|
||||||
MDBX_debug_func *logger);
|
MDBX_debug_func *logger);
|
||||||
|
|
||||||
|
@ -5972,7 +5972,8 @@ static int mdbx_txn_renew0(MDBX_txn *txn, unsigned flags) {
|
|||||||
if (unlikely(txn->mt_owner == tid))
|
if (unlikely(txn->mt_owner == tid))
|
||||||
return MDBX_BUSY;
|
return MDBX_BUSY;
|
||||||
MDBX_lockinfo *const lck = env->me_lck;
|
MDBX_lockinfo *const lck = env->me_lck;
|
||||||
if (lck && (env->me_flags & MDBX_NOTLS) == 0) {
|
if (lck && (env->me_flags & MDBX_NOTLS) == 0 &&
|
||||||
|
(mdbx_runtime_flags & MDBX_DBG_LEGACY_OVERLAP) == 0) {
|
||||||
const unsigned snap_nreaders = lck->mti_numreaders;
|
const unsigned snap_nreaders = lck->mti_numreaders;
|
||||||
for (unsigned i = 0; i < snap_nreaders; ++i) {
|
for (unsigned i = 0; i < snap_nreaders; ++i) {
|
||||||
if (lck->mti_readers[i].mr_pid == env->me_pid &&
|
if (lck->mti_readers[i].mr_pid == env->me_pid &&
|
||||||
@ -6213,7 +6214,9 @@ int mdbx_txn_begin(MDBX_env *env, MDBX_txn *parent, unsigned flags,
|
|||||||
size = env->me_maxdbs * (sizeof(MDBX_db) + sizeof(MDBX_cursor *) + 1);
|
size = env->me_maxdbs * (sizeof(MDBX_db) + sizeof(MDBX_cursor *) + 1);
|
||||||
size += tsize = sizeof(MDBX_txn);
|
size += tsize = sizeof(MDBX_txn);
|
||||||
} else if (flags & MDBX_RDONLY) {
|
} else if (flags & MDBX_RDONLY) {
|
||||||
if (env->me_txn0 && unlikely(env->me_txn0->mt_owner == mdbx_thread_self()))
|
if (env->me_txn0 &&
|
||||||
|
unlikely(env->me_txn0->mt_owner == mdbx_thread_self()) &&
|
||||||
|
(mdbx_runtime_flags & MDBX_DBG_LEGACY_OVERLAP) == 0)
|
||||||
return MDBX_TXN_OVERLAPPING;
|
return MDBX_TXN_OVERLAPPING;
|
||||||
size = env->me_maxdbs * (sizeof(MDBX_db) + 1);
|
size = env->me_maxdbs * (sizeof(MDBX_db) + 1);
|
||||||
size += tsize = sizeof(MDBX_txn);
|
size += tsize = sizeof(MDBX_txn);
|
||||||
@ -16532,21 +16535,20 @@ int __cold mdbx_setup_debug(int loglevel, int flags, MDBX_debug_func *logger) {
|
|||||||
#if !MDBX_DEBUG
|
#if !MDBX_DEBUG
|
||||||
(void)loglevel;
|
(void)loglevel;
|
||||||
#else
|
#else
|
||||||
if (loglevel != -1)
|
if (loglevel != MDBX_LOG_DONTCHANGE)
|
||||||
mdbx_loglevel = (uint8_t)loglevel;
|
mdbx_loglevel = (uint8_t)loglevel;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (flags != -1) {
|
if (flags != MDBX_DBG_DONTCHANGE) {
|
||||||
#if !MDBX_DEBUG
|
flags &=
|
||||||
flags &= MDBX_DBG_DUMP | MDBX_DBG_LEGACY_MULTIOPEN;
|
#if MDBX_DEBUG
|
||||||
#else
|
MDBX_DBG_ASSERT | MDBX_DBG_AUDIT | MDBX_DBG_JITTER |
|
||||||
flags &= MDBX_DBG_ASSERT | MDBX_DBG_AUDIT | MDBX_DBG_JITTER |
|
|
||||||
MDBX_DBG_DUMP | MDBX_DBG_LEGACY_MULTIOPEN;
|
|
||||||
#endif
|
#endif
|
||||||
|
MDBX_DBG_DUMP | MDBX_DBG_LEGACY_MULTIOPEN | MDBX_DBG_LEGACY_OVERLAP;
|
||||||
mdbx_runtime_flags = (uint8_t)flags;
|
mdbx_runtime_flags = (uint8_t)flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-1 != (intptr_t)logger)
|
if (logger != MDBX_LOGGER_DONTCHANGE)
|
||||||
mdbx_debug_logger = logger;
|
mdbx_debug_logger = logger;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user