Skip to content

Conversation

hanabi1224
Copy link
Contributor

@hanabi1224 hanabi1224 commented Oct 9, 2025

Summary of changes

To fix below error (which does not break anything)

2025-10-09T12:13:40.785178Z ERROR forest::daemon::db_util: Failed to import F3 snapshot: leveldb: closed

Changes introduced in this pull request:

Reference issue to close (if applicable)

Closes

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Summary by CodeRabbit

  • New Features
    • No user-facing features added in this release.
  • Bug Fixes
    • Improved resource cleanup during data operations to reduce the likelihood of shutdown errors and intermittent failures.
  • Refactor
    • Streamlined internal datastore lifecycle management to centralize cleanup and improve reliability.
  • Chores
    • Adjusted internal handling of close operations to ensure errors are captured consistently and do not impact runtime stability.

Copy link
Contributor

coderabbitai bot commented Oct 9, 2025

Walkthrough

Adjusted datastore cleanup: instead of deferring close on the raw datastore, the code now keeps it open, wraps it in a dsWrapper, and defers closing the wrapper with error-joining on close.

Changes

Cohort / File(s) Summary
Resource lifecycle and cleanup
f3-sidecar/import.go
Replaced deferred ds.Close with creation of a dsWrapper and deferred dsWrapper.Close, applying error-joining to wrapper close errors; raw datastore remains open while wrapper manages cleanup.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Caller
  participant Import as import.go
  participant DS as Datastore (raw)
  participant W as dsWrapper

  C->>Import: import(...)
  activate Import
  Import->>DS: Open/obtain raw datastore
  Note right of DS: Raw datastore remains open
  Import->>W: Create dsWrapper(DS)
  Note over Import,W: Defer W.Close with error-joining
  Import-->>C: Perform import operations using W
  deactivate Import
  C->>Import: function returns (deferred runs)
  Import->>W: Close()
  alt Close returns error
    Note right of W: Error joined into return error
  else Close succeeds
    Note right of W: No additional error
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the main change—preventing LevelDB from being closed twice—in a single clear sentence using conventional commit style. It accurately focuses on the f3 component and the issue addressed without extraneous details.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hm/f3-db-closed-twice

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d1a154f and c7b240e.

📒 Files selected for processing (1)
  • f3-sidecar/import.go (0 hunks)
💤 Files with no reviewable changes (1)
  • f3-sidecar/import.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: cargo-publish-dry-run
  • GitHub Check: Build Ubuntu
  • GitHub Check: Build MacOS
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: tests
  • GitHub Check: tests-release
  • GitHub Check: All lint checks

Comment @coderabbitai help to get the list of available commands and usage tips.

return err
}
defer func() {
if closeErr := ds.Close(); closeErr != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

dsWrapper.Close calls ds.Close internally

@hanabi1224 hanabi1224 marked this pull request as ready for review October 9, 2025 13:00
@hanabi1224 hanabi1224 requested a review from a team as a code owner October 9, 2025 13:00
@hanabi1224 hanabi1224 requested review from akaladarshi and elmattic and removed request for a team October 9, 2025 13:00
@hanabi1224 hanabi1224 enabled auto-merge October 9, 2025 13:18
@hanabi1224 hanabi1224 added this pull request to the merge queue Oct 9, 2025
Merged via the queue into main with commit c2423e2 Oct 9, 2025
41 checks passed
@hanabi1224 hanabi1224 deleted the hm/f3-db-closed-twice branch October 9, 2025 13:55
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.

3 participants