Repository navigation
fix: load-test and federation findings (503 on auth DB errors, federation conflict counting, upload buffers, S3 spans) - #456
Merged
Conversation
Coverage
Go by area
Web by area (lines)
|
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.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_SCALE1 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 got401(token validation error: failed to get token by hash: … connection refused, ~9,400 times) and repository lookups500.auth.ValidateTokenalready returnsnil, nilfor an unknown, revoked, expired or disabled token (orNotFound), so any error it returns is infrastructure: Bearer, Basic-with-token and MCP now answer503 service_unavailablewithRetry-After: 5, as do evaluator and project lookups (rbac_projects.go). A client that hung up gets499. 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 ans3PartSizebuffer from async.Pool, which GC empties: at scale 1, 40% of all allocated bytes werenewPartPool.func1for 64 KiB layers. The body is now staged in a buffer sized to the data; a pooled part buffer is taken only once it reachesminUploadPart. Part cutting, tail handling and in-flight limits are unchanged;TestStageBodyBoundarycovers 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 (
DisableLogOutputChecksumValidationSkippedin the shared S3 options):SDK … DEBUG Response has no supported checksumwas 23-28% of the app's log lines and rotated pod logs within ~2 minutes under load.Docs:
DB_MAX_OPEN_CONNSlimits each of the two pools (pgx and database/sql), so a replica can open twice that many backends:MaxOpenConnscomment,.env.example,openartifact.example.yaml,docs/getting-started/configuration.md, regenerateddocs/reference/config.md.Federation conflicts count only concurrent writes (
internal/federation, migration028). Two instances (compose, 5 s poll), raw repository federated both ways:e.txt, it replicates to B, and B overwrites it after seeing it. A'sconflicts_totalwent 2 → 3. Every cross-site tag move (Docker tag, npm dist-tag) counted as a conflict.federation_units.base_*,Entry.baseon 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.TestIsConflictand the integration testTestEngineConflictAccountingcover 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 reportedupstream_error (HTTP 500), and any error loading the token's repository was a401, which the peer shows as a refused token. Now503+Retry-After, the same as the RBAC change above. Test:TestAuthenticateDatabaseDownIsUnavailable.Checks
go vet ./...,go test -short(and-race) forinternal/database,internal/middleware,internal/storage,golangci-linton 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:unauthorized (HTTP 401), then recovery with a new token;upstream_error (HTTP 503)and recovers in 6 s.Upgrading the running stacks to this build applied
028and 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.