Skip to content

Latest commit

 

History

History
100 lines (73 loc) · 3.91 KB

runbook.md

File metadata and controls

100 lines (73 loc) · 3.91 KB

Runbook

Commands assume the project directory on the host and one of:

COMPOSE="docker compose -f compose.yml -f compose.prod.yml"   # production
COMPOSE="docker compose"                                      # local

Health

Check Command
Everything scripts/smoke.sh (in production, with BASE_URL=https://$DOMAIN)
Containers $COMPOSE ps
API health $COMPOSE exec api wget -qO- localhost:8080/actuator/health
Judge queue $COMPOSE exec db psql -U contester -c "select status, count(*) from submissions group by 1"
Logs $COMPOSE logs -f --tail 200 api (JSON; filter by requestId)

When a user reports an error, the problem response contains a requestId. Search the API log for it.

Dashboards and alerts

These need the observability profile. Grafana runs at localhost:3201 locally and has two dashboards:

  • "Contester — Golden Signals & SLO": traffic, latency, errors and JVM.
  • "Contester — Judge": queue, judge time and verdicts.

Alert rules are in alerts/alert_rules.yml:

Alert Meaning First steps
ContesterBackendUnreachable Prometheus cannot scrape the API $COMPOSE ps api, $COMPOSE logs api; is the DB reachable?
ContesterElevated5xxRate More than 0.5 % of requests are 5xx Find the errors in the logs by requestId; after a recent deploy, roll back
ContesterJudgeBacklog More than 20 submissions queued Is Piston up? Check JUDGE_WORKERS; see below
ContesterJudgeInternalErrors Submissions ended as INTERNAL_ERROR Piston is down or runtimes are missing; rejudge afterwards
ContesterSlowJudging p95 judge time above 30 s CPU saturation on the host; too many workers

Alertmanager is not part of the stack, so alerts show only in Prometheus and Grafana. For paging, add Alertmanager or Grafana contact points.

Incidents

Judge down or submissions stuck in "Queued"

  1. Run $COMPOSE ps piston and $COMPOSE logs --tail 100 piston.
  2. Check that the runtimes are installed: $COMPOSE run --rm piston-install (idempotent).
  3. Run $COMPOSE restart piston. Queued submissions are picked up automatically, and rows stuck in RUNNING are requeued after 5 minutes.
  4. For submissions that ended as INTERNAL_ERROR during the outage, an admin rejudges the affected problems: admin UI → problem → Rejudge, or POST /api/v1/admin/problems/{id}/rejudge.

Contest needs more judge capacity

  1. Raise JUDGE_WORKERS.
  2. Set PISTON_MAX_CONCURRENT_JOBS in compose.yml to workers × JUDGE_PARALLEL_TESTS.
  3. Give the host more CPUs.

Running more parallel jobs than there are CPU cores makes each run slower, and correct solutions can then fail with time limit exceeded.

Wrong test data in a running contest

Fix the tests in the admin UI, then rejudge the problem. Standings are computed from verdicts, so they update immediately.

Suspected account compromise

Reset the password through "Forgot password", which revokes every session. Alternatively, end the sessions directly: delete from spring_session where principal_name = '<email>'.

Leaked secret

  1. Rotate the secret at its source: for the DB password, run ALTER USER and update .env; for the SMTP password, change it at the provider.
  2. Restart the affected services.
  3. Check the access logs.

Rollback

  1. Run APP_VERSION=<previous> scripts/deploy.sh.
  2. If the newer version ran a migration that the old version cannot handle, restore the backup made by the failed deploy with scripts/restore.sh backups/<file> (with COMPOSE set for production). Data written since that backup is lost, so prefer a forward fix when the outage is small.

Routine

When Task
Daily (cron) Run scripts/backup.sh, then copy backups/ off the host
Monthly Restore drill (disaster-recovery.md)
On Dependabot PRs Review, let CI pass, merge, release