mirror of
https://github.com/isar/libmdbx.git
synced 2024-10-29 23:19:20 +08:00
mdbx: refine/clarify error messages.
Change-Id: If2a38bdfb4a9fce176acb87fa452709bcfc5c972
This commit is contained in:
parent
17fe5f106b
commit
a594f79e5f
32
mdbx.h
32
mdbx.h
@ -1412,7 +1412,7 @@ typedef enum MDBX_cursor_op {
|
||||
/* Environment maxreaders reached */
|
||||
#define MDBX_READERS_FULL (-30790)
|
||||
|
||||
/* Txn has too many dirty pages */
|
||||
/* Transaction has too many dirty pages, i.e transaction too big */
|
||||
#define MDBX_TXN_FULL (-30788)
|
||||
|
||||
/* Cursor stack too deep - internal error */
|
||||
@ -1421,30 +1421,35 @@ typedef enum MDBX_cursor_op {
|
||||
/* Page has not enough space - internal error */
|
||||
#define MDBX_PAGE_FULL (-30786)
|
||||
|
||||
/* Database contents grew beyond environment mapsize */
|
||||
/* Database contents grew beyond environment mapsize and engine was
|
||||
* unable to extend mapping, e.g. since address space is unavailable or busy */
|
||||
#define MDBX_MAP_RESIZED (-30785)
|
||||
|
||||
/* Operation and DB incompatible, or DB type changed. This can mean:
|
||||
/* Environment or database is not compatible with the requested operation
|
||||
* or the specified flags. This can mean:
|
||||
* - The operation expects an MDBX_DUPSORT / MDBX_DUPFIXED database.
|
||||
* - Opening a named DB when the unnamed DB has MDBX_DUPSORT/MDBX_INTEGERKEY.
|
||||
* - Accessing a data record as a database, or vice versa.
|
||||
* - The database was dropped and recreated with different flags. */
|
||||
#define MDBX_INCOMPATIBLE (-30784)
|
||||
|
||||
/* Invalid reuse of reader locktable slot */
|
||||
/* Invalid reuse of reader locktable slot,
|
||||
* e.g. read-transaction already run for current thread */
|
||||
#define MDBX_BAD_RSLOT (-30783)
|
||||
|
||||
/* Transaction must abort, has a child, or is invalid */
|
||||
/* Transaction is not valid for requested operation,
|
||||
* e.g. had errored and be must aborted, has a child, or is invalid */
|
||||
#define MDBX_BAD_TXN (-30782)
|
||||
|
||||
/* Unsupported size of key/DB name/data, or wrong DUPFIXED size,
|
||||
* or wrong aligment */
|
||||
/* Invalid size or alignment of key or data for target database,
|
||||
* either invalid subDB name */
|
||||
#define MDBX_BAD_VALSIZE (-30781)
|
||||
|
||||
/* The specified DBI was changed unexpectedly */
|
||||
/* The specified DBI-handle is invalid
|
||||
* or changed by another thread/transaction */
|
||||
#define MDBX_BAD_DBI (-30780)
|
||||
|
||||
/* Unexpected problem - txn should abort */
|
||||
/* Unexpected internal error, transaction should be aborted */
|
||||
#define MDBX_PROBLEM (-30779)
|
||||
|
||||
/* The last LMDB-compatible defined error code */
|
||||
@ -1454,8 +1459,7 @@ typedef enum MDBX_cursor_op {
|
||||
* opening with MDBX_EXCLUSIVE flag */
|
||||
#define MDBX_BUSY (-30778)
|
||||
|
||||
/* The mdbx_put() or mdbx_replace() was called for key,
|
||||
* that has more that one associated value. */
|
||||
/* The specified key has more than one associated value */
|
||||
#define MDBX_EMULTIVAL (-30421)
|
||||
|
||||
/* Bad signature of a runtime object(s), this can mean:
|
||||
@ -1463,8 +1467,8 @@ typedef enum MDBX_cursor_op {
|
||||
* - ABI version mismatch (rare case); */
|
||||
#define MDBX_EBADSIGN (-30420)
|
||||
|
||||
/* Database should be recovered, but this could NOT be done automatically
|
||||
* right now (e.g. in readonly mode and so forth). */
|
||||
/* Database should be recovered, but this could NOT be done for now
|
||||
* since it opened in read-only mode */
|
||||
#define MDBX_WANNA_RECOVERY (-30419)
|
||||
|
||||
/* The given key value is mismatched to the current cursor position,
|
||||
@ -1479,7 +1483,7 @@ typedef enum MDBX_cursor_op {
|
||||
* e.g. a transaction that started by another thread. */
|
||||
#define MDBX_THREAD_MISMATCH (-30416)
|
||||
|
||||
/* Overlapping read and write transactions for the same thread */
|
||||
/* Overlapping read and write transactions for the current thread */
|
||||
#define MDBX_TXN_OVERLAPPING (-30415)
|
||||
|
||||
/**** FUNCTIONS & RELATED STRUCTURES ******************************************/
|
||||
|
@ -3186,23 +3186,29 @@ static const char *__mdbx_strerr(int errnum) {
|
||||
"MDBX_VERSION_MISMATCH: DB version mismatch libmdbx",
|
||||
"MDBX_INVALID: File is not an MDBX file",
|
||||
"MDBX_MAP_FULL: Environment mapsize limit reached",
|
||||
"MDBX_DBS_FULL: Too may DBI (maxdbs reached)",
|
||||
"MDBX_DBS_FULL: Too may DBI-handles (maxdbs reached)",
|
||||
"MDBX_READERS_FULL: Too many readers (maxreaders reached)",
|
||||
NULL /* MDBX_TLS_FULL (-30789): unused in MDBX */,
|
||||
"MDBX_TXN_FULL: Transaction has too many dirty pages, "
|
||||
"i.e transaction too big",
|
||||
"MDBX_CURSOR_FULL: Internal error - cursor stack limit reached",
|
||||
"MDBX_PAGE_FULL: Internal error - page has no more space",
|
||||
"MDBX_MAP_RESIZED: Database contents grew beyond environment mapsize",
|
||||
"MDBX_INCOMPATIBLE: Operation and DB incompatible, or DB flags changed",
|
||||
"MDBX_BAD_RSLOT: Invalid reuse of reader locktable slot",
|
||||
"MDBX_BAD_TXN: Transaction must abort, has a child, or is invalid",
|
||||
"MDBX_BAD_VALSIZE: Unsupported size of key/DB name/data, or wrong "
|
||||
"DUPFIXED size",
|
||||
"MDBX_BAD_DBI: The specified DBI handle was closed/changed unexpectedly",
|
||||
"MDBX_PROBLEM: Unexpected problem - txn should abort",
|
||||
"MDBX_BUSY: Another write transaction is running or "
|
||||
"environment is already used while opening with MDBX_EXCLUSIVE flag",
|
||||
"MDBX_TXN_FULL: Transaction has too many dirty pages,"
|
||||
" i.e transaction too big",
|
||||
"MDBX_CURSOR_FULL: Internal error - Cursor stack limit reached",
|
||||
"MDBX_PAGE_FULL: Internal error - Page has no more space",
|
||||
"MDBX_MAP_RESIZED: Database contents grew beyond environment mapsize"
|
||||
" and engine was unable to extend mapping,"
|
||||
" e.g. since address space is unavailable or busy",
|
||||
"MDBX_INCOMPATIBLE: Environment or database is not compatible"
|
||||
" with the requested operation or the specified flags",
|
||||
"MDBX_BAD_RSLOT: Invalid reuse of reader locktable slot,"
|
||||
" e.g. read-transaction already run for current thread",
|
||||
"MDBX_BAD_TXN: Transaction is not valid for requested operation,"
|
||||
" e.g. had errored and be must aborted, has a child, or is invalid",
|
||||
"MDBX_BAD_VALSIZE: Invalid size or alignment of key or data"
|
||||
" for target database, either invalid subDB name",
|
||||
"MDBX_BAD_DBI: The specified DBI-handle is invalid"
|
||||
" or changed by another thread/transaction",
|
||||
"MDBX_PROBLEM: Unexpected internal error, transaction should be aborted",
|
||||
"MDBX_BUSY: Another write transaction is running,"
|
||||
" or environment is already used while opening with MDBX_EXCLUSIVE flag",
|
||||
};
|
||||
|
||||
if (errnum >= MDBX_KEYEXIST && errnum <= MDBX_LAST_LMDB_ERRCODE) {
|
||||
@ -3214,24 +3220,27 @@ static const char *__mdbx_strerr(int errnum) {
|
||||
case MDBX_SUCCESS:
|
||||
return "MDBX_SUCCESS: Successful";
|
||||
case MDBX_EMULTIVAL:
|
||||
return "MDBX_EMULTIVAL: Unable to update multi-value for the given key";
|
||||
return "MDBX_EMULTIVAL: The specified key has"
|
||||
" more than one associated value";
|
||||
case MDBX_EBADSIGN:
|
||||
return "MDBX_EBADSIGN: Wrong signature of a runtime object(s)";
|
||||
return "MDBX_EBADSIGN: Wrong signature of a runtime object(s),"
|
||||
" e.g. memory corruption or double-free";
|
||||
case MDBX_WANNA_RECOVERY:
|
||||
return "MDBX_WANNA_RECOVERY: Database should be recovered, but this could "
|
||||
"NOT be done in a read-only mode";
|
||||
return "MDBX_WANNA_RECOVERY: Database should be recovered,"
|
||||
" but this could NOT be done automatically for now"
|
||||
" since it opened in read-only mode";
|
||||
case MDBX_EKEYMISMATCH:
|
||||
return "MDBX_EKEYMISMATCH: The given key value is mismatched to the "
|
||||
"current cursor position";
|
||||
return "MDBX_EKEYMISMATCH: The given key value is mismatched to the"
|
||||
" current cursor position";
|
||||
case MDBX_TOO_LARGE:
|
||||
return "MDBX_TOO_LARGE: Database is too large for current system, "
|
||||
"e.g. could NOT be mapped into RAM";
|
||||
return "MDBX_TOO_LARGE: Database is too large for current system,"
|
||||
" e.g. could NOT be mapped into RAM";
|
||||
case MDBX_THREAD_MISMATCH:
|
||||
return "MDBX_THREAD_MISMATCH: A thread has attempted to use a not "
|
||||
"owned object, e.g. a transaction that started by another thread";
|
||||
return "MDBX_THREAD_MISMATCH: A thread has attempted to use a not"
|
||||
" owned object, e.g. a transaction that started by another thread";
|
||||
case MDBX_TXN_OVERLAPPING:
|
||||
return "MDBX_TXN_OVERLAPPING: Overlapping read and write transactions for "
|
||||
"the same thread";
|
||||
return "MDBX_TXN_OVERLAPPING: Overlapping read and write transactions for"
|
||||
" the current thread";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@ -5950,7 +5959,7 @@ static int mdbx_txn_renew0(MDBX_txn *txn, unsigned flags) {
|
||||
if (unlikely(txn->mt_txnid == 0 ||
|
||||
txn->mt_txnid >= SAFE64_INVALID_THRESHOLD)) {
|
||||
mdbx_error("%s", "environment corrupted by died writer, must shutdown!");
|
||||
rc = MDBX_WANNA_RECOVERY;
|
||||
rc = MDBX_CORRUPTED;
|
||||
goto bailout;
|
||||
}
|
||||
mdbx_assert(env, txn->mt_txnid >= *env->me_oldest);
|
||||
@ -9360,7 +9369,7 @@ static int __cold mdbx_setup_dxb(MDBX_env *env, const int lck_rc) {
|
||||
const unsigned meta_clash_mask = mdbx_meta_eq_mask(env);
|
||||
if (meta_clash_mask) {
|
||||
mdbx_error("meta-pages are clashed: mask 0x%d", meta_clash_mask);
|
||||
return MDBX_WANNA_RECOVERY;
|
||||
return MDBX_CORRUPTED;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
|
Loading…
Reference in New Issue
Block a user