Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inactive replication slot causing warnings on DO managed Postgres #1285

Open
jocubeit opened this issue May 21, 2024 · 6 comments
Open

Inactive replication slot causing warnings on DO managed Postgres #1285

jocubeit opened this issue May 21, 2024 · 6 comments
Assignees

Comments

@jocubeit
Copy link

jocubeit commented May 21, 2024

Hi,

I set up a single primary managed Postgres on Digital Ocean, and ElectricSQL in on their App Platform.

I have not created any tables or electrified anything yet. I also do not have any clients connecting yet.

I received a warning email this morning about Inactive or Lagging Replication Slots Detected.

I see that the replication slot named electric_replication_out_defaultdb is inactive while the one named electric_replication_out_defaultdb_rc is active. The inactive slot is the cause of the warning.

Is it supposed to be inactive? Does in become active when I connect a client? Is the inactive slot used?

Any advice much appreciated.

Copy link

linear bot commented May 21, 2024

@jocubeit
Copy link
Author

I edited my question after noticing some typos - not sure if this is picked up in Linear.

@alco
Copy link
Member

alco commented May 21, 2024

Hey @jocubeit. This is expected behaviour for Electric. You can read more about the need to keep around a replication slot in our docs, here.

The summary is that one replication slot is used to retain a history of transactions in Postgres that allows Electric to resume streaming transactions to clients after a restart. The other slot is temporary, it is only created when Electric is running and is used for its logical replication connection to Postgres.

Could you share a screenshot of the DO email?

@jocubeit
Copy link
Author

Yes no problem sharing.

Screenshot 2024-05-21 at 4 10 42 PM

The following query:

SELECT slot_name, restart_lsn, active FROM pg_replication_slots WHERE slot_type = 'logical';

results in:

Screenshot 2024-05-21 at 4 14 44 PM

@jocubeit
Copy link
Author

I got the same email again this morning.

What I'm not clear about is whether the electric_replication_out_defaultdb slot should be inactive? You state it's a temporary slot used while the electric sync service is running. If it's running shouldn't it be active? My electric sync service is running, what would happen if I deleted this row? Would it be recreated, or is it only created at service initialization?

@alco
Copy link
Member

alco commented May 26, 2024

Thanks for the additional context!

To clarify: electric_replication_out_defaultdb_rc is the temporary one. It only exists while Electric has an active database connection. If you stop Electric, you'll see the slot disappear.

The other slot is persisted, Electric uses that to maintain a point in time which it can resuming streaming from after a shutdown/restart.

You won't be able to delete the *_rc slot while it's in use, and there's no point in doing that. If you delete the persisted slot (the one named electric_replication_out_defaultdb), Electric will create a new one upon restart, but it won't be able to resume the logical replication stream from exactly the point where it had left off. The consequence of this is that clients connecting to Electric will be asked to reset their local state and re-fetch their shape subscription data from the latest Postgres state before they can resuming real-time streaming of transactions from Electric.

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

No branches or pull requests

2 participants