Postgres transaction locks

I download my node.js. application At some point, I get to the state in which requests are expected, and, as far as I know, due to a blocked transaction. This is the last log statement:

SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

And in pg_lockI have 4 lines with the above query, which GRANTED = true, with mode ExclusiveLock.

Where should I look for a mistake? If in this lock request I do a lot of operations insertand updateshould there be an isolation level REPEATABLE READ? Is there any way to debug / handle such situations? Is there any timeout mechanism that blocks, so the application can be easily / automatically released and not block further requests?

The side question (since I'm not looking for a tool directly): are there any tools for monitoring and identifying such situations? (I was hoping to use Munin.)

I use nodejs 4.2.1 with expression 4.13.3, sexualize 3.19.3 as Postgres 9.4.1 ORM.

+4
source share
2 answers

Welcome to PostgreSQL transaction transaction :)

You can spend a lot of time trying to figure out exactly where the lock occurs and why. But there is very little chance that this will help you in resolving the situation.

The general recipe for solving such situations is as follows:

  • , - . , , , IO
  • , , .. .
  • , . .

, ;)

+1

, 5 , , , postgres. , pg_stat_activity ​​ pg_locks.

, , ;

, . postgres.

4 , .

, , postgres, , , seciezlize .

sequiezlize , 5, .

, 5- , - 4, 5, - , , , .

NOWAIT postgres, .

, , - .

0

All Articles