eventstore: optimize event store SST file filtering#4984
Conversation
This reverts commit 5770a52.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR implements SST-level filtering by transaction commit timestamp for TiCDC's log service event store. The changes add Pebble table property collection and filtering to reduce unnecessary SST file scans during iterator operations, with Prometheus metrics for observability. ChangesSST Commit-TS Filtering Optimization
Sequence DiagramsequenceDiagram
participant Client
participant GetIterator as event_store.GetIterator
participant Filter as newEventStoreSSTFileFilter
participant Pebble
participant Collector as EventStoreTxnCommitTsCollector
Client->>GetIterator: GetIterator(dataRange)
GetIterator->>GetIterator: computeLowerTs(LastScannedTxnStartTs)
GetIterator->>Filter: newEventStoreSSTFileFilter(lowerTs, upperTs)
GetIterator->>Pebble: NewIter(LowerBound, UpperBound, TableFilter)
Pebble->>Pebble: Evaluate TableFilter for each SST
Pebble->>Collector: During compaction: Add(key, value)
Collector->>Collector: extractCommitTs(key)
Collector->>Collector: updateMinMaxRange()
Pebble->>Collector: Finish(userProps)
Collector->>Pebble: Write min/max/logicalBytes to props
Pebble->>Filter: CanFilter(SST properties)
Filter->>Filter: Parse min/maxTs from properties
Filter->>Filter: Check [minTs, maxTs] overlap [lowerTs, upperTs]
Filter->>Pebble: true (scan) or false (skip)
Pebble-->>Client: Iterator over qualifying SSTs
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.1)Command failed Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request implements SST file filtering for the event store by introducing a custom Pebble table property collector to track transaction commit timestamps, optimizing read performance. Feedback suggests handling potential errors from db.NewIter to prevent panics and optimizing metrics collection within the filter closure by pre-fetching Prometheus counters to reduce overhead.
| iter, _ := db.NewIter(&pebble.IterOptions{ | ||
| LowerBound: start, | ||
| UpperBound: end, | ||
| TableFilter: newEventStoreSSTFileFilter( | ||
| lowerTs, | ||
| dataRange.CommitTsEnd, | ||
| ), | ||
| }) |
There was a problem hiding this comment.
The error returned by db.NewIter is ignored. If an error occurs (e.g., due to invalid bounds if CommitTsStart > CommitTsEnd), iter will be nil, which will cause a panic when iter.First() is called on line 939. It is recommended to handle the error and return early to avoid a potential crash.
| iter, _ := db.NewIter(&pebble.IterOptions{ | |
| LowerBound: start, | |
| UpperBound: end, | |
| TableFilter: newEventStoreSSTFileFilter( | |
| lowerTs, | |
| dataRange.CommitTsEnd, | |
| ), | |
| }) | |
| iter, err := db.NewIter(&pebble.IterOptions{ | |
| LowerBound: start, | |
| UpperBound: end, | |
| TableFilter: newEventStoreSSTFileFilter( | |
| lowerTs, | |
| dataRange.CommitTsEnd, | |
| ), | |
| }) | |
| if err != nil { | |
| log.Error("failed to create pebble iterator", | |
| zap.Stringer("dispatcherID", dispatcherID), | |
| zap.Error(err)) | |
| return nil | |
| } |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
What problem does this PR solve?
Issue Number: close #4939
What is changed and how it works?
Check List
Tests
Questions
Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?
Release note
Summary by CodeRabbit
Performance
Monitoring