Skip to content

fix(jsoncs3): wait for init before asserting the migration timeout - #792

Open
dschmidt wants to merge 1 commit into
mainfrom
fix/jsoncs3-cleanup-stale-shares-test-race
Open

fix(jsoncs3): wait for init before asserting the migration timeout#792
dschmidt wants to merge 1 commit into
mainfrom
fix/jsoncs3-cleanup-stale-shares-test-race

Conversation

@dschmidt

@dschmidt dschmidt commented Sep 3, 2026

Copy link
Copy Markdown

New() initializes the metadata storage in a background goroutine. The CleanupStaleShares spec started its 1ms context right after New(), so CleanupStaleShares raced:

if err := m.waitForInit(ctx); err != nil { return err }   // "share manager not yet initialized"
if err := m.waitForMigrations(ctx); err != nil { ... }    // "share manager migrations did not complete"

On a loaded machine the context expires before Init + MakeDirIfNotExist + MarkAllApplied are done, so the first wait returns and the spec fails:

[FAILED] Expected
    : share manager not yet initialized: context deadline exceeded
to contain substring
    : share manager migrations did not complete

Reproduced with 8 busy loops on 4 cores: 21 of 40 runs failed.

This exposes Ready() and waits for it before starting the timeout context. The timeout then only applies to the migration wait, which is what the spec asserts. Same load, 0 of 40 runs failed; package is green under -race.

Seen on https://ci.opencloud.rocks/repos/4/pipeline/586/19, unrelated to the PR it failed on (#790).

New() initializes the metadata storage in a background goroutine. The
CleanupStaleShares spec started its 1ms context right after New(), so
under load the context expired during initialization and the manager
returned "not yet initialized" instead of the migration timeout.

Expose Ready() and wait for it before starting the timeout context.
@dschmidt
dschmidt force-pushed the fix/jsoncs3-cleanup-stale-shares-test-race branch from 4a6ed98 to ccdac30 Compare September 3, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant