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

Add a hack to make migration deadlocks less likely in some common cases #6379

Merged
merged 1 commit into from Oct 28, 2023

Conversation

msullivan
Copy link
Member

This is a partial mitigation of #6304.

There are a lot of opportunities for deadlocks between DDL
(which can take a lot of full locks on things) and
long-running queries. One place this comes up is with views,
since recreating a view requires a lock. When adding things to
tables, our DDL must modify the table, then modify the view.
This poses a deadlock risk with queries, which nearly always
will access the view before accessing the table (since the table
is how they get to the view).

Put a hacky and hopefully temporary bandage around this particular
deadlock case by injecting a no-op ALTER VIEW before the first
ALTER of some table. This ensures that DDL locks the inhview
before the real table, making the lock order match the typical
query lock order.

This is a partial mitigation of #6304.

There are a lot of opportunities for deadlocks between DDL
(which can take a lot of full locks on things) and
long-running queries.  One place this comes up is with views,
since recreating a view requires a lock. When adding things to
tables, our DDL must modify the table, then modify the view.
This poses a deadlock risk with queries, which nearly always
will access the view before accessing the table (since the table
is how they get to the view).

Put a hacky and hopefully temporary bandage around this particular
deadlock case by injecting a no-op ALTER VIEW before the first
ALTER of some table.  This ensures that DDL locks the inhview
before the real table, making the lock order match the typical
query lock order.
@msullivan msullivan merged commit 4ab50b5 into master Oct 28, 2023
22 checks passed
@msullivan msullivan deleted the deadlock-hack branch October 28, 2023 00:11
msullivan added a commit that referenced this pull request Oct 28, 2023
…es (#6379)

This is a partial mitigation of #6304.

There are a lot of opportunities for deadlocks between DDL
(which can take a lot of full locks on things) and
long-running queries.  One place this comes up is with views,
since recreating a view requires a lock. When adding things to
tables, our DDL must modify the table, then modify the view.
This poses a deadlock risk with queries, which nearly always
will access the view before accessing the table (since the table
is how they get to the view).

Put a hacky and hopefully temporary bandage around this particular
deadlock case by injecting a no-op ALTER VIEW before the first
ALTER of some table.  This ensures that DDL locks the inhview
before the real table, making the lock order match the typical
query lock order.
aljazerzen pushed a commit that referenced this pull request Oct 30, 2023
…es (#6379)

This is a partial mitigation of #6304.

There are a lot of opportunities for deadlocks between DDL
(which can take a lot of full locks on things) and
long-running queries.  One place this comes up is with views,
since recreating a view requires a lock. When adding things to
tables, our DDL must modify the table, then modify the view.
This poses a deadlock risk with queries, which nearly always
will access the view before accessing the table (since the table
is how they get to the view).

Put a hacky and hopefully temporary bandage around this particular
deadlock case by injecting a no-op ALTER VIEW before the first
ALTER of some table.  This ensures that DDL locks the inhview
before the real table, making the lock order match the typical
query lock order.
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.

None yet

3 participants