Skip to content

feat(pinner): close pinner before repo on shutdown#11296

Merged
lidel merged 5 commits into
masterfrom
feat/pinner-close
May 14, 2026
Merged

feat(pinner): close pinner before repo on shutdown#11296
lidel merged 5 commits into
masterfrom
feat/pinner-close

Conversation

@lidel
Copy link
Copy Markdown
Member

@lidel lidel commented Apr 24, 2026

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: closed panic (masked by a recover in the pinner, see ipfs/boxo#1146).

(The Proper) Fix

Register an fx OnStop hook that closes the pinner before the repo. Pinner.Close cancels in-flight operations and waits for them to return; the datastore closes after the pinner is fully done.

This bumps boxo to

Closes #11292 and similar ones in a safe way

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
@lidel lidel marked this pull request as ready for review April 24, 2026 19:19
@lidel lidel requested a review from a team as a code owner April 24, 2026 19:19
lidel added 2 commits May 13, 2026 23:28
# 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 lidel marked this pull request as ready for review May 13, 2026 22:31
Comment thread core/node/core.go
// runs after, without an explicit dependency between them.
lc.Append(fx.Hook{
OnStop: func(context.Context) error {
return pinning.Close()
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ok for now, we will properly bound this in #11329

@lidel lidel merged commit d01246f into master May 14, 2026
22 checks passed
@lidel lidel deleted the feat/pinner-close branch May 14, 2026 21:29
@lidel lidel mentioned this pull request May 19, 2026
37 tasks
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.

pebble panic on shutdown

1 participant