1

I have a table A, that is referencing two other tables B and C. I would like to understand what's happening exactly when i am dropping A.

When dropping A my understanding is that an access exclusive lock needs to be acquired on A and B (mainly to remove triggers ?).

I am curious to know how these locks are done: are locks on B and C acquired at the same time ? or sequentially ?

If that's the former that could explain some deadlock that i am sometimes noticing when dropping tables

Thanks

asked May 22, 2024 at 9:00

1 Answer 1

0

You are right: if you drop a table, all its foreign key constraints are dropped as well, and dropping the system triggers on the referenced table requires an ACCESS EXCLUSIVE lock there. These locks are all taken during the execution of the DROP TABLE statement, in the same transaction. These locks will be taken one after the other, so if you have another transaction that needs these tables, you can easily get a deadlock.

answered May 22, 2024 at 9:14

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.