Repository navigation
Conversation
The server had dropped the slot, but a failed close of the replication connection made the reaper report it as failed and keep its publication. The catalog now confirms the slot is gone and the publication follows.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
🤖 Review 1/2 (correctness) of 0358750: 0 blocking, 2 non-blocking. Inspected the whole change at The drop is judged correctly, and the distinction the PR needs is drawn at the right place. "Only the close failed" is exactly What a resume does with the carried state. The reaper keeps no state across passes: a slot in Invariants ( Non-blocking
Test case (not run here: needs a live PostgreSQL through the fixture): a wait the context ends, with a failing close, is not a dropfunc TestDropSlotEndedByItsContextWhoseConnectionFailsToCloseIsNotADrop(t *testing.T) {
f := newSlotFixture(t)
slot := f.createSlot(t)
require.NoError(t, slot.Close(t.Context()))
release := f.holdSlot(t, slot)
defer release()
fault := &testutil.SlotDropFault{FailClose: true}
cfg := f.cfg
cfg.BeforeConnect = fault.BeforeConnect
dropCtx, cancel := context.WithTimeout(t.Context(), 500*time.Millisecond)
defer cancel()
err := decode.DropSlot(dropCtx, cfg, f.pool, slot.Name())
require.ErrorIs(t, err, context.DeadlineExceeded)
require.ErrorIs(t, err, testutil.ErrInjectedCloseFailure, "the close's error rides beside the failure")
assert.NotErrorIs(t, err, decode.ErrSlotDroppedConnectionNotClosed)
assert.NotErrorIs(t, err, decode.ErrSlotDroppedPublicationLeft)
assert.Equal(t, int64(1), fault.ClosesFailed())
_, found, err := decode.InspectSlot(t.Context(), f.pool, slot.Name())
require.NoError(t, err)
assert.True(t, found, "the holder keeps the slot")
assert.True(t, f.publicationExists(t, slot.Name()))
}Not run: the fixture starts a PostgreSQL container, which this review does not use. Expected to pass at
Verified
This review was generated by Claude Code (claude-sonnet-5-5). |
|
🤖 Review 2/2 (OSS adoption and integration) of 0358750: 0 blocking, 2 non-blocking. Read the change from two seats: an importer that calls Non-blocking
What reads well for adopters
This review was generated by Claude Code (claude-sonnet-5-5). |
aparajon
left a comment
There was a problem hiding this comment.
🤖 Stamping with comments: 0 blocking, 4 non-blocking (see the review comments above).
This stamp was left by Claude Code (claude-sonnet-5-5).
When the server drops a replication slot but closing the replication connection afterwards fails,
pg-sprite reapnow confirms the slot is gone, drops its publication, and reports the slot as dropped.Why
pg-sprite reapcleans up replication slots that stopped runs left behind, each with a publication of the same name. It drops a slot over a replication connection, and if only the final close of that connection failed, it reported the slot as failed ("may be gone") and stopped before the publication, although the server had already dropped the slot. The operator was left a publication to clean by hand and a report that did not say what really happened.What
pkg/decode: the drop returns the drop error and the close error separately. After an accepted drop, it readspg_replication_slotsby name on the pool (once more if that read fails); if no slot of that name remains, it drops the publication exactly as a clean drop does and returns the newErrSlotDroppedConnectionNotClosed, wrapping the close error. A slot still in the catalog stays anErrInvariantViolationand its publication is kept. A refused drop is unchanged. Applies toDropSlot,DropIdleSlotand both*OfGoneTableforms.pkg/checkpoint:ReapOrphanSlotscounts that sentinel as a drop; the slot goes inDropped, a newReaped.Unclosedrecords the close error, and the pass carries on. The CLI logs one warning per such slot; the JSON report and exit code are unchanged.internal/testutil.SlotDropFault: a fault hook on the existingdbconn.Config.BeforeConnectthat makes the close fail after the server has answered the drop. No production hook.cli.mdreap section, copy-and-swap design (reaper), invariants (ST-3),SAFETY.md.Before / after
The same orphan slot reaped when the replication connection's close fails after the server has dropped it.
If the catalog still shows a slot of that name, the slot stays under
failedand its publication is kept, as before.