Skip to content

fix(resolver): default pools to a cohort multiorch will bootstrap - #853

Open
shanurwan wants to merge 1 commit into
multigres:mainfrom
shanurwan:fix/failure-safe-default-poolers
Open

shanurwan wants to merge 1 commit into
multigres:mainfrom
shanurwan:fix/failure-safe-default-poolers

Conversation

@shanurwan

Copy link
Copy Markdown

Fixes #684.

Since multigres/multigres#1349, multiorch only initializes a shard whose initial cohort can lose any one pooler and still meet its durability policy. The resolver still defaulted a single-cell pool to 2 poolers and a two-cell pool to 1 per cell, so on main config/samples/minimal.yaml and a two-cell cluster with default pools never get a primary (initialized poolers (2) satisfy the durability policy but aren't failure-safe). Details and the repro are in #684. The e2e framework already works around this: 4b74406 ("test(e2e): use failure-safe minimal cohort") gives the synthetic default pool 3 replicas. This PR makes the product default match.

Changes

  • Default (pkg/resolver/shard.go, failure_safe.go): a pool without replicasPerCell gets ceil(3 / cells): 3 in one cell, 2 per cell across two cells, and the existing 1 per cell from three cells up.
  • Warning (pkg/resolver/validation.go): the existing durability warnings are unchanged. A new one fires only when none of them did and the layout still could not bootstrap. It asks upstream consensus.CohortSurvivesAnyMemberLoss directly, so uneven layouts are judged the way multiorch judges them.
  • Test against upstream (failure_safe_test.go): checks, for both policies and 1–5 cells, that the default is failure-safe by the upstream function and that one fewer per cell is not. If the rule changes upstream again, this test fails instead of new shards silently staying uninitialized.
  • Tests that encoded the old default: four expectations in pkg/cluster-handler/controller/multigrescluster integration tests move from 2 to 3, and test/suite's child-CR thrash scenario now expects MinFailureSafePoolers - 1 replicas from MinimalCluster instead of 1. test/suite's shard-lifecycle scenario sets 2 replicas explicitly and keeps its shard-lifecycle-two-member-pool-never-rolls pin; I only changed the comments that called 2 the resolver's default. That pin says it expires "if the single-cell default moves off 2", so with this change a default single-cell pool is no longer that shape: the same scenario's later resource change, on three members, rolls without a pin. An explicit replicasPerCell: 2 still cannot roll.
  • Docs and CHANGELOG: README, docs/durability-policy.md, config/samples/README.md, docs/development/pod-management-design.md and docs/development/reconcile-gating.md still described 2 poolers as enough. CHANGELOG gets a Bug Fixes entry and a Breaking entry (below).

Upgrade behaviour

Clusters admitted through the webhook without templates have replicasPerCell stored in the spec, so they keep their current count. A pool resolved from a ShardTemplate without replicasPerCell picks up the new default on operator upgrade. On K3s with a patched build, such a cluster scaled from 2 to 3 poolers and its stuck shard went Healthy in about 30 s. Already-healthy clusters of that kind also gain a pooler and a PVC, hence the Breaking entry.

Testing

  • go test (unit), go test -tags=integration with envtest 1.35, and test/suite (run with -v, as the Makefile does): all pass; the suite's existing KnownDefect pins report as before. golangci-lint v2.14.0 on the touched packages: 0 issues. e2e (kind) not run.

  • Before/after on K3s v1.35.10 (single node), default pools, no templates:

    Operator Cells Poolers Shard after 4 min SQL through Multigateway
    main 817402a 1 2 Progressing FATAL: database is temporarily unavailable
    main 817402a 2 2 Progressing FATAL: database is temporarily unavailable
    this branch 1 3 Healthy after 84 s INSERT and SELECT work
    this branch 2 4 Healthy after 94 s INSERT and SELECT work

    On main, multiorch logs initialized poolers (2) satisfy the durability policy but aren't failure-safe in both cases.

Notes for review

  • durabilityPolicyProto in failure_safe.go mirrors buildDurabilityPolicy in pkg/data-handler/topo. I kept it local to avoid a new import between the resolver and data-handler; happy to move it to a shared package instead.
  • Multiorch has --allow-unsafe-initial-cohort, but upstream marks it test-only, so this PR does not use it.
  • If you would rather keep 2 as the default and only add the warning and docs, I can cut the PR down to that.

@shanurwan
shanurwan requested a review from a team as a code owner November 26, 2026 04:30
Since multigres/multigres#1349, multiorch only initializes a shard whose
initial cohort can lose any one pooler and still meet its durability
policy. The resolver defaulted a single-cell pool to 2 poolers and a
two-cell pool to 1 per cell, so those shards never got a primary.

Default replicasPerCell to ceil(3 / cells), warn in the webhook when an
explicit layout meets the policy but cannot bootstrap (judged by upstream
consensus.CohortSurvivesAnyMemberLoss), and update the docs and tests
that described 2 poolers as enough.

Fixes multigres#684

Signed-off-by: Wan Nur Shafiqah <[email protected]>
@shanurwan
shanurwan force-pushed the fix/failure-safe-default-poolers branch from c5afc28 to de81fde Compare November 26, 2026 04:30
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.

minimal.yaml defaults to two poolers and cannot complete bootstrap

1 participant