I was debugging my PostgreSQL database and found 7 queries for "DEALLOCATE pdo_stmt" that have been running for 15 days.
Reading from the PostgreSQL docs, I see that these queries are supposed to deallocate prepared statements after a session ends, but i can't believe that it can take so much time.
Also, other projects in the company have found that the same queries have been running for an unusual amounts of time.
The DB is hosted on an AWS RDS, and is being accessed using Laravel 5.2.
The query I ran was:
SELECT
pid,
now() - query_start as duration,
query,
state
FROM pg_stat_activity
where now() - query_start > interval '2 minutes'
order by now() - query_start desc
An the result was:
10169 15 days 23:52:04.697072 DEALLOCATE pdo_stmt_00000003 idle
10170 15 days 23:52:04.64288 DEALLOCATE pdo_stmt_00000003 idle
10171 15 days 23:52:04.616907 DEALLOCATE pdo_stmt_00000003 idle
10172 15 days 23:52:04.60968 DEALLOCATE pdo_stmt_00000003 idle
10174 15 days 23:52:04.604393 DEALLOCATE pdo_stmt_00000003 idle
10173 15 days 23:52:04.596357 DEALLOCATE pdo_stmt_00000003 idle
10175 15 days 23:52:04.591835 DEALLOCATE pdo_stmt_00000003 idle