Skip to content

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

Merged
rhafer merged 1 commit into
mainfrom
fix/jsoncs3-cleanup-stale-shares-test-race
Sep 8, 2026
Merged

rhafer merged 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
@rhafer
rhafer merged commit 7b0ee56 into main Sep 8, 2026
18 of 19 checks passed
@rhafer
rhafer deleted the fix/jsoncs3-cleanup-stale-shares-test-race branch September 8, 2026 10:07
@openclouders openclouders mentioned this pull request Sep 8, 2026
1 task
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.

2 participants