Cancel query on Ctrl-C when --pager used#88935
Conversation
Trying to process SIGINT query and terminate the pager. I have a great
concerns about what should be done: different pages behaves differently.
Some could path-through the signal, some -- not. Different signals could
be handled differently, etc. The patch is more like fast-and-dirty fix
of particular use cases:
pagers: `more`, `less`
queries:
- `SELECT 3`
- `SELECT * FROM numbers(1e12) format Null`
- `SELECT * FROM numbers(300)`
behavior:
- try to wait for result (for short queries) and exit from pager
- for long-running queries, try cancel and then assert that pager is
terminated
|
@azat, could you take a look? |
azat
left a comment
There was a problem hiding this comment.
Thanks for taking a look!
Looks OK, but let's add a test, I do not want to break it again (you can take a look at expect tests, and use query like select sleepEachRow(1) from numbers(30) settings max_block_size=1, function_sleep_max_microseconds_per_block=30e6)
Can you also address minor issues here:
- missing redraw in case of cancellation, though I cannot reproduce it, but after a simple query (
select sleepEachRow(1) from numbers(3) settings max_block_size=1) there was not prompt - and sometimes there are extra new lines - https://pastila.nl/?07b9abe6/d5d459bed20554da7ced8d4559429226#mU1u2N+22zv57/tl9tLobw==
|
@azat, here is the test. BTW, I struggled to test proper less exit |
tests/queries/0_stateless/03701_pager_proper_termination.expect
Outdated
Show resolved
Hide resolved
tests/queries/0_stateless/03701_pager_proper_termination.expect
Outdated
Show resolved
Hide resolved
Hm, I think it should simply by sending |
|
@GSokol what about two other issues? |
|
Workflow [PR], commit [8099349] Summary: ❌
|
So:
As I understand this expectation insures, that the prompt is alweys remndered, isn't it?
I would check that there is no new line in the end. |
Not exactly, when you launch client it does not execute pager yet, while the problem I found was that after pager had been executed and I pressed Ctrl-C, there was no prompt. Maybe you can try to reproduce it. |
|
Also about |
Sorry, the wrong line number. Here is the proper one. |
tests/queries/0_stateless/03701_pager_proper_termination.expect
Outdated
Show resolved
Hide resolved
@GSokol can you point me to a relevant code in the patch for this behavior? |
|
@GSokol I've fixed the test and now it is ready to land! Thanks for taking a look into this. |
365fc6d
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
User can now cancel the query by pressing Ctrl-C when the pager is running. Resolves #80778
Documentation entry for user-facing changes
Details
Trying to process SIGINT query and terminate the pager. I have great concerns about what should be done: different pagers behave differently. Some could pass-through the signal, some -- not. Different signals could be handled differently, etc. The patch is more like a fast-and-dirty fix of particular use cases:
pagers:
more,lessqueries:
SELECT 3SELECT * FROM numbers(1e12) format NullSELECT * FROM numbers(300)behavior:
Resolves #80778