-
Notifications
You must be signed in to change notification settings - Fork 266
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: close the pruning process properly #970
Conversation
WalkthroughThe recent updates enhance the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant NodeDB
participant PruningRoutine
Client->>NodeDB: Close()
NodeDB->>PruningRoutine: Cancel()
PruningRoutine-->>NodeDB: Finish Pruning
NodeDB-->>Client: Closed
Assessment against linked issues
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 as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
@Mergifyio backport release/v1.2.x |
✅ Backports have been created
|
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- CHANGELOG.md (1 hunks)
- nodedb.go (6 hunks)
- nodedb_test.go (1 hunks)
Additional comments not posted (7)
CHANGELOG.md (1)
10-10
: Changelog entry is accurate and complete.The new entry for pull request #970 correctly describes the addition of the API call to close the pruning process when the nodeDB is closed.
nodedb_test.go (1)
440-447
: Test functionTestCloseNodeDB
is well-structured and effective.The test correctly verifies the closure functionality of the
NodeDB
instance. Consider adding more assertions to check the state of theNodeDB
after closure.nodedb.go (5)
5-5
: Context package import is necessary.The import of the
context
package is required for managing asynchronous operations in thenodeDB
.
76-81
: Additions tonodeDB
struct are necessary.The new fields
ctx
,cancel
, anddone
are required for managing the context and signaling the completion of the pruning process.
Line range hint
104-124
: Changes tonewNodeDB
function are necessary and correct.The function now correctly initializes the context and cancel function, and starts the pruning process if asynchronous pruning is enabled.
588-612
: Changes tostartPruning
method ensure graceful termination.The method now listens for the context's
Done
signal, allowing the pruning process to exit cleanly when the context is canceled.
1112-1116
: Changes toClose
method ensure proper cleanup.The method now calls the
cancel
function and waits for the pruning process to finish, ensuring that all resources are properly cleaned up when thenodeDB
instance is closed.
(cherry picked from commit 7939ef9)
Co-authored-by: cool-developer <[email protected]>
Context
close: #966
Summary by CodeRabbit
New Features
Bug Fixes
Tests