Skip to content

Fix: Handle 'slot already exists' error gracefully during node join#307

Open
MonkeyGyu wants to merge 1 commit into
aws:mainfrom
MonkeyGyu:main
Open

Fix: Handle 'slot already exists' error gracefully during node join#307
MonkeyGyu wants to merge 1 commit into
aws:mainfrom
MonkeyGyu:main

Conversation

@MonkeyGyu

Copy link
Copy Markdown

Issue #, if available:
N/A (addresses existing TODO in code)

Description of changes:
Fix handling of "slot already exists" error during dynamic node join.

When an apply worker crashes after creating a remote replication slot
but before committing the local replication origin, the worker enters
an infinite crash loop because CREATE_REPLICATION_SLOT fails with
"already exists" error.

This patch:

  • Catches ERRCODE_DUPLICATE_OBJECT (42710) from CREATE_REPLICATION_SLOT
  • Reuses the existing slot instead of failing with FATAL
  • Creates the local replication origin if missing

When an apply worker crashes after creating a remote slot but before
committing the local replication origin, subsequent restart attempts
would fail with FATAL error because the slot already exists.

This patch:
- Catches ERRCODE_DUPLICATE_OBJECT (42710) error from CREATE_REPLICATION_SLOT
- Logs a message and continues with the existing slot
- Creates the local replication origin if it doesn't exist
- Allows dynamic node addition to work without manual intervention
@sharmay sharmay self-assigned this Jan 1, 2026
@sharmay

sharmay commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Like the idea and it matches with TODO comment but when the slot already exists, the code assumes it's the correct slot (same plugin, same database). A malicious or stale slot with the same name but wrong configuration would silently be reused.

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