fix(nats): propagate object store init errors#1361
Open
corylanou wants to merge 2 commits into
Open
Conversation
Treat the object store as the NATS initialization invariant and initialize replica clients before Store starts background work. This returns missing-bucket errors from startup instead of leaving a partial client that panics. Fixes #1349
PR Build Metrics✅ All clear — no issues detected
Binary Size
Dependency ChangesNo dependency changes. govulncheck OutputBuild Info
History (1 previous)
🤖 Updated on each push. |
Run replica client initialization as a complete pass before any database opens. This prevents a later initialization error from returning with an earlier database and its monitor still active.
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.
Description
Propagates replica client initialization failures from
Store.Open()before any database or compaction monitors start. All replica clients complete initialization as a separate pass before any database opens. NATS initialization now considers the object store, rather than only the NATS connection, to be the completed initialization state and reuses an existing connection when retrying object store access.Motivation and Context
With
origin/mainat c96c0f4 and a localnats:latest -jsserver that did not contain the configured object store, this command reproduced issue #1349:Before this change, the first access returned
nats: bucket not foundafter settingReplicaClient.ncandReplicaClient.js. A concurrent startup access then saw the non-nil connection, treated initialization as complete, and calledobjectStore.List()on a nil object store:The focused regression test reproduced the same partial state and panicked before the fix. After the fix, the CLI returns the initialization error once and exits with status 1:
Fixes #1349
Scope
In scope:
Storestarts database and maintenance monitors.Not in scope:
Behavior Change
Store.Open()returns the error before monitors startHow Has This Been Tested?
go test ./nats -run TestReplicaClient_LTXFiles_InitError -count=1 -vgo test . -run TestStore_Open_InitError -count=1 -vgo test -race . -run TestStore_Open_InitErrorDoesNotOpenDBs -count=20go test ./... -count=1go test -race ./... -count=1go vet ./...pre-commit run --all-filesTypes of changes
Checklist
go fmt,go vet)go test ./...)