Skip to content

Conversation

@kennyu
Copy link

@kennyu kennyu commented Nov 18, 2025

Remove conditional checks in Connection.Manager.terminate/2 to ensure replication slots and publications are always cleaned up during graceful shutdown, preventing resource leaks during deployment cycles.

Fixes #3284

Remove conditional checks in Connection.Manager.terminate/2 to ensure
replication slots and publications are always cleaned up during graceful
shutdown, preventing resource leaks during deployment cycles.

Fixes electric-sql#3284
@kennyu kennyu closed this Nov 18, 2025
@kennyu kennyu reopened this Nov 18, 2025
Copy link
Contributor

@icehaunter icehaunter left a comment

Choose a reason for hiding this comment

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

Unfortunately dropping a slot always like that means Electric can never continue, so any on-disk state will be invalid on startup, dropping all shapes.

I'm actually unsure what you meant by the original issue, @balegas - are we moving to transient state only?

@msfstef
Copy link
Contributor

msfstef commented Nov 19, 2025

It is currently undocumented but you an set an environment variable CLEANUP_REPLICATION_SLOTS_ON_SHUTDOWN to true and it will create the slot as a temporary slot which is automatically cleaned up when the connection is lost.

As @icehaunter pointed out, cleaning up the slot means you cannot recover any data, so the above might be what you need.

@kennyu kennyu closed this Nov 20, 2025
@kennyu kennyu deleted the fix/defensive-replication-slot-cleanup branch November 20, 2025 02:52
@balegas
Copy link
Contributor

balegas commented Nov 20, 2025

Agree with both. way to achieve this is to use the temporary slot.

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.

Explicit Postgres connection cleanup on graceful shutdown

4 participants