Exclusive PostgreSQL lockout terminates

My application tests are pretty complicated in the database. They run the create, drop, and alter table statements. However, I would still expect postresql to handle them even in the event of a deadlock (for example, it will detect a lock and pull out one thread). I also do not execute requests at the same time.

However, in my case, it just hangs, and I have to manually kill them manually (this works if I change the startup order a little, but it does not give me confidence). Locks indicate that the create table statement has an exclusive lock, and the transaction also has one.

Has anyone experienced something like this? Are there any server settings that might help? Or just advise?

+3
source share
1 answer

PostgreSQL automatically detects deadlocks. Most likely, you are only blocking some statement somewhere that has not yet ended. A deadlock occurs only if two operators are waiting for each other.

If you examine your lock tree to the root (d lock b lock on a has in the root directory), you will most likely find a transaction somewhere that either takes a long time to start, or it does not execute properly, but simply finds in idle mode.

Since you mention threads, remember that all client libraries are not necessarily thread safe on the client side.

+7
source

Source: https://habr.com/ru/post/1713055/


All Articles