Skip to content

swapclientserver: Retry pending swaps after driver interruption - #1643

Open
sputn1ck wants to merge 1 commit into
mainfrom
kon/pending-swap-worker-retry
Open

sputn1ck wants to merge 1 commit into
mainfrom
kon/pending-swap-worker-retry

Conversation

@sputn1ck

Copy link
Copy Markdown
Member

An ordinary pay or receive can lose its process-local driver while the durable swap is still pending. Previously the daemon abandoned that worker after a resume or wait error until something else restarted it. Retry the same payment hash after a bounded pause while its durable record is pending. Stop on successful completion, daemon cancellation, terminal state or a missing record. A read error is logged distinctly and does not pretend the swap is terminal. This creates no work for an empty wallet.

Extracted from the shared worker portion of #1139. This changes two swap-service files only. There are no channel APIs, wallet options, generated code, server protocol changes or dependency pins. This is independent of the ordinary receive-acceptance timeout in #1639.

Local checks on main: full tagged ./swapclientserver unit package, formatting, changed lint, actor checks and commit messages passed. An additional raw pay-worker test with pending, terminal and absent records, alongside the receive disconnect regression, passed five consecutive runs. Hosted CI is separate.

A process-local driver failure does not terminate a durable swap.
Resume the same payment hash while it remains pending; stop on
shutdown, completion, or a missing durable record.
Copilot AI balanced review requested due to automatic review settings November 24, 2026 16:49
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T16:51:24.543352Z 46afaea PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 46afaeaf77

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +2370 to +2371
for {
err := drive(s.rootCtx)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Requeue failed receives instead of monopolizing worker slots

When a receive driver errors while its durable summary remains pending, this loop retries without returning, so the deferred finishReceiveWorker never releases activeReceives or transfers the slot to the FIFO. If the pool is saturated—especially with MaxActiveReceiveSwaps=1—one permanently failing session can prevent every queued or overflow receive from ever being attempted; requeue the failed hash behind the existing backlog before retrying it.

AGENTS.md reference: swapclientserver/AGENTS.md:L97-L105

Useful? React with 👍 / 👎.

Comment on lines +2390 to +2391
s.log.Warnf("%s swap %s stopped while still pending; "+
"retrying: %v", direction, key, err)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Lower the severity of recurring retry messages

During a sustained transport or mailbox outage, every pending worker reaches this branch once per second indefinitely, generating repeated Warn alerts rather than one actionable event; with the receive pool at its default size this can produce more than a hundred warnings per second, plus any pay workers. Emit recurring retry noise at Info/Debug or rate-limit it so an outage does not flood operator alerts.

AGENTS.md reference: AGENTS.md:L38-L41

Useful? React with 👍 / 👎.

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.

2 participants