[ https://issues.apache.org/jira/browse/FLINK-23645?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17393961#comment-17393961 ]
Jark Wu commented on FLINK-23645: --------------------------------- [~loyi] are you willing to contribute the fix? cc [~fsk119] > 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, > image-2021-08-05-18-44-08-453.png > > > If we press ctrl-c before the *ResultView* opened,the terminal will exits > without any prompt. > For example: > !image-2021-08-05-18-31-50-487.png! > 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} > > After fixed: > !image-2021-08-05-18-44-08-453.png! -- This message was sent by Atlassian Jira (v8.3.4#803005)