10000 Move transaction cleanup outside of the transaction lock by taniabogatsch · Pull Request #17034 · duckdb/duckdb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Move transaction cleanup outside of the transaction lock #17034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 15, 2025

Conversation

taniabogatsch
Copy link
Contributor
@taniabogatsch taniabogatsch commented Apr 8, 2025

Before this PR, transaction Cleanup happened immediately (1) while removing a transaction (during commit/rollback), or (2) while moving a transaction to the old_transactions (during commit/rollback). Both of these code paths happened behind a transaction lock, potentially stalling other transactions.

In this PR, instead of immediately invoking a Cleanup, we now schedule the transaction for cleanup by adding it to a new CleanupInfo. Later, we invoke the Cleanup outside the transaction lock. Because the actual Cleanup now happens outside the lock, we need to ensure any transaction can only ever be cleanup up once it has no more dependencies (once it exits old_transactions, or on !store_transaction && transaction.ChangesMade().

Additionally, not all transactions that exit old_transactions await cleanup (e.g., store_transaction, but no changes were made). Thus, this PR also introduces a new flag indicating which transactions in the CleanupInfo await Cleanup.

Related issues:

@duckdb-draftbot duckdb-draftbot marked this pull request as draft April 11, 2025 13:37
@taniabogatsch taniabogatsch marked this pull request as ready for review April 14, 2025 08:50
@taniabogatsch
Copy link
Contributor Author

Also started some nightly tests here: https://github.com/taniabogatsch/duckdb/actions/runs/14441466225

@Mytherin Mytherin merged commit dbbf3d3 into duckdb:main Apr 15, 2025
52 checks passed
@Mytherin
Copy link
Collaborator

Thanks!

@taniabogatsch taniabogatsch deleted the tx-lock branch April 15, 2025 11:47
Mytherin added a commit that referenced this pull request Apr 15, 2025
Just a small follow-up to the review comment in
#17034.
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request May 18, 2025
Move transaction cleanup outside of the transaction lock (duckdb/duckdb#17034)
Always parallelize `read_json` schema detection (duckdb/duckdb#17106)
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request May 18, 2025
Move transaction cleanup outside of the transaction lock (duckdb/duckdb#17034)
Always parallelize `read_json` schema detection (duckdb/duckdb#17106)
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request May 19, 2025
Move transaction cleanup outside of the transaction lock (duckdb/duckdb#17034)
Always parallelize `read_json` schema detection (duckdb/duckdb#17106)
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.

2 participants
0