mdbx: adding cursors tracking/lists for read-only transactions.

Briefly, this commit fixes a missed flaw:
 - Cursor tracking is required to replacing shaded pages and adjusting the positions in writing transactions;
 - Thus, historically, an internal linked list was maintained for a read-write transactions, but not for a read-only.
   For this reason, the API for using cursors should be different for writing and reading transactions;
 - However, the libmdbx's API has been significantly improved, including the ability to reuse cursors and a uniform cursors behavior for any kind of transactions.
   My mistake is that due to working with MithrilDB, I forgot to make a same changes to libmdbx.

Fixes https://github.com/erthink/libmdbx/issues/272.
This commit is contained in:
Леонид Юрьев (Leonid Yuriev)
2022-03-03 12:39:48 +03:00
parent 96c93ac2f1
commit 71d07b3a8e
2 changed files with 64 additions and 72 deletions

View File

@@ -945,6 +945,7 @@ struct MDBX_txn {
size_t mt_owner; /* thread ID that owns this transaction */
MDBX_canary mt_canary;
void *mt_userctx; /* User-settable context */
MDBX_cursor **mt_cursors;
union {
struct {
@@ -953,7 +954,6 @@ struct MDBX_txn {
} to;
struct {
/* In write txns, array of cursors for each DB */
MDBX_cursor **cursors;
pgno_t *reclaimed_pglist; /* Reclaimed GC pages */
txnid_t last_reclaimed; /* ID of last used record */
#if MDBX_ENABLE_REFUND