Repository navigation
fix(session): the recorder retries a write that can pass and keeps others' items - #2203
Conversation
056e5fb to
1a77769
Compare
ca87b58 to
2be3358
Compare
kanat
left a comment
There was a problem hiding this comment.
Reviewed at 2be3358 merged onto main 1c87c73: the merge is clean, CI is green, and RecordFlushSuite plus the new store tests pass. -race -count=50 -cpu 1 on the order-dependent tests passes.
Checked and sound:
- A retry after a commit whose answer was lost writes nothing twice: every recorder write is an ON CONFLICT insert, an update guarded by
closed_at,finished_atorended_at IS NULL, or an idempotent update. No write touches usage. - Queue order is kept.
- A non-transient failure is tried once.
- The 23503 split runs once per response and cannot loop.
- The metric's labels are a fixed set of three.
Closestill closes the queue first, so the send-on-closed window is the same as on main.- A write that succeeds on its first try behaves as on main. The only change on that path is one 5 s context per statement.
Verdict: NO-GO. Request changes for R1.1 and R1.2: rules the tests do not pin.
2be3358 to
bab0172
Compare
kanat
left a comment
There was a problem hiding this comment.
Delta round 2: reviewed bab0172 merged onto main eaaf409. The delta is one commit (the tests plus the narrowed store.Transient); the other four commits are identical in range-diff, and records.go is unchanged. Verdict: NO-GO, one Should fix left.
Prior findings:
- R1.1 fixed. I re-ran my mutants on this head. Each write kind now fails its own subtest of
TestEveryWriteCutOffByADroppedConnectionIsStoredwhen it is reverted to one try (13 kinds, plusSessions.UpsertthroughTestASessionWriteCut...).failingnever cleared,failingcleared by a refused write,.Inc()per response, and uncounted full-queue session and call ends each fail a test. The one survivor is the per-response fallbackInsertMany(own)tried once, which you named yourself; optional. - R1.2 fixed for the rows it listed: dropping any of 25006, 40001, 40P01, 53300, 57014, 57P01, 57P02, 57P03, the 08 class, or the timeout rule fails a row. See R2.1 for the rest of the rewritten branch.
- R1.3, R1.4 fixed. The dead
DeadlineExceededand syscall checks are gone, and ENOENT and EACCES are rows. - R1.5, R1.6, R1.7 are AI-3606; fine as tickets.
New:
- [Should fix] R2.1 on
postgres_unit_test.go, see the inline comment. - [Nit] R2.2 on
postgres.go, see the inline comment.
Checks: build, vet and gofmt are clean. RecordFlushSuite and the Transient table pass; -race -cpu 1 passes (-count=3 on the new session tests, -count=20 on the table). gh pr checks shows integration (api) red on TestAThreadTaskWhoseSessionEndsMidTurnSettles and TestAReplyNeverWrittenIsNoReply; nothing under internal/api changed here. I reproduced the first on main: run in one process after TestScheduledTasksSuite/TestAReplyNeverWrittenIsNoReply it fails 3 of 3 on main, and alone it passes 23 of 23 on this head. I did not find why CI's second test timed out, so please rerun the job.
kanat
left a comment
There was a problem hiding this comment.
Verdict: GO, re-graded under this repo's pr-review skill (no Blocker, and no Should fix that has to land before merge). R2.1 is a test-coverage gap on code that behaves correctly, so it is a follow-up: the ready test rows are in the earlier review. The Nits stay optional.
bab0172 to
9b3b4cb
Compare
…her sessions' items A write that fails for a dropped or refused connection, a timeout, a server shutting down, or a serialization failure or deadlock is tried again in place, in queue order, for up to 10 seconds. A batch of items refused for a missing parent row is written again per session, and only the sessions whose row is missing are dropped. Session and call ends that still cannot be stored, and dropped items, are counted in router_session_records_lost_total.
…write is retried A batch of items refused for a missing parent is written again per response, the row the items' key names, so a stored turn's items are kept beside a session's missing turn; a batch of one turn is not sent again. A write refused with 25006 (read-only transaction, a demoted primary) or 57014 (statement cancelled) is retried, as a client-side timeout already was. A session or call end dropped by a full queue is counted as lost, and a write refused before it reached the database no longer marks the writer healthy.
…celled write is retried
…t counts Each write kind is cut mid-statement by a terminated backend and must still be stored, a reopen's tools included. A proxy outage longer than a budget, then a write that gets through, must end the try-once mode; a write refused before it reached the database must not. Two items of a missing turn count as two, and an end a full queue drops is counted. store.Transient is tested against a fake server's SQLSTATEs, a silent server, a closed pool and local errors; it now retries a failed dial, read or write and a timeout, not every errno, and its 57014 comment says what sends one.
…anches A wrapped driver.ErrBadConn, io.EOF, io.ErrUnexpectedEOF and context.DeadlineExceeded, and a dial to a closed port, are each retried; the 57014 comment reads as a sentence.
kanat
left a comment
There was a problem hiding this comment.
Verdict: GO at 9b3b4cb. The rebase leaves the earlier commits identical (range-diff). The new commit adds the R2.1 rows and fixes the R2.2 comment. All four mutants (dropping driver.ErrBadConn, io.EOF, io.ErrUnexpectedEOF or *net.OpError) now fail the Transient unit table.
9b3b4cb to
a1e9cea
Compare
Problem
sessionRecorder.writeandwriteItemstried each write once. A session or response row lost to a dropped connection failed the foreign key of every later row of that conversation, and one item whose response was never stored failed the sharedInsertManyfor everybody. A lost session or call end left the row open for good.Fix
attemptretries in place, keeping queue order, whenstore.Transientsays the failure can pass: a failed dial, read or write, a deadline, class 08, 25006 (a demoted primary), 40001, 40P01, 53300, 57014 (statement_timeoutorpg_cancel_backend; pgdriver sends no cancel, so a client deadline is a net timeout), 57P01-57P03. A local error such as a missing file is not. Backoff 50 ms to 1 s, 10 s per write; after one runs out, writes are tried once until one succeeds.closed_at IS NULL,ON CONFLICT).router_session_records_lost_total{write}.Tests
Each failed before the fix.
TestEveryWriteCutOffByADroppedConnectionIsStored: every write kind, a reopen's tools included, survives its backend being terminated.TestAnEndQueuedWhileTheDatabaseIsBrieflyDownAfterAnOutageIsStored: a write that succeeds ends the try-once mode.TestEndsThatCannotBeStoredAreCountedOnceTheRetriesRunOut: database down; one budget in all, an invalid end between included.TestEndsAFullQueueDropsAreCounted.TestAnItemWhoseResponseIsMissing...(two): stored items survive a missing turn's, in another session or the same; each dropped item counts.TestTransientTellsAFailureAnotherTryCanPassFromOneItCannot(store): SQLSTATEs from a fake server, a silent server, a closed pool and local errors.Fixes AI-3492