Closed GeoffMontee closed 1 year ago
It looks like this affects both pg_cancel_backend()
and pg_terminate_backend()
.
postgres=# SELECT pid, state, query FROM pg_stat_activity;
pid | state | query
-------+--------+-------------------------------------------------
7245 | active | SELECT * FROM mssql_table;
11207 | active | SELECT pid, state, query FROM pg_stat_activity;
(2 rows)
postgres=# SELECT pg_cancel_backend(7245);
pg_cancel_backend
-------------------
t
(1 row)
postgres=# SELECT pid, state, query FROM pg_stat_activity;
pid | state | query
-------+--------+-------------------------------------------------
7245 | active | SELECT * FROM mssql_table;
11207 | active | SELECT pid, state, query FROM pg_stat_activity;
(2 rows)
postgres=# SELECT pg_terminate_backend(7245);
pg_terminate_backend
----------------------
t
(1 row)
postgres=# SELECT pid, state, query FROM pg_stat_activity;
pid | state | query
-------+--------+-------------------------------------------------
7245 | active | SELECT * FROM mssql_table;
11207 | active | SELECT pid, state, query FROM pg_stat_activity;
(2 rows)
It looks like a similar problem was recently fixed in postgres_fdw: https://github.com/postgres/postgres/commit/f039eaac7131ef2a4cf63a10cf98486f8bcd09d2
"I might need to write an interrupt handler for tds_fdw using dbsetinterrupt()." => that would be great :-)
I believe @deathwish implemented this functionality in PR #336.
Ctrl+C doesn't cancel a query running against tds_fdw in psql. I'm guessing any program linked with libpq will not be able to cancel a query running against tds_fdw.
I wonder if
pg_cancel_backend()
andpg_terminate_backend()
also have issues cancelling a running query?I might need to write an interrupt handler for tds_fdw using dbsetinterrupt().