Redshift keeps lock on table after query completed

0

Hi!

I have the following situation:
My teammate ran a query from Python, and received the data into DataFrame. So the query had been completed, but he didn't close the connection.

I've tried to rename that table (using DBeaver client) and the query was running too long. When I checked the pg_locks table I found that those table was locked by my colleague.

I have tested with queries from Python on my side using 2 different modules psycopg2 and pyodbc, and found that tables are locked in both cases after the query completed, until the connection is closed by me.

Is it normal that Redshift keeps lock on table after the query had been completed?

已提問 5 年前檢視次數 1494 次
1 個回答
0
已接受的答案

Hi denisaleksandrov,

I think you may find this knowledge center article helpful: https://aws.amazon.com/premiumsupport/knowledge-center/prevent-locks-blocking-queries-redshift/

I suspect there is an open transaction or perhaps an open cursor on the session doing the SELECT ... that is still holding an AccessShareLock on the table when your other session it trying to get an AccessExclusiveLock while doing the ALTER TABLE ... RENAME ...

I hope this helps,
-Kurt

klarson
已回答 5 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南