Skip to content

[v0.21.x-branch] Backport #10799: payments/db: remap legacy zero attempt IDs#10805

Merged
ziggie1984 merged 1 commit into
v0.21.x-branchfrom
backport-10799-to-v0.21.x-branch
May 14, 2026
Merged

[v0.21.x-branch] Backport #10799: payments/db: remap legacy zero attempt IDs#10805
ziggie1984 merged 1 commit into
v0.21.x-branchfrom
backport-10799-to-v0.21.x-branch

Conversation

@github-actions
Copy link
Copy Markdown

Backport of #10799


Legacy KV payments can contain HTLC attempts with attempt ID zero. The SQL payments schema requires payment_htlc_attempts.attempt_index to be globally unique, so migrating multiple such attempts can fail with a UNIQUE constraint violation.

This PR allocates synthetic attempt indexes for legacy zero-ID attempts from the switch payment ID sequencer horizon, keeps nonzero attempt IDs unchanged, and advances the switch sequence once after migration validation succeeds.

It also wraps HTLC insert errors with the attempted index and payment hash so future migration failures identify the problematic row.

Fixes #10797

Legacy KV payments can contain HTLC attempts with attempt ID zero. The
SQL payments schema requires payment_htlc_attempts.attempt_index to be
globally unique, so migrating multiple such attempts can fail with a
UNIQUE constraint violation.

Allocate synthetic attempt indexes for legacy zero-ID attempts from the
switch payment ID sequencer horizon. Keep nonzero attempt IDs unchanged
and advance the switch sequence once after migration validation succeeds.

This preserves the SQL uniqueness invariant and prevents future switch
IDs from colliding with migrated attempts. It also wraps HTLC insert
errors with the attempted index and payment hash so future migration
failures identify the problematic row.

(cherry picked from commit c11a292)
Copy link
Copy Markdown
Collaborator

@ziggie1984 ziggie1984 left a comment

Choose a reason for hiding this comment

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

LGTM

@ziggie1984 ziggie1984 merged commit e316f43 into v0.21.x-branch May 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant