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 年前1495 查看次数
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 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则