Kettle leads data to cause Postgresql lock table

Scenario: Kettle data extraction nodes A and B, Postgresql cluster data management node C. A and B are running data extraction tasks at the same time, and two tasks are stuck during the running process. So I plan to restart the extraction task, first truncate these two tables (one task corresponds to one table), the problem occurs, one table is stuck in truncate execution, delete is stuck, and drop table is not enough, but insert and select are available. The watch must be locked!

Solution:

1. Query the locks that exist in the table

select a.locktype,a.database,a.pid,a.mode,a.relation,b.relname

from pg_locks a

join pg_class b on a.relation = b.oid

where upper(b.relname) = 'TABLE_NAME';

 

After checking, it is found that there is indeed a lock, as follows:

 locktype | database |  pid  |      mode       | relation | relname

----------+----------+-------+-----------------+----------+---------

 relation |   439791 | 26752 | AccessShareLock |  2851428 |table_name

 relation |   439791 | 26752 | ExclusiveLock   |  2851428 |table_name

 

2. According to the pid found above, go to the table pg_stat_activity to query the SQL statement corresponding to the lock:

select usename,current_query ,query_start,procpid,client_addr from pg_stat_activity where procpid=17509;

as follows:

  usename  |  current_query                      |          query_start          | procpid |  client_addr  

-----------+---------------------------------------------------------------------------------------------------------------+-------------------------------+---------+----------------

 gpcluster | DELETE FROM TABLE_NAME WHERE A = 1  | 2011-05-14 09:35:47.721173+08 |   17509 | 192.168.165.18

(1 row)

 

3. Killing method: In the Postgresql database management server, query the process PID and then Kill it.

Note that the process cannot be found on nodes A and B, because the copy statements organized by A and B are to be executed in the database, and a copy statement corresponds to a process.

 

 > ps -ef | grep 17509

postgres 17509  4868  1 Nov18 ?        00:11:19 postgres: postgres mydb 192.168.165.18(56059) SELECT             

postgres 30838 30800  0 15:19 pts/3    00:00:00 grep 17509

> kill -9 17509

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326265811&siteId=291194637