Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctrl+C doesn't cancel a query in psql #26

Closed
GeoffMontee opened this issue Jun 7, 2015 · 4 comments
Closed

Ctrl+C doesn't cancel a query in psql #26

GeoffMontee opened this issue Jun 7, 2015 · 4 comments

Comments

@GeoffMontee
Copy link
Collaborator

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() and pg_terminate_backend() also have issues cancelling a running query?

I might need to write an interrupt handler for tds_fdw using dbsetinterrupt().

@GeoffMontee
Copy link
Collaborator Author

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)

@GeoffMontee
Copy link
Collaborator Author

It looks like a similar problem was recently fixed in postgres_fdw: postgres/postgres@f039eaa

@beaud76
Copy link

beaud76 commented Mar 28, 2022

"I might need to write an interrupt handler for tds_fdw using dbsetinterrupt()." => that would be great :-)

@GeoffMontee
Copy link
Collaborator Author

I believe @deathwish implemented this functionality in PR #336.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants