Add production-grade online logs slimming job - #686
Conversation
|
Final staging acceptance is complete. Evidence:
Scope remains unchanged: staging GO; production NO-GO. The checked-in binary still hard-refuses the production |
|
|
Follow-up on the final review gate:
The PR body already marks the prior non-root acceptance item complete. Scope remains staging GO / production NO-GO; no production resource was changed. |
|
Resolved the actionable findings from OpenCodeReview comment #5251079323 in commit Resolution by finding:
Additional correction from independent review:
Fresh validation on
The PR remains Draft. Previous staging evidence belongs to |
|
|
|
Staging follow-up for commit
The attempted cancel-after-guard-drop injection completed before the cancellation API took effect, so that exact SIGKILL timing is not claimed as passed. Per the decision to stop expanding staging fault permutations, the PR remains Draft and production remains NO-GO. |
Problem / background
The production
logstable has reached roughly 100M rows with data and indexes both around 60 GB. Root-user Codex traffic accounts for most growth and is now routed tologs_company, but historical rows still need an online, customer-transparent compaction path.Direct bulk DELETE or an unmanaged table rebuild would create unacceptable undo/redo, replication, metadata-lock, disk, and rollback risk on the shared Cloud SQL instance.
Evidence and reproduced risks
Staging exercises were run only against the isolated
newapi_stagingschema on the shared Cloud SQL instance. The job hard-refuses the productionnewapischema.Observed and covered failure modes include:
71successful,0failed);Threads_running=19exceeded the configured threshold of 16 and stopped the operation before topology mutation;Design / scope
This PR adds an independent operational binary and build definition:
cmd/logs_slimming: preflight, prepare, bounded backfill, forward trigger, reconcile, verify, cutover, rollback, recover, and cleanup commands;No application router, console, frontend, Terraform, Cloudflare, or production migration path is changed.
Impact and risks
The code is isolated from the serving application and is invoked only as a standalone Job. The main remaining risk is operational misuse or database load during a future production migration; production therefore remains NO-GO and requires a separately reviewed production-enabled artifact and runbook.
The checked-in binary currently rejects
schema=newapi; it must not be weakened or reused directly for production.Multi-node correctness does not depend on process memory: coordination uses MySQL advisory locking, durable checkpoint CAS, database triggers, and atomic RENAME.
Validation
Fresh after rebase onto current
main:gofmt -l cmd/logs_slimming— cleango vet ./cmd/logs_slimming— passgo test -race -count=1 ./cmd/logs_slimming— passgo build -o /tmp/logs-slimming-evaluator ./cmd/logs_slimming— passorigin/main— 12 isolated added files, low risk, no existing execution flows affectedPASS: code gates and staging 1-9 evidence are presentStaging evidence covers preflight, resumable backfill, advisory locking, append-only guards, DDL watchdog, AUTO_INCREMENT barrier, concurrent cutover writers, topology recovery, non-root rollback API behavior, and production zero-write audit.
Non-root rollback API acceptance
A real non-root staging session (
test_codex) validated the post-rollback user log page:/api/log/self— Cloud Run HTTP 200 at2026-08-11T08:49:48.742232Z/api/log/self/stat— Cloud Run HTTP 200 at2026-08-11T08:49:48.735794Z$0.000246The non-root acceptance item passed for commit
bb6de4d0c, but commite9b9df997changes trigger and watchdog behavior; the prior runtime evidence is therefore historical only. PR remains Draft until the updated artifact completes the full staging 1–9 suite again.Deployment recommendation