[
https://issues.apache.org/jira/browse/FLINK-23645?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
loyi updated FLINK-23645:
-------------------------
Attachment: image-2021-08-05-18-31-50-487.png
> Sqlclient doesn't response CTRL-C correctly before Executor ResultView
> opening.
> -------------------------------------------------------------------------------
>
> Key: FLINK-23645
> URL: https://issues.apache.org/jira/browse/FLINK-23645
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / Client
> Affects Versions: 1.13.1
> Reporter: loyi
> Priority: Minor
> Attachments: image-2021-08-05-18-31-50-487.png
>
>
> If we press ctrl-c before the *ResultView* opened,the terminal will exits
> without any prompt.
> For example:
> {noformat}
> Flink SQL> select 1;
> ^C
> [bot@ bin]${noformat}
> After analsis, i found out the reason is Sqlclient doesn't register
> *Signal.INT* handler before *callOperation*, then jvm default handler
> executes and exit.
>
> Suggestion:
> We could just interupt the Executor when we receive *Signal.INT*
>
> {code:java}
> private void callOperation(Operation operation, ExecutionMode mode) {
> validate(operation, mode);
> final Thread thread = Thread.currentThread();
> final Terminal.SignalHandler previousHandler =
> terminal.handle(Terminal.Signal.INT, (signal) ->
> thread.interrupt());
> try {
> if (operation instanceof QuitOperation) {
> // QUIT/EXIT
> callQuit();
> } else if (operation instanceof ClearOperation) {
> // CLEAR
> callClear();
> } else if (operation instanceof HelpOperation) {
> // HELP
> callHelp();
> } else if (operation instanceof SetOperation) {
> // SET
> callSet((SetOperation) operation);
> } else if (operation instanceof ResetOperation) {
> // RESET
> callReset((ResetOperation) operation);
> } else if (operation instanceof CatalogSinkModifyOperation) {
> // INSERT INTO/OVERWRITE
> callInsert((CatalogSinkModifyOperation) operation);
> } else if (operation instanceof QueryOperation) {
> // SELECT
> callSelect((QueryOperation) operation);
> } else if (operation instanceof ExplainOperation) {
> // EXPLAIN
> callExplain((ExplainOperation) operation);
> } else if (operation instanceof BeginStatementSetOperation) {
> // BEGIN STATEMENT SET
> callBeginStatementSet();
> } else if (operation instanceof EndStatementSetOperation) {
> // END
> callEndStatementSet();
> } else {
> // fallback to default implementation
> executeOperation(operation);
> }
> } finally {
> terminal.handle(Terminal.Signal.INT, previousHandler);
> }
> }{code}
> **
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)