Yesterday, I added the pldbgapi extension in my Postgres DB to debug a function. I was using PgAdmin for debugging the same. But today, when I tried invoking a simple query, it was taking a lot of time to execute. I tried to find out the active sessions using the below query:
select * from pg_stat_activity where datname = 'dbname';
In the results, 6 sessions were there, out of which 4 were active. On checking the query that these active sessions were executing, I found that all the 4 sessions were executing the same query and these queries were invoked yesterday when debugging the function.
So every time I debug a function, a new session was created and all the created sessions didn't get closed and remained in the active state.
I tried to close the session using
pg_cancel_backend but nothing works and all 4 sessions remain in the active state.
I didn't know how this happened and why I am not able to close these connections.