diff options
author | George Hazan <ghazan@miranda.im> | 2018-09-26 13:59:25 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-09-26 13:59:25 +0300 |
commit | 7eabf1f5a4d7691af4cbf7ac470b4aca75f78443 (patch) | |
tree | 6b89cb287fb8b5fa82e8334bebc41b1309a27694 | |
parent | 1291ee8b887f46ee8db1b87492931213b82c6439 (diff) |
libmdbx: merge to 0.2
-rw-r--r-- | libs/libmdbx/src/mdbx.h | 17 | ||||
-rw-r--r-- | libs/libmdbx/src/packages/rpm/CMakeLists.txt | 19 | ||||
-rw-r--r-- | libs/libmdbx/src/src/mdbx.c | 35 | ||||
-rw-r--r-- | libs/libmdbx/src/src/tools/mdbx_chk.c | 14 |
4 files changed, 36 insertions, 49 deletions
diff --git a/libs/libmdbx/src/mdbx.h b/libs/libmdbx/src/mdbx.h index 8720f34ae0..283f595df6 100644 --- a/libs/libmdbx/src/mdbx.h +++ b/libs/libmdbx/src/mdbx.h @@ -369,17 +369,17 @@ typedef enum MDBX_cursor_op { MDBX_GET_BOTH, /* MDBX_DUPSORT-only: Position at key/data pair. */ MDBX_GET_BOTH_RANGE, /* MDBX_DUPSORT-only: position at key, nearest data. */ MDBX_GET_CURRENT, /* Return key/data at current cursor position */ - MDBX_GET_MULTIPLE, /* MDBX_DUPFIXED-only: Return key and up to a page of - * duplicate data items from current cursor position. - * Move cursor to prepare for MDBX_NEXT_MULTIPLE.*/ + MDBX_GET_MULTIPLE, /* MDBX_DUPFIXED-only: Return up to a page of duplicate + * data items from current cursor position. + * Move cursor to prepare for MDBX_NEXT_MULTIPLE. */ MDBX_LAST, /* Position at last key/data item */ MDBX_LAST_DUP, /* MDBX_DUPSORT-only: Position at last data item * of current key. */ MDBX_NEXT, /* Position at next data item */ MDBX_NEXT_DUP, /* MDBX_DUPSORT-only: Position at next data item * of current key. */ - MDBX_NEXT_MULTIPLE, /* MDBX_DUPFIXED-only: Return key and up to a page of - * duplicate data items from next cursor position. + MDBX_NEXT_MULTIPLE, /* MDBX_DUPFIXED-only: Return up to a page of duplicate + * data items from next cursor position. * Move cursor to prepare for MDBX_NEXT_MULTIPLE. */ MDBX_NEXT_NODUP, /* Position at first data item of next key */ MDBX_PREV, /* Position at previous data item */ @@ -391,7 +391,7 @@ typedef enum MDBX_cursor_op { MDBX_SET_RANGE, /* Position at first key greater than or equal to * specified key. */ MDBX_PREV_MULTIPLE /* MDBX_DUPFIXED-only: Position at previous page and - * return key and up to a page of duplicate data items. */ + * return up to a page of duplicate data items. */ } MDBX_cursor_op; /* Return Codes @@ -989,7 +989,7 @@ LIBMDBX_API int mdbx_env_set_assert(MDBX_env *env, MDBX_assert_func *func); * Returns A non-zero error value on failure and 0 on success, some * possible errors are: * - MDBX_PANIC - a fatal error occurred earlier and the environment - * must be shut down. + * must be shut down. * - MDBX_MAP_RESIZED - another process wrote data beyond this MDBX_env's * mapsize and this environment's map must be resized * as well. See mdbx_env_set_mapsize(). @@ -1486,6 +1486,9 @@ LIBMDBX_API int mdbx_cursor_put(MDBX_cursor *cursor, MDBX_val *key, /* Delete current key/data pair * * This function deletes the key/data pair to which the cursor refers. + * This does not invalidate the cursor, so operations such as MDBX_NEXT + * can still be used on it. Both MDBX_NEXT and MDBX_GET_CURRENT will return + * the same record after this operation. * * [in] cursor A cursor handle returned by mdbx_cursor_open() * [in] flags Options for this operation. This parameter must be set to 0 diff --git a/libs/libmdbx/src/packages/rpm/CMakeLists.txt b/libs/libmdbx/src/packages/rpm/CMakeLists.txt index b664075556..55fbe964fb 100644 --- a/libs/libmdbx/src/packages/rpm/CMakeLists.txt +++ b/libs/libmdbx/src/packages/rpm/CMakeLists.txt @@ -2,19 +2,10 @@ cmake_minimum_required(VERSION 2.8.7) set(TARGET mdbx) project(${TARGET}) -message(WARNING " -*************************************************************** - MDBX is under active development, database format and API - aren't stable at least until 2018Q3. New version won't be - backwards compatible. Main focus of the rework is to provide - clear and robust API and new features. -*************************************************************** -") - set(MDBX_VERSION_MAJOR 0) -set(MDBX_VERSION_MINOR 1) -set(MDBX_VERSION_RELEASE 3) -set(MDBX_VERSION_REVISION 1) +set(MDBX_VERSION_MINOR 2) +set(MDBX_VERSION_RELEASE 0) +set(MDBX_VERSION_REVISION 0) set(MDBX_VERSION_STRING ${MDBX_VERSION_MAJOR}.${MDBX_VERSION_MINOR}.${MDBX_VERSION_RELEASE}) @@ -111,14 +102,14 @@ add_library(${TARGET}_SHARED SHARED set_target_properties(${TARGET}_SHARED PROPERTIES VERSION ${MDBX_VERSION_STRING} - SOVERSION ${MDBX_VERSION_MAJOR} + SOVERSION ${MDBX_VERSION_MAJOR}.${MDBX_VERSION_MINOR} OUTPUT_NAME ${TARGET} CLEAN_DIRECT_OUTPUT 1 ) set_target_properties(${TARGET}_STATIC PROPERTIES VERSION ${MDBX_VERSION_STRING} - SOVERSION ${MDBX_VERSION_MAJOR} + SOVERSION ${MDBX_VERSION_MAJOR}.${MDBX_VERSION_MINOR} OUTPUT_NAME ${TARGET} CLEAN_DIRECT_OUTPUT 1 ) diff --git a/libs/libmdbx/src/src/mdbx.c b/libs/libmdbx/src/src/mdbx.c index 088ac248e6..574b4c66dd 100644 --- a/libs/libmdbx/src/src/mdbx.c +++ b/libs/libmdbx/src/src/mdbx.c @@ -3819,7 +3819,7 @@ retry: goto bailout; } - unsigned settled = 0, cleaned_gc_slot = 0, reused_gc_slots = 0, + unsigned settled = 0, cleaned_gc_slot = 0, reused_gc_slot = 0, filled_gc_slot = ~0u; txnid_t cleaned_gc_id = 0, head_gc_id = env->me_last_reclaimed; while (1) { @@ -3832,16 +3832,13 @@ retry: if (cleaned_gc_slot < MDBX_PNL_SIZE(txn->mt_lifo_reclaimed)) { settled = 0; cleaned_gc_slot = 0; - reused_gc_slots = 0; + reused_gc_slot = 0; filled_gc_slot = ~0u; /* LY: cleanup reclaimed records. */ do { cleaned_gc_id = txn->mt_lifo_reclaimed[++cleaned_gc_slot]; mdbx_tassert(txn, cleaned_gc_slot > 0 && cleaned_gc_id < *env->me_oldest); - head_gc_id = (!head_gc_id || head_gc_id > cleaned_gc_id) - ? cleaned_gc_id - : head_gc_id; key.iov_base = &cleaned_gc_id; key.iov_len = sizeof(cleaned_gc_id); rc = mdbx_cursor_get(&mc, &key, NULL, MDBX_SET); @@ -3862,7 +3859,7 @@ retry: goto bailout; } while (cleaned_gc_slot < MDBX_PNL_SIZE(txn->mt_lifo_reclaimed)); mdbx_txl_sort(txn->mt_lifo_reclaimed); - mdbx_tassert(txn, MDBX_PNL_LAST(txn->mt_lifo_reclaimed) == head_gc_id); + head_gc_id = MDBX_PNL_LAST(txn->mt_lifo_reclaimed); } } else { /* If using records from freeDB which we have not yet deleted, @@ -4087,7 +4084,7 @@ retry: txn->mt_lifo_reclaimed ? (unsigned)MDBX_PNL_SIZE(txn->mt_lifo_reclaimed) : 0, - reused_gc_slots); + reused_gc_slot); if (0 >= (int)left) break; @@ -4125,7 +4122,7 @@ retry: if (head_gc_id > 1 && MDBX_PNL_SIZE(txn->mt_lifo_reclaimed) < prefer_max_scatter && left > ((unsigned)MDBX_PNL_SIZE(txn->mt_lifo_reclaimed) - - reused_gc_slots) * + reused_gc_slot) * env->me_maxgc_ov1page) { /* LY: need just a txn-id for save page list. */ rc = mdbx_page_alloc(&mc, 0, NULL, MDBX_ALLOC_GC | MDBX_ALLOC_KICK); @@ -4156,19 +4153,19 @@ retry: } while (head_gc_id > 1 && MDBX_PNL_SIZE(txn->mt_lifo_reclaimed) < prefer_max_scatter && left > ((unsigned)MDBX_PNL_SIZE(txn->mt_lifo_reclaimed) - - reused_gc_slots) * + reused_gc_slot) * env->me_maxgc_ov1page); } - if ((unsigned)MDBX_PNL_SIZE(txn->mt_lifo_reclaimed) <= reused_gc_slots) { + if ((unsigned)MDBX_PNL_SIZE(txn->mt_lifo_reclaimed) <= reused_gc_slot) { mdbx_notice("** restart: reserve depleted (reused_gc_slot %u >= " "lifo_reclaimed %u" PRIaTXN, - reused_gc_slots, + reused_gc_slot, (unsigned)MDBX_PNL_SIZE(txn->mt_lifo_reclaimed)); goto retry; } const unsigned i = - (unsigned)MDBX_PNL_SIZE(txn->mt_lifo_reclaimed) - reused_gc_slots; + (unsigned)MDBX_PNL_SIZE(txn->mt_lifo_reclaimed) - reused_gc_slot; mdbx_tassert(txn, i > 0 && i <= MDBX_PNL_SIZE(txn->mt_lifo_reclaimed)); reservation_gc_id = txn->mt_lifo_reclaimed[i]; mdbx_trace("%s: take @%" PRIaTXN " from lifo-reclaimed[%u]", @@ -4179,16 +4176,14 @@ retry: mdbx_trace("%s: take @%" PRIaTXN " from head-gc-id", dbg_prefix_mode, reservation_gc_id); } + ++reused_gc_slot; - ++reused_gc_slots; - mdbx_tassert(txn, txn->mt_lifo_reclaimed == NULL || - MDBX_PNL_SIZE(txn->mt_lifo_reclaimed) <= INT16_MAX); unsigned chunk = left; if (unlikely(chunk > env->me_maxgc_ov1page)) { const unsigned avail_gs_slots = txn->mt_lifo_reclaimed ? (unsigned)MDBX_PNL_SIZE(txn->mt_lifo_reclaimed) - - reused_gc_slots + 1 + reused_gc_slot + 1 : (head_gc_id < INT16_MAX) ? (unsigned)head_gc_id : INT16_MAX; if (avail_gs_slots > 1) { if (chunk < env->me_maxgc_ov1page * 2) @@ -4223,7 +4218,7 @@ retry: chunk = (avail >= tail) ? tail - span : (avail_gs_slots > 3 && - reused_gc_slots < prefer_max_scatter - 3) + reused_gc_slot < prefer_max_scatter - 3) ? avail - span : tail; } @@ -4234,7 +4229,7 @@ retry: mdbx_trace("%s: head_gc_id %" PRIaTXN ", reused_gc_slot %u, reservation-id " "%" PRIaTXN, - dbg_prefix_mode, head_gc_id, reused_gc_slots, reservation_gc_id); + dbg_prefix_mode, head_gc_id, reused_gc_slot, reservation_gc_id); mdbx_trace("%s: chunk %u, gc-per-ovpage %u", dbg_prefix_mode, chunk, env->me_maxgc_ov1page); @@ -4282,8 +4277,8 @@ retry: /* Fill in the reserved records */ filled_gc_slot = txn->mt_lifo_reclaimed - ? (unsigned)MDBX_PNL_SIZE(txn->mt_lifo_reclaimed) - reused_gc_slots - : reused_gc_slots; + ? (unsigned)MDBX_PNL_SIZE(txn->mt_lifo_reclaimed) - reused_gc_slot + : reused_gc_slot; rc = MDBX_SUCCESS; mdbx_tassert(txn, mdbx_pnl_check(env->me_reclaimed_pglist, true)); if (env->me_reclaimed_pglist && MDBX_PNL_SIZE(env->me_reclaimed_pglist)) { diff --git a/libs/libmdbx/src/src/tools/mdbx_chk.c b/libs/libmdbx/src/src/tools/mdbx_chk.c index ca6c56fa2c..ddaff0ab4b 100644 --- a/libs/libmdbx/src/src/tools/mdbx_chk.c +++ b/libs/libmdbx/src/src/tools/mdbx_chk.c @@ -409,14 +409,12 @@ static int handle_freedb(const uint64_t record_number, const MDBX_val *key, problem_add("entry", record_number, "wrong txn-id", "%" PRIaTXN, txnid); else { if (data->iov_len < sizeof(pgno_t) || data->iov_len % sizeof(pgno_t)) - problem_add("entry", record_number, "wrong idl size", "%" PRIuPTR, - data->iov_len); + problem_add("entry", txnid, "wrong idl size", "%" PRIuPTR, data->iov_len); size_t number = (data->iov_len >= sizeof(pgno_t)) ? *iptr++ : 0; if (number < 1 || number > MDBX_PNL_MAX) - problem_add("entry", record_number, "wrong idl length", "%" PRIuPTR, - number); + problem_add("entry", txnid, "wrong idl length", "%" PRIuPTR, number); else if ((number + 1) * sizeof(pgno_t) > data->iov_len) { - problem_add("entry", record_number, "trimmed idl", + problem_add("entry", txnid, "trimmed idl", "%" PRIuSIZE " > %" PRIuSIZE " (corruption)", (number + 1) * sizeof(pgno_t), data->iov_len); number = data->iov_len / sizeof(pgno_t) - 1; @@ -424,7 +422,7 @@ static int handle_freedb(const uint64_t record_number, const MDBX_val *key, /* LY: allow gap upto one page. it is ok * and better than shink-and-retry inside mdbx_update_gc() */ envstat.ms_psize) - problem_add("entry", record_number, "extra idl space", + problem_add("entry", txnid, "extra idl space", "%" PRIuSIZE " < %" PRIuSIZE " (minor, not a trouble)", (number + 1) * sizeof(pgno_t), data->iov_len); @@ -438,13 +436,13 @@ static int handle_freedb(const uint64_t record_number, const MDBX_val *key, for (unsigned i = 0; i < number; ++i) { const pgno_t pgno = iptr[i]; if (pgno < NUM_METAS || pgno > envinfo.mi_last_pgno) - problem_add("entry", record_number, "wrong idl entry", + problem_add("entry", txnid, "wrong idl entry", "%u < %" PRIaPGNO " < %" PRIu64, NUM_METAS, pgno, envinfo.mi_last_pgno); else { if (MDBX_PNL_DISORDERED(prev, pgno)) { bad = " [bad sequence]"; - problem_add("entry", record_number, "bad sequence", + problem_add("entry", txnid, "bad sequence", "%" PRIaPGNO " <> %" PRIaPGNO, prev, pgno); } if (walk.pagemap && walk.pagemap[pgno]) { |