feat(pinner): close pinner before repo on shutdown#11296
Merged
Conversation
The pinner's streaming goroutines hold a reference to the backing datastore, and pebble panics on use after Close. Before this change the panic was recovered inside the pinner (see ipfs/boxo#1146) and the symptom was only a transient log trace on daemon exit, but the race remained. Register a new fx OnStop hook that calls pinner.Close before the repo (and therefore the datastore) closes. Close drains all in-flight stream goroutines, so the datastore is closed only after the pinner is fully quiesced. Bumps boxo to pick up Pinner.Close from ipfs/boxo#1150. Fixes #11292
# Conflicts: # docs/changelogs/v0.42.md # docs/examples/kubo-as-a-library/go.mod # docs/examples/kubo-as-a-library/go.sum # go.mod # go.sum # test/dependencies/go.mod # test/dependencies/go.sum
ipfs/boxo#1150 was reworked to use context fan-out instead of a done channel. Pinner.Close now cancels every admitted op and waits for them to return, broadening the shutdown contract from "drain streams" to "drain everything". Comments and changelog reworded to match.
lidel
commented
May 14, 2026
| // runs after, without an explicit dependency between them. | ||
| lc.Append(fx.Hook{ | ||
| OnStop: func(context.Context) error { | ||
| return pinning.Close() |
Member
Author
There was a problem hiding this comment.
ok for now, we will properly bound this in #11329
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The pinner's in-flight operations use the backing datastore. Daemon shutdown closed the datastore before the pinner, racing in-flight work into a
pebble: closedpanic (masked by a recover in the pinner, see ipfs/boxo#1146).(The Proper) Fix
Register an fx
OnStophook that closes the pinner before the repo.Pinner.Closecancels in-flight operations and waits for them to return; the datastore closes after the pinner is fully done.This bumps boxo to
Pinner.Close(review/merge that first)Closes #11292 and similar ones in a safe way