One of my dragon scripts ran some optional table queries on the Postgres database. Something went wrong and the tables were locked. When I run any queries in those tables, it tells me the query to run and nothing happens. Currently, I'm able to remove the lock only by closing my system and restarting it. Please tell me a better way This is a Windows host.
You should check the lock:
Select L *, a. * PG_Locks JOIN pg_stat_activity A USING (pid) where not provided;
You will see a list of waiting sessions and the following:
SELECT l *, A. * From pg_locks i JOG pg_stat_activity where a USING (pid) is given and in (database, connection) (select database, relation to pg_locks, where not provided);
will give you a list of Blocked sessions if you use to get the column-per-line output, it is better to see such information.
I advise you to look at this question too: (though it does speak bout In your case, I blocked < / Em> Try to identify the sessions and find out why they are blocking. The most specific case in my experience - anybody entering DROP TABLE <<>
COMMIT
Forget about it and went out for lunch if you are sure that it will not harm your system, you can Busted can kill session:
SELECT pg_terminate_backend (pid);
Comments
Post a Comment