Skip to content

fix: load-test and federation findings (503 on auth DB errors, federation conflict counting, upload buffers, S3 spans) - #456

Merged
M0Rf30 merged 8 commits into
mainfrom
fix/load-test-findings
Nov 9, 2026
Merged

M0Rf30 merged 8 commits into
mainfrom
fix/load-test-findings

Conversation

@M0Rf30

@M0Rf30 M0Rf30 commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes found by load-testing the dev instance and by an end-to-end federation test between two instances built from this branch (k6 bench, BENCH_SCALE 1 and 8, Prometheus + Pyroscope + Tempo + Loki).

Changes

  • 503 instead of 401/500 when the database fails during authentication (internal/middleware). During a CNPG failover every valid token got 401 (token validation error: failed to get token by hash: … connection refused, ~9,400 times) and repository lookups 500. auth.ValidateToken already returns nil, nil for an unknown, revoked, expired or disabled token (orNotFound), so any error it returns is infrastructure: Bearer, Basic-with-token and MCP now answer 503 service_unavailable with Retry-After: 5, as do evaluator and project lookups (rbac_projects.go). A client that hung up gets 499. Session-cookie lookup errors are unchanged (still anonymous). Upgrade note added.

  • Small S3 appends no longer take a 16 MiB part buffer (internal/storage/s3_uploads.go). Every OCI chunk append took an s3PartSize buffer from a sync.Pool, which GC empties: at scale 1, 40% of all allocated bytes were newPartPool.func1 for 64 KiB layers. The body is now staged in a buffer sized to the data; a pooled part buffer is taken only once it reaches minUploadPart. Part cutting, tail handling and in-flight limits are unchanged; TestStageBodyBoundary covers both sides of the 5 MiB boundary.

  • Spans for upload completion: storage.s3.upload_complete, upload_promote, upload_open, upload_delete. A ~950 ms OCI blob PUT in Tempo had an untraced gap exactly there.

  • AWS SDK checksum debug log silenced (DisableLogOutputChecksumValidationSkipped in the shared S3 options): SDK … DEBUG Response has no supported checksum was 23-28% of the app's log lines and rotated pod logs within ~2 minutes under load.

  • Docs: DB_MAX_OPEN_CONNS limits each of the two pools (pgx and database/sql), so a replica can open twice that many backends: MaxOpenConns comment, .env.example, openartifact.example.yaml, docs/getting-started/configuration.md, regenerated docs/reference/config.md.

  • Federation conflicts count only concurrent writes (internal/federation, migration 028). Two instances (compose, 5 s poll), raw repository federated both ways:

    • False positive: A uploads e.txt, it replicates to B, and B overwrites it after seeing it. A's conflicts_total went 2 → 3. Every cross-site tag move (Docker tag, npm dist-tag) counted as a conflict.
    • False negative: concurrent writes where only the winner pulls (a one-way mirror). B skipped A's older, different write with no count and no log line, and A and B kept different bytes for the unit. The docs promise this case is counted.
    • Fix: every log state records the base stamp of the state it replaced (federation_units.base_*, Entry.base on the wire, omitempty). A replace is a conflict only if the writer had not seen the local state; a skip is a conflict only if the local writer had not seen the incoming state. A peer without bases (an older version, or rows from before the migration) falls back to the old rule. TestIsConflict and the integration test TestEngineConflictAccounting cover five cases: sequential, loser pulls, winner-only pulls, resync, entry without a base.
  • Federation peer endpoint answers 503 when the database fails during peer authentication (federation/server.go). With A's Postgres stopped, B reported upstream_error (HTTP 500), and any error loading the token's repository was a 401, which the peer shows as a refused token. Now 503 + Retry-After, the same as the RBAC change above. Test: TestAuthenticateDatabaseDownIsUnavailable.

Checks

go vet ./..., go test -short (and -race) for internal/database, internal/middleware, internal/storage, golangci-lint on those packages (0 issues), go run ./cmd/docgen -check. The S3 append change is covered by unit tests only; not exercised against a real S3 here.

Federation, end to end (two compose stacks from this branch, podman): real clients replicate both ways: raw, npm (publish, dist-tag move, install), OCI (multi-arch index via skopeo, tag create and delete), maven (deploy, version range resolve), helm, pypi (pip install), go (one-way mirror into a public repository, go run), and cargo (dependent crate builds against the peer). Also checked:

  • delete → tombstone in the peer's trash, and restore;
  • concurrent conflict converges to the last writer;
  • peer outage: a 31-unit backlog plus a 64 MiB file caught up in ~2 s, sha256 matched;
  • token revoke → unauthorized (HTTP 401), then recovery with a new token;
  • resync is idempotent;
  • after the fix, a source DB outage shows upstream_error (HTTP 503) and recovers in 6 s.

Upgrading the running stacks to this build applied 028 and kept federation healthy. The fixes were re-verified live: a sequential overwrite now adds 0 conflicts, and a winner-only pull counts 1. nuget was not exercised (no client here). Federation integration tests pass against Postgres 17.

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Coverage

Coverage vs main
Go, unit + integration 83.3% ±0.0
Go, unit tests only 70.0% ±0.0
Go, integration tests only 53.9% +0.1
Web, lines 91.8% ±0.0
Web, functions 85.8% ±0.0
Go by area
Area Coverage vs main
cmd/docgen 80.3% ±0.0
cmd/genformats 90.8% ±0.0
cmd/oa 0.0% ±0.0
cmd/resetpw 0.0% ±0.0
cmd/server 70.2% ±0.0
internal/ai 85.6% ±0.0
internal/api 77.0% ±0.0
internal/apkkeys 77.1% ±0.0
internal/artifactpath 100.0% ±0.0
internal/attest 84.0% ±0.0
internal/attestation 79.2% ±0.0
internal/audit 97.6% ±0.0
internal/auth 91.6% +0.1
internal/backup 72.4% ±0.0
internal/bgtask 96.8% ±0.0
internal/blockreason 100.0% ±0.0
internal/branding 93.5% ±0.0
internal/bundlechecks 100.0% ±0.0
internal/clientsetup 93.6% ±0.0
internal/config 96.4% ±0.0
internal/cron 90.0% ±0.0
internal/crypto 91.0% ±0.0
internal/csaf 85.0% ±0.0
internal/curation 99.0% ±0.0
internal/database 76.0% ±0.0
internal/declarative 84.1% ±0.0
internal/dtrack 85.3% ±0.0
internal/exploit 93.6% ±0.0
internal/federation 81.6% +0.1
internal/format 81.2% ±0.0
internal/formats 88.0% ±0.0
internal/gpgkeys 86.8% -0.3
internal/group 89.5% ±0.0
internal/httpcache 100.0% ±0.0
internal/httpcompress 93.3% ±0.0
internal/httpx 85.7% ±0.0
internal/imagesbom 81.9% ±0.0
internal/importmeta 93.3% ±0.0
internal/iocopy 100.0% ±0.0
internal/itempath 98.3% ±0.0
internal/lazyre 100.0% ±0.0
internal/license 98.5% ±0.0
internal/licensemeta 87.5% ±0.0
internal/licensepolicy 92.6% ±0.0
internal/limitio 92.9% ±0.0
internal/mcp 89.7% +0.5
internal/metrics 96.2% ±0.0
internal/middleware 94.6% +0.7
internal/netutil 93.4% ±0.0
internal/nixkeys 79.6% ±0.0
internal/oacli 85.0% ±0.0
internal/ocimanifest 100.0% ±0.0
internal/ocipath 100.0% ±0.0
internal/ociref 96.8% ±0.0
internal/osv 89.8% ±0.0
internal/passwd 93.3% ±0.0
internal/pathseg 100.0% ±0.0
internal/pglock 79.0% ±0.0
internal/pkgdeps 88.1% ±0.0
internal/presign 99.2% ±0.0
internal/promote 84.5% ±0.0
internal/proxy 86.7% ±0.0
internal/publicurl 96.8% ±0.0
internal/pypisimple 97.9% ±0.0
internal/quarantine 100.0% ±0.0
internal/quayapi 81.2% ±0.0
internal/quota 92.2% ±0.0
internal/recovery 85.4% ±0.0
internal/registry 100.0% ±0.0
internal/replication 78.1% ±0.0
internal/repodispatch 85.1% ±0.0
internal/repotype 97.0% ±0.0
internal/sbom 89.9% ±0.0
internal/scanexport 96.4% ±0.0
internal/search 90.3% -0.4
internal/secrets 91.4% ±0.0
internal/storage 84.9% +0.1
internal/telemetry 92.2% ±0.0
internal/tiering 83.5% ±0.0
internal/trash 96.7% ±0.0
internal/urlparams 100.0% ±0.0
internal/vexsync 80.0% ±0.0
internal/vuln 89.9% ±0.0
internal/webhook 86.1% ±0.0
internal/worker 82.4% +0.1
internal/workq 79.5% ±0.0
pkg/ansible 89.8% ±0.0
pkg/apk 96.0% ±0.0
pkg/cargo 95.6% ±0.0
pkg/compactindex 97.8% ±0.0
pkg/composer 94.5% ±0.0
pkg/conan 99.2% ±0.0
pkg/conda 94.8% ±0.0
pkg/deb 81.0% ±0.0
pkg/delta 71.4% ±0.0
pkg/gemversion 100.0% ±0.0
pkg/gpg 86.5% ±0.0
pkg/helm 97.0% ±0.0
pkg/logger 96.9% +3.1
pkg/maven 96.7% ±0.0
pkg/nix 99.1% ±0.0
pkg/npm 88.0% ±0.0
pkg/nuget 97.6% ±0.0
pkg/pacman 90.4% ±0.0
pkg/pyversion 100.0% ±0.0
pkg/rpm 92.3% ±0.0
pkg/rpmsign 90.5% ±0.0
pkg/rubymarshal 87.1% ±0.0
pkg/xzlimit 78.0% ±0.0
tests/integration 78.8% ±0.0
web 93.7% ±0.0
Web by area (lines)
Area Coverage vs main
src 85.1% ±0.0
src/api 92.0% ±0.0
src/components 90.3% ±0.0
src/composables 89.7% ±0.0
src/demo 93.3% ±0.0
src/i18n 98.5% ±0.0
src/lib 99.2% ±0.0
src/pages 92.1% ±0.0
src/pwa 97.6% ±0.0
src/router 98.6% ±0.0
src/stores 99.0% ±0.0
src/telemetry 90.9% ±0.0

Full report (HTML, merged profile) in the CI run artifacts

Log states record the base stamp of the state they replaced; a conflict is a
change made without having seen the state it meets. Sequential overwrites are
no longer counted, and a newer local change that skips a concurrent peer entry
is.
…ntication

A database error while checking a peer token was a 500, and any error loading the token's repository was a 401, so a pulling peer reported a refused token for an outage. Both are now 503 with Retry-After, like the RBAC path; a refused token or a missing repository is still 401.
@M0Rf30 M0Rf30 changed the title fix: load-test findings (503 on auth DB errors, upload buffers, S3 spans and logs) fix: load-test and federation findings (503 on auth DB errors, federation conflict counting, upload buffers, S3 spans) Nov 9, 2026
@M0Rf30
M0Rf30 merged commit e09e115 into main Nov 9, 2026
25 checks passed
@M0Rf30
M0Rf30 deleted the fix/load-test-findings branch November 9, 2026 20:36
@M0Rf30 M0Rf30 mentioned this pull request Nov 9, 2026
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.

1 participant