-
Notifications
You must be signed in to change notification settings - Fork 174
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
Drop replication slot on tenant delete #1965
Conversation
Electric.TenantSupervisor.start_link([]) | ||
{:ok, _} = | ||
Electric.TenantSupervisor.start_link(electric_instance_id: ctx.electric_instance_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This silently failed before
@@ -67,20 +68,26 @@ defmodule Support.ComponentSetup do | |||
] | |||
|
|||
:ok = Electric.TenantManager.store_tenant(tenant, tenant_opts) | |||
Electric.TenantSupervisor.start_tenant(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This silently fails so I've removed it. Typically it's run inside with_complete_stack
that also the shape cache, shape log collector which then conflict with the ones created inside the tenant. I spent some time trying to fix this but was spending too much time on it so will leave that work for a separate PR.
|
||
defp drop_publication(state) do | ||
publication_name = Keyword.fetch!(state.replication_opts, :publication_name) | ||
Postgrex.query!(state.pool_pid, "DROP PUBLICATION #{publication_name}", []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This runs the query directly on the pool rather than using the Postgrex.ReplicationConnection
:query
return term like we do for creating the publication. This is because there isn't a way to switch from stream mode back into query mode without waiting for something to arrive in the stream. WAL Keep-alives will eventually come but this is rather slow. Running the query directly seemed a better option.
@@ -0,0 +1,14 @@ | |||
defmodule Electric.TenantTables do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this module to Tenant.Tables
one level down? Top level is already quite crowded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
✅ Deploy Preview for electric-next ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Following on from #1965 this drops the replication slot as well as the publication.
Fixes #1924