Skip to content

Add composite MySQL safety checks and stable recovery - #196

Open
pradeepkintali wants to merge 11 commits into
masterfrom
pkintali/a1-freno-primary-protection
Open

pradeepkintali wants to merge 11 commits into
masterfrom
pkintali/a1-freno-primary-protection

Conversation

@pradeepkintali

@pradeepkintali pradeepkintali commented Sep 23, 2026 •

Copy link
Copy Markdown

Summary

  • Compose MySQL checks with opt-in RequiredClusters dependencies.
  • Evaluate ShadowRequiredClusters without changing the source cluster's admission decision, and report would-reject observations.
  • Fail closed when configured safety probes have no eligible hosts or required runtime metrics are unavailable.
  • Support separate recovery thresholds and continuous healthy recovery periods, including after startup and leadership changes.
  • Include the blocking metric name in composite responses and export recovery-latch metrics.
  • Add leader-only, read-only /explain/mysql/<cluster> diagnostics for loaded thresholds, recovery settings, exclusions, and cached required/shadow metric state.
  • Support canonical Vitess PRIMARY discovery while accepting MASTER as a deprecated input alias.
  • Validate dependency references, cycles, and tablet types when loading configuration.

Configuration and compatibility

RequiredClusters, ShadowRequiredClusters, FailOnNoHosts, and
RecoveryDurationMillis are opt-in. Existing clusters retain legacy behavior
when these settings are absent.

Shadow observations do not simulate application-specific throttling policies.
Background observations represent aggregation cycles, not client requests or
independent database samples. Missing observations are not evidence of health.

Diagnostics do not run admission checks or SQL, advance recovery, or record
synthetic check/shadow observations. Missing measurements are null; credentials,
queries, connection details, and raw probe errors are not exported. A successful
diagnostic request is not permission to write.

Deployment and rollback

Deploy a compatible binary before configuring the new fields. Validate probe
discovery, permissions, sampling cost, and recovery behavior before enabling
required dependencies. Review thresholds and client retry/wait budgets for each
workload, and enable enforcement incrementally.

To roll back dependency enforcement, remove the relevant RequiredClusters
entry while preserving existing replica-lag checks. Keep it in
ShadowRequiredClusters if continued observation is desired. Configuration
deployment and startup recovery still apply; this is not an instantaneous
runtime toggle.

See doc/mysql.md for configuration examples, behavior changes, and rollout
warnings, and doc/http.md for the diagnostic endpoint contract.

Validation

  • Race-enabled tests: go test -mod=vendor -race ./cmd/... ./pkg/...
  • Static analysis: go vet -mod=vendor ./cmd/... ./pkg/...
  • Binary build: go build -mod=vendor -o /tmp/freno ./cmd/freno
  • Diagnostic coverage includes dependency modes, recovery, unavailable/non-finite values, redaction, read-only behavior, and HTTP error handling.
  • Go formatting and git diff --check.

Scope

These are cooperative admission checks, not universal database load shedding.
Deployments remain responsible for metric selection, thresholds, discovery,
monitoring, and safe client retry/defer behavior.

Allow replica-lag checks to require cached primary and ProxySQL safety metrics, fail closed for configured probes, and hold recovery until a cooling period completes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 0fbc396f-32f9-449a-8537-6264e8665c31
Require a full healthy window after process or leader startup, expose the blocking metric in check responses, and publish recovery latch state.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 0fbc396f-32f9-449a-8537-6264e8665c31
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 0fbc396f-32f9-449a-8537-6264e8665c31
@pradeepkintali pradeepkintali changed the title Add composite MySQL safety checks Add composite MySQL safety checks and stable recovery Sep 24, 2026
@pradeepkintali
pradeepkintali marked this pull request as ready for review September 28, 2026 19:03
Copilot AI balanced review requested due to automatic review settings September 28, 2026 19:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Recovery semantics and direct-memcache behavior can bypass or inconsistently apply the new safety gates.

Review effort: Balanced
Findings: 1 High severity · 3 Medium severity

Open (4)
What changed in this PR

Adds composite MySQL safety checks, recovery hysteresis, and configurable Vitess tablet discovery.

Changes:

  • Composes replica checks with required primary and ProxySQL metrics.
  • Adds fail-closed behavior, recovery thresholds, cooling periods, and metrics.
  • Supports validated REPLICA, MASTER, and PRIMARY Vitess tablet configuration.
File Description
pkg/​base/​throttle_metric.go Adds recovery-state metric errors.
pkg/​config/​config_test.go Tests new configuration validation.
pkg/​config/​mysql_config.go Adds composite and recovery settings.
pkg/​config/​vitess_config.go Validates tablet types.
pkg/​throttle/​check.go Evaluates required clusters.
pkg/​throttle/​check_result.go Reports the blocking metric.
pkg/​throttle/​throttler.go Implements recovery latching.
pkg/​throttle/​throttler_test.go Tests composition and recovery.
pkg/​vitess/​api_client.go Filters configured tablet types.
pkg/​vitess/​api_client_test.go Tests primary discovery.
doc/​mysql.md Documents configuration and rollout scope.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/vitess/api_client.go
Comment thread pkg/throttle/check.go
Comment thread pkg/throttle/throttler.go
Comment thread pkg/throttle/throttler.go
Preserve the replica validation API, apply read overrides consistently, reset recovery state on leadership regain, and enforce required clusters for direct memcache consumers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 0fbc396f-32f9-449a-8537-6264e8665c31
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 0fbc396f-32f9-449a-8537-6264e8665c31
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dea961fa-5766-415f-a0f5-2562c55a0385
Comment thread doc/mysql.md Outdated
Comment thread pkg/config/vitess_config.go Outdated
Pradeep Kintali and others added 3 commits October 15, 2026 12:38
Preserve MASTER as a deprecated input alias and the existing numeric tablet mapping. Clarify that shadow collection precedes enforcement and is not composite dry-run counting.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fbc83df2-d1af-406f-b97b-51cf0aaa570d
Evaluate prospective required metrics without changing admission or memcache publication. Report separate HTTP and background would-reject counters, validate dependency graphs, and document safe activation and recovery behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fbc83df2-d1af-406f-b97b-51cf0aaa570d

@andyedison andyedison left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM 🚀

Pradeep Kintali and others added 2 commits October 16, 2026 09:16
Preserve static-host ignore-settings propagation and both regression test suites.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fbc83df2-d1af-406f-b97b-51cf0aaa570d
Explain cached source and dependency metrics with effective thresholds, recovery settings and enforcement modes without running checks or exposing connection details.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fbc83df2-d1af-406f-b97b-51cf0aaa570d

This branch has not been deployed

No deployments
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.

3 participants