control-api: reduce SQLite disk writes; add diagnostic mode

Disk writes:
- SQLite pragmas in DSN: wal_autocheckpoint=10000, journal_size_limit=64MB, cache_size=64MB
- migration 0013: drop redundant idx_checks_registry_cycle
- results batched: UpsertChecksIfOpen in one transaction; agent flushes every 5s and before complete
- heartbeat kept in memory, persisted on state change or every 60s; startup grace for stale sweeps

Diagnostic mode:
- POST /api/v1/admin/diagnostics/attach|detach, GET /api/v1/admin/diagnostics
- migration 0014: diagnostic_holds; validator state "diagnostic"
- held addresses are not queued, held validators skip sweeps, port release and delete

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Opus 5.5 committed 2026-11-03 07:01:24 +03:00
1 parent d0ab6b94f9
commit 55d383bd34
41 files changed
+1214 -94

No files matched your search

+7
View File
@@ -270,6 +270,10 @@ type AgentChecks struct {
HTTPSAttempts int `yaml:"https_attempts"`
HTTPSRetryDelaySeconds int `yaml:"https_retry_delay_seconds"`
// ResultsFlushSeconds is how often buffered check results are sent to
// control-api (they are always sent before the completion signal).
ResultsFlushSeconds int `yaml:"results_flush_seconds"`
Traceroute TracerouteCfg `yaml:"traceroute"`
}
@@ -330,6 +334,9 @@ func LoadValidatorAgent(path string) (*ValidatorAgent, error) {
if c.Checks.HTTPSRetryDelaySeconds <= 0 {
c.Checks.HTTPSRetryDelaySeconds = 2
}
if c.Checks.ResultsFlushSeconds <= 0 {
c.Checks.ResultsFlushSeconds = 5
}
if c.Checks.Traceroute.TimeoutSeconds <= 0 {
c.Checks.Traceroute.TimeoutSeconds = 90
}