mdbx: Merge branch 'devel'.

This commit is contained in:
Leo Yuriev 2016-01-14 00:28:31 +03:00
commit f8941daa0a
4 changed files with 53 additions and 5 deletions

View File

@ -1,7 +1,9 @@
LMDB 0.9 Change Log
LMDB 0.9.18 Release Engineering
Add MDB_PREV_MULTIPLE
already done for mdbx - Fix robust mutex detection on glibc 2.10-11 (ITS#8330)
Fix page_search_root assert on FreeDB (ITS#8336)
n/a for mdbx - Check for utf8_to_utf16 failures (ITS#7992)
Catch strdup failure in mdb_dbi_open
Build

9
lmdb.h
View File

@ -76,6 +76,11 @@
* access to locks and lock file. Exceptions: On read-only filesystems
* or with the #MDB_NOLOCK flag described under #mdb_env_open().
*
* - An LMDB configuration will often reserve considerable \b unused
* memory address space and maybe file size for future growth.
* This does not use actual memory or disk space, but users may need
* to understand the difference so they won't be scared off.
*
* - By default, in versions before 0.9.10, unused portions of the data
* file might receive garbage data from memory freed by other code.
* (This does not happen when using the #MDB_WRITEMAP flag.) As of
@ -387,7 +392,9 @@ typedef enum MDB_cursor_op {
MDB_PREV_NODUP, /**< Position at last data item of previous key */
MDB_SET, /**< Position at specified key */
MDB_SET_KEY, /**< Position at specified key, return key + data */
MDB_SET_RANGE /**< Position at first key greater than or equal to specified key. */
MDB_SET_RANGE, /**< Position at first key greater than or equal to specified key. */
MDB_PREV_MULTIPLE /**< Position at previous page and return key and up to
a page of duplicate data items. Only for #MDB_DUPFIXED */
} MDB_cursor_op;
/** @defgroup errors Return Codes

42
mdb.c
View File

@ -4097,6 +4097,7 @@ mdb_env_sync0(MDB_env *env, unsigned flags, MDB_meta *pending)
size_t prev_mapsize = head->mm_mapsize;
MDB_meta* tail = META_IS_WEAK(head) ? head : mdb_env_meta_flipflop(env, head);
off_t offset = (char*) tail - env->me_map;
size_t used_size = env->me_psize * (pending->mm_last_pg + 1);
mdb_assert(env, (env->me_flags & (MDB_RDONLY | MDB_FATAL_ERROR)) == 0);
mdb_assert(env, META_IS_WEAK(head) || env->me_sync_pending != 0
@ -4108,6 +4109,7 @@ mdb_env_sync0(MDB_env *env, unsigned flags, MDB_meta *pending)
mdb_assert(env, pending->mm_txnid > stay->mm_txnid);
pending->mm_mapsize = env->me_mapsize;
mdb_assert(env, pending->mm_mapsize >= used_size);
if (unlikely(pending->mm_mapsize != prev_mapsize)) {
if (pending->mm_mapsize < prev_mapsize) {
/* LY: currently this can't happen, but force full-sync. */
@ -4124,7 +4126,7 @@ mdb_env_sync0(MDB_env *env, unsigned flags, MDB_meta *pending)
if (env->me_sync_pending && (flags & MDB_NOSYNC) == 0) {
if (env->me_flags & MDB_WRITEMAP) {
int mode = (flags & MDB_MAPASYNC) ? MS_ASYNC : MS_SYNC;
if (unlikely(msync(env->me_map, pending->mm_mapsize, mode))) {
if (unlikely(msync(env->me_map, used_size, mode))) {
rc = errno;
goto fail;
}
@ -4729,13 +4731,23 @@ mdb_env_setup_locks(MDB_env *env, char *lpath, int mode, int *excl)
return errno;
env->me_txns = m;
if (madvise(env->me_txns, rsize, MADV_DONTFORK | MADV_WILLNEED))
return errno;
#ifdef MADV_NOHUGEPAGE
(void) madvise(env->me_txns, rsize, MADV_NOHUGEPAGE);
#endif
#ifdef MADV_DODUMP
madvise(env->me_txns, rsize, MADV_DODUMP);
(void) madvise(env->me_txns, rsize, MADV_DODUMP);
#endif
if (madvise(env->me_txns, rsize, MADV_DONTFORK) < 0)
return errno;
if (madvise(env->me_txns, rsize, MADV_WILLNEED) < 0)
return errno;
if (madvise(env->me_txns, rsize, MADV_RANDOM) < 0)
return errno;
if (*excl > 0) {
pthread_mutexattr_t mattr;
@ -6327,6 +6339,28 @@ fetchm:
}
}
break;
case MDB_PREV_MULTIPLE:
if (data == NULL) {
rc = EINVAL;
break;
}
if (!(mc->mc_db->md_flags & MDB_DUPFIXED)) {
rc = MDB_INCOMPATIBLE;
break;
}
if (!(mc->mc_flags & C_INITIALIZED))
rc = mdb_cursor_first(mc, key, data);
else {
MDB_cursor *mx = &mc->mc_xcursor->mx_cursor;
if (mx->mc_flags & C_INITIALIZED) {
rc = mdb_cursor_sibling(mx, 0);
if (rc == MDB_SUCCESS)
goto fetchm;
} else {
rc = MDB_NOTFOUND;
}
}
break;
case MDB_NEXT:
case MDB_NEXT_DUP:
case MDB_NEXT_NODUP:

View File

@ -19,4 +19,9 @@
<title>mdb_stat - environment status tool</title>
<filename>mdb_stat.1</filename>
</compound>
<compound kind="page">
<name>mdb_chk_1</name>
<title>mdb_chk - environment check tool</title>
<filename>mdb_chk.1</filename>
</compound>
</tagfile>