Skip to content

Conversation

@Kerollmops
Copy link
Member

@Kerollmops Kerollmops commented Feb 26, 2025

In this PR, we accept nested read-only transactions and no longer count them to accept more than one. We free/close the child transactions only once the last one has been dropped. I am proposing this patch upstream.

We use atomics to implement a reference-counted system that correctly drops the read transactions and the pghead only once. This is not C99 but C11-compatible.

Warning

We found a memory leak in this PR. We need to take time to investigate the matter and fix it.

hyc added 2 commits October 6, 2025 16:49
Use the correct stack index when adjusting other cursors pointing to
the affected page and the DB has a subDB. Broken in ITS#8406.
txn->mt_cursors = (MDB_cursor **)(txn->mt_dbs + env->me_maxdbs);
txn->mt_dbiseqs = parent->mt_dbiseqs;
/* Not useful when nested RDONLY but correctly freed in mdb_txn_end */
txn->mt_u.dirty_list = malloc(sizeof(MDB_ID2)*MDB_IDL_UM_SIZE);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider skipping if MDB_RDONLY

@Kerollmops Kerollmops force-pushed the allow-nested-rtxn-from-wtxn branch from 2c8691e to 2019715 Compare October 24, 2025 09:12
Kerollmops and others added 7 commits October 24, 2025 11:17
We accept nested read-only transactions and no longer count them to
accept more than a single one. We make sure that we free/close the
child transactions only once the last one has been dropped.

We use atomics to implement a reference-counted system to correctly
drop the read transactions and the pghead only once. This is not C99
but C11-compatible.
@Kerollmops Kerollmops force-pushed the allow-nested-rtxn-from-wtxn branch from 2019715 to 41bf522 Compare October 24, 2025 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants