-
Notifications
You must be signed in to change notification settings - Fork 283
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
fix: importer to wait db close #1050
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThis change refines error handling and control flow within the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Importer as writeNode()
participant Inflight as InflightCommit
participant Batch
Caller->>Importer: call writeNode()
Importer->>Inflight: check inflight commit error
alt Error exists
Inflight-->>Importer: return error
Importer-->>Caller: return error
else No error
Inflight-->>Importer: return nil
Importer->>Batch: call WriteSync()
Batch-->>Importer: return batch result/error
alt Batch error
Importer-->>Caller: return error
else Successful write
Importer-->>Caller: proceed with success
end
end
sequenceDiagram
participant Caller
participant Importer as Commit()
participant Inflight as InflightCommit
participant Batch
Caller->>Importer: call Commit()
Importer->>Inflight: await inflight commit
alt Inflight error exists
Inflight-->>Importer: return error
Importer-->>Caller: return error
else No error
Inflight-->>Importer: return nil
Importer->>Batch: call WriteSync() for batch write
Batch-->>Importer: return batch response/error
alt Batch error
Importer-->>Caller: return error
else Successful commit
Importer-->>Caller: commit successful
end
end
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
import.go
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Analyze (go)
- GitHub Check: Test
- GitHub Check: Benchmarks
🔇 Additional comments (1)
import.go (1)
85-103
: LGTM! Improved error handling and synchronous batch operations.The changes enhance reliability by:
- Immediately checking and propagating errors from previous batch operations
- Using
WriteSync()
to ensure synchronous completion- Properly handling errors from both
WriteSync()
andClose()
operationsThis aligns well with the PR objective of ensuring proper wait for batch operations.
Here is context: cosmos/cosmos-sdk#23740
When we use statesync, it is using this IAVL importer but sometimes the IAVL store is empty even there is no notable errors. And after digging the issue, I found importer is not waiting the
batch.Close()
.This PR is to fix to importer to wait previous batch's
WriteSync()
andClose()
.Summary by CodeRabbit
Bug Fixes
Refactor