Skip to content

refactor: redundancy getter exhaust#5470

Merged
nugaon merged 1 commit into
masterfrom
refactor/replicas-getter-return
May 28, 2026
Merged

refactor: redundancy getter exhaust#5470
nugaon merged 1 commit into
masterfrom
refactor/replicas-getter-return

Conversation

@nugaon
Copy link
Copy Markdown
Member

@nugaon nugaon commented May 20, 2026

Small cleanup of pkg/replicas/getter.go prompted by a beekeeper CI failure where the return nil, nil at the bottom of Get was somehow reached, causing a nil-panic downstream in joiner.New.

Changes:

  • NONE short-circuit: NewGetter with redundancy.NONE now returns g.Getter.Get directly. The replica machinery (goroutines, ticker, replicator) is pointless for level 0, and emitting ErrSwarmageddon when the chunk is simply not found at level 0 was semantically wrong.
  • return nil, nilerrGetterExhausted: the trailing return is structurally unreachable (the replicator exhausts exactly at the last loop iteration, turning it into an indefinite wait on resultC/errc; the loop always exits via success or Swarmageddon). Renamed to a named sentinel with a matching comment so the intent is clear if it ever surfaces again.
  • Comment above loop: explains the batch-doubling design (2, 2, 4, 8, 16 for PARANOID) and why the loop cannot fall through to the bottom.
  • Test: level=0 all-fail case no longer asserts ErrSwarmageddon; the raw error is returned via the short-circuit.

Comment thread pkg/replicas/getter.go
// errGetterExhausted is returned when the retry loop exhausts all levels without
// receiving a result or enough errors to trigger ErrSwarmageddon.
// This path should never be reached under normal operation.
errGetterExhausted = errors.New("replicas getter: exhausted all levels without result (unexpected)")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

similar comment to the other PR - this also suggests incorrect error handling. not a big fan of this but approving because this package's legibility is limited for me.

@nugaon nugaon merged commit 021935f into master May 28, 2026
15 checks passed
@nugaon nugaon deleted the refactor/replicas-getter-return branch May 28, 2026 13:42
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.

4 participants