mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-30 22:47:16 +08:00
mdbx-windows: always susppend local threads while resize DB (workaround for Windows kernel bug).
We should not concern about performance on Windows platform, it just unreasonable. Therefore just always suspend the local threads to avoid this issue. This resolves https://github.com/leo-yuriev/libmdbx/issues/48
This commit is contained in:
parent
ee7ebe438c
commit
35f95e8ca2
28
src/mdbx.c
28
src/mdbx.c
@ -2246,19 +2246,21 @@ static int mdbx_mapresize(MDBX_env *env, const pgno_t size_pgno,
|
|||||||
env->me_dxb_mmap.current == env->me_dxb_mmap.filesize)
|
env->me_dxb_mmap.current == env->me_dxb_mmap.filesize)
|
||||||
goto bailout;
|
goto bailout;
|
||||||
|
|
||||||
if ((env->me_flags & MDBX_RDONLY) || limit_bytes != env->me_dxb_mmap.length ||
|
/* 1) Windows allows only extending a read-write section, but not a
|
||||||
size_bytes < env->me_dxb_mmap.current) {
|
* corresponing mapped view. Therefore in other cases we must suspend
|
||||||
/* Windows allows only extending a read-write section, but not a
|
* the local threads for safe remap.
|
||||||
* corresponing mapped view. Therefore in other cases we must suspend
|
* 2) At least on Windows 10 1803 the entire mapped section is unavailable
|
||||||
* the local threads for safe remap. */
|
* for short time during NtExtendSection() or VirtualAlloc() execution.
|
||||||
array_onstack.limit = ARRAY_LENGTH(array_onstack.handles);
|
*
|
||||||
array_onstack.count = 0;
|
* THEREFORE LOCAL THREADS SUSPENDING IS ALWAYS REQUIRED!
|
||||||
suspended = &array_onstack;
|
*/
|
||||||
rc = mdbx_suspend_threads_before_remap(env, &suspended);
|
array_onstack.limit = ARRAY_LENGTH(array_onstack.handles);
|
||||||
if (rc != MDBX_SUCCESS) {
|
array_onstack.count = 0;
|
||||||
mdbx_error("failed suspend-for-remap: errcode %d", rc);
|
suspended = &array_onstack;
|
||||||
goto bailout;
|
rc = mdbx_suspend_threads_before_remap(env, &suspended);
|
||||||
}
|
if (rc != MDBX_SUCCESS) {
|
||||||
|
mdbx_error("failed suspend-for-remap: errcode %d", rc);
|
||||||
|
goto bailout;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* Acquire guard to avoid collision between read and write txns
|
/* Acquire guard to avoid collision between read and write txns
|
||||||
|
Loading…
x
Reference in New Issue
Block a user