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

Support closing all connections to a database on database drop #6780

Merged
merged 11 commits into from
Feb 15, 2024

Conversation

fantix
Copy link
Member

@fantix fantix commented Feb 5, 2024

drop database will now interrupt and close idle frontend connections before the actual backend database is dropped. Note, idle-in-transaction frontend connections will also be closed.

@msullivan you can configure close_frontend_conns=True conditionally in execute.pyx.

Fixes #6776

  • Add a test

@fantix
Copy link
Member Author

fantix commented Feb 5, 2024

Hmm, while adding a test, I realized this was not enough. on_before_drop_db() will abort if any frontend connections are found, regardless of being idle or not. So we can't even reach the backend drop database. I'll add an early kick here.

Comment on lines +258 to +280
# The frontend connection should be closed by the server now
self.assertTrue(conn.is_closed())
Copy link
Member

Choose a reason for hiding this comment

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

Are you confident that this will be reflected in the client state already?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, the test passed at b851e5c - could be flaky but I haven't met

@msullivan msullivan requested a review from elprans February 12, 2024 23:50
@msullivan msullivan marked this pull request as ready for review February 12, 2024 23:50
_, _, name = kids
self.val = qlast.DropDatabase(name=name.val)

def reduce_DROP_BRANCH_RESET_CONNECTIONS_DatabaseName(self, *kids):
Copy link
Member

Choose a reason for hiding this comment

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

Not sure I like the formulation. It doesn't read very well and would scale poorly if we add more options. I actually like PostgreSQL's drop database foo [with option, ...] somewhat more. I also like force as a shorter spelling (a-la Postgres also)

Copy link
Member

Choose a reason for hiding this comment

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

Sure

@msullivan msullivan requested review from elprans and 1st1 February 14, 2024 00:11
@msullivan msullivan changed the title Close all connections to a database on database drop Support closing all connections to a database on database drop Feb 15, 2024
@msullivan msullivan merged commit 561c9d1 into master Feb 15, 2024
24 checks passed
@msullivan msullivan deleted the t6776-stop-fe-conn branch February 15, 2024 22:05
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.

Provide a way to force close all connections to a database
3 participants