Skip to content

nodestorage: IndexSpace releases the storage - #244

Merged
cheggaaa merged 5 commits into
mainfrom
cheggaaa/indexspace-release-storage
Sep 19, 2026
Merged

cheggaaa merged 5 commits into
mainfrom
cheggaaa/indexspace-release-storage

Conversation

@cheggaaa

@cheggaaa cheggaaa commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Problem

IndexSpace returns an acquired SpaceStorage. The repairer and resharder discard it, so the storage container keeps handlers > 0 and the storage cache never evicts it. Each such space keeps its db open for the process lifetime and TryLockAndOpenDb reports it as locked, so it can never be archived.

With a failing archive upload this compounds: the archiver marks a space Error each check, the repairer "repairs in place" via IndexSpace and pins it. The archiver then re-scans a growing list of locked spaces on every check, which shows up as periodic CPU spikes on an idle node.

Change

IndexSpace closes the storage itself and returns only an error. Callers and the mock are updated; nodehead.ReloadHeadFromStore no longer closes it by hand. A close failure is logged, not returned, since the index is already written by then.

The migrator indexes migrated spaces through IndexSpace instead of repeating its body without a release.

Tests

TestStorageService_IndexSpace covers: index written and storage released, setHead, a storage held elsewhere stays open and usable, and release on the error path.

🤖 Generated with Claude Code

IndexSpace returned an acquired SpaceStorage that the repairer and
resharder discarded, so the container kept handlers > 0 and the storage
cache never evicted it: the db stayed open and TryLockAndOpenDb reported
the space as locked forever.

IndexSpace closes the storage itself and returns only an error.
@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

New Coverage 51.5% of statements
Patch Coverage 58.8% of changed statements (10/17)

Coverage provided by https://github.com/seriousben/go-patch-cover-action

The hash and nodehead are already written by then, so a release error
must not make callers treat an indexed space as failed. The test evicts
through the cache instead of closing the container directly.
The migrator repeated the IndexSpace body and never closed the acquired
storage, pinning every migrated space in the storage cache.
Bulk callers (startup indexing, repairer, resharder) would otherwise keep
every indexed db open until the cache gc. A storage held by someone else
stays in the cache.

Startup indexing no longer calls ForceRemove, which closed the db
regardless of other holders.
ocache.TryRemove has no guard for an entry that is still loading and
closes an idle container under a concurrent opener, so IndexSpace only
releases its handle. A released storage is evicted by the gc within the
cache ttl.
@requilence
requilence self-requested a review September 19, 2026 13:52
@cheggaaa
cheggaaa merged commit 4803eed into main Sep 19, 2026
6 checks passed
@cheggaaa
cheggaaa deleted the cheggaaa/indexspace-release-storage branch September 19, 2026 15:27
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants