Commit Graph
11 Commits
Author SHA1 Message Date
ricoromaandClaude Opus 5.5 628b5f2278 fix: reject tampered cursors and non-canonical UUIDs
decode_cursor checked only for KeyError, TypeError and ValueError, so a
server-issued cursor whose item id was replaced with [], {}, 123 or
false crashed UUID() with AttributeError and answered 500. It now checks
the types of "t" and "i" before parsing and accepts only the exact
string the server would issue for the parsed key: re-encoding must give
the received cursor, so v=true, an extra field or the id in another
notation is a 400 instead of a page.

pydantic's UUID also accepts ids without hyphens, with the urn:uuid:
prefix and in braces, wider than the contract's format: uuid. chat_id in
the path of the three chat endpoints and member_ids elements now use
UuidIn, which requires the 8-4-4-4-12 form in any case. Response models
and the OpenAPI schema are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:58:30 +03:00
ricoromaandClaude Opus 5.5 edad1fda2b fix: exit at once on SIGTERM before the server starts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 16:53:15 +03:00
ricoroma 7a38c5dbcc Revert "revert: measure scaling-improvement baseline again without the pool change"
This reverts commit 5c07923d8c.
2026-10-11 17:23:34 +03:00
ricoromaandClaude Opus 5.5 5c07923d8c revert: measure scaling-improvement baseline again without the pool change
This reverts commit 53eb38e (the pool change 9c3959d, 623a973, 80e64cd).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 16:30:27 +03:00
ricoroma 53eb38e19b Revert "revert: measure scaling-improvement baseline without the pool change"
This reverts commit 62fa57535e.
2026-10-11 15:04:46 +03:00
ricoromaandClaude Opus 5.5 62fa57535e revert: measure scaling-improvement baseline without the pool change
This reverts commits 9c3959d, 623a973 and 80e64cd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 14:10:43 +03:00
ricoromaandClaude Opus 5.5 9c3959d768 perf: keep a fixed PostgreSQL pool without overflow connections
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 13:25:26 +03:00
ricoromaandClaude Opus 5.5 68edc66742 fix: answer 503 when PostgreSQL refuses connections with too many clients
SQLSTATE 53300 (too_many_connections) joins UNAVAILABLE_SQLSTATES, so a
refused pool connection gives 503 unavailable instead of 500. New fault
check fills max_connections through the failure stand hook and expects
503 in the contract format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 07:26:36 +03:00
ricoromaandClaude Opus 5.5 d2148ac566 feat: add rolling update with LB drain and rollout load profile
scripts/rolling-update.sh (make rolling_update) replaces API replicas one
by one: build, migrations once, new replica UP in HAProxy, old replica
drained and put into maintenance through the LB runtime API on loopback,
then stopped and removed; the slot is reset once DNS drops the address.
Expand migration adds messages.instance_id with a lock timeout. The bench
rollout profile runs the same script under constant load, starting from
the image of an older commit built with git archive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 00:49:50 +03:00
ricoromaandClaude Opus 5.5 459f84c75c feat: coordinate timeout chain and add failover load profile
HAProxy checks get fastinter 500ms and timeout check 2.5s (hung replica
detected within 6.5 s), http-reuse never with uvicorn keep-alive 60 s so
the LB closes idle replica connections, and app connections set
idle_in_transaction_session_timeout so a frozen replica releases its
idempotency key. The bench stand runs behind HAProxy with N replicas and
gains the failover profile (make bench_failover / bench_failover_quick):
constant-rate writes with a key and reads while each replica is stopped,
killed or paused, with per-second timeline, detection and recovery time
and write reconciliation. Driver commands idle-conns and hang-key check
the keep-alive and hung-transaction decisions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 23:21:12 +03:00
ricoromaandClaude Opus 5.5 af4bca08c9 feat: carry lab 2 over and add X-Instance-Id and idempotency keys
- carry the lab 2 solution over and plan lab 3 (PLAN.md, OpenSpec
  change instance-id-idempotency)
- rename the compose project to mtusi-lab3 and the image to :lab3
- add X-Instance-Id to every response and instance_id to every log
  record ([app] instance_id, hostname by default)
- require Idempotency-Key on POST messages: keys table in Postgres,
  key and message in one transaction, replay returns the same 201,
  another body gets 409, TTL from [idempotency] ttl_seconds
- send the key from student-tests, k6 scenarios and the skill driver;
  add idempotency, X-Instance-Id, key race and fault tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 19:42:36 +03:00