Skip to content

Fix commit and query contention#3075

Merged
jewei1997 merged 5 commits into
mainfrom
fix-commit-and-query-contention
Mar 17, 2026
Merged

Fix commit and query contention#3075
jewei1997 merged 5 commits into
mainfrom
fix-commit-and-query-contention

Conversation

@jewei1997

@jewei1997 jewei1997 commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

Describe your changes and provide context

Previously, there was an issue where Commit() and queries (getLogs, getReceiptByTxHash) into parquet via DuckDB would sometimes have lock contention because these queries would hold the read lock for the entire query, while Commit() stores receipts and during parquet file rotation, we need to acquire this lock to update the files on disk we are tracking. This has the possibility of slowing down the consensus commit phase, potentially slowing down block production.

The fix: old hold the existing lock for modifying and reading/copying of the files being tracked. This allows for minimal contention between Commit() and queries(). Then introduce a second lock which will synchronize between queries and pruning so that parquet files aren't dropped while queries are happening. Pruning and queries are less performance-critical to the node as ensuring Commits are fast.

Testing performed to validate your change

unit tests.

@github-actions

github-actions Bot commented Mar 16, 2026

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMar 17, 2026, 1:20 PM

@codecov

codecov Bot commented Mar 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.42%. Comparing base (dcdde1b) to head (2486772).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sei-db/ledger_db/parquet/store.go 80.00% 1 Missing and 1 partial ⚠️
sei-db/ledger_db/parquet/reader.go 96.15% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3075      +/-   ##
==========================================
- Coverage   58.43%   58.42%   -0.02%     
==========================================
  Files        2088     2088              
  Lines      172084   172102      +18     
==========================================
- Hits       100559   100547      -12     
- Misses      62599    62616      +17     
- Partials     8926     8939      +13     
Flag Coverage Δ
sei-chain-pr 72.96% <91.66%> (?)
sei-db 70.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sei-db/ledger_db/parquet/reader.go 77.51% <96.15%> (+1.99%) ⬆️
sei-db/ledger_db/parquet/store.go 68.45% <80.00%> (+0.27%) ⬆️

... and 13 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jewei1997 jewei1997 requested review from masih and yzang2019 and removed request for masih March 16, 2026 13:38
defer wg.Done()
for i := uint64(0); i < 5; i++ {
startBlock := 5000 + i*500
writeTestReceiptFile(t, dir, startBlock, 1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Instead of passing in t to then call require no error, I recommend using an error group and have this function return error.

This way we would capture errors in the goroutine. Otherwise t would exist the current goroutine only and might not fail the test itself on error.

@jewei1997 jewei1997 enabled auto-merge March 17, 2026 13:23
@jewei1997 jewei1997 added this pull request to the merge queue Mar 17, 2026
Merged via the queue into main with commit 1d93a1a Mar 17, 2026
38 checks passed
@jewei1997 jewei1997 deleted the fix-commit-and-query-contention branch March 17, 2026 13:49
yzang2019 pushed a commit that referenced this pull request Mar 19, 2026
Previously, there was an issue where Commit() and queries (getLogs,
getReceiptByTxHash) into parquet via DuckDB would sometimes have lock
contention because these queries would hold the read lock for the entire
query, while Commit() stores receipts and during parquet file rotation,
we need to acquire this lock to update the files on disk we are
tracking. This has the possibility of slowing down the consensus commit
phase, potentially slowing down block production.

The fix: old hold the existing lock for modifying and reading/copying of
the files being tracked. This allows for minimal contention between
Commit() and queries(). Then introduce a second lock which will
synchronize between queries and pruning so that parquet files aren't
dropped while queries are happening. Pruning and queries are less
performance-critical to the node as ensuring Commits are fast.

unit tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants