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

[Bug] Ctrl-C does not terminating the current shell operation in pulsar shell #22671

Open
2 of 3 tasks
mukesh154 opened this issue May 8, 2024 · 2 comments
Open
2 of 3 tasks
Labels
type/bug The PR fixed a bug or issue reported a bug

Comments

@mukesh154
Copy link
Contributor

Search before asking

  • I searched in the issues and found nothing similar.

Read release policy

  • I understand that unsupported versions don't get bug fixes. I will attempt to reproduce the issue on a supported version of Pulsar client and Pulsar broker.

Version

3.2.2

Minimal reproduce step

Issue Description:
In the Pulsar-Shell environment, when a user presses Ctrl-C during a shell operation to terminate the running shell operation, an exception org.apache.pulsar.shell.PulsarShell$InterruptShellException occurs but it does not terminate the running shell operation, it prints the below stack trace and the current execution keeps on running. Ideally, it should terminate the current execution.

^CException in thread "SIGINT handler" org.apache.pulsar.shell.PulsarShell$InterruptShellException
	at org.apache.pulsar.shell.PulsarShell.lambda$run$2(PulsarShell.java:230)
	at org.jline.terminal.impl.AbstractTerminal.raise(AbstractTerminal.java:89)
	at org.jline.terminal.impl.PosixSysTerminal.lambda$handle$1(PosixSysTerminal.java:65)
	at org.jline.utils.Signals.lambda$register$1(Signals.java:53)
	at jdk.proxy2/jdk.proxy2.$Proxy3.handle(Unknown Source)
	at jdk.unsupported/sun.misc.Signal$InternalMiscHandler.handle(Signal.java:198)
	at java.base/jdk.internal.misc.Signal$1.run(Signal.java:219)
	at java.base/java.lang.Thread.run(Thread.java:840)

To reproduce it locally:

  • Run pulsar in standalone mode.
  • Start pulsar-shell using ./bin/pulsar-shell
  • Run some command for example, client produce my-topic -m "my-msg" -n 1000 or client consume -s s1 my-topic -n 1000
  • Then try to press Ctrl+C immediately. The expected behaviour should be that it terminate the above command immediately and return to the shell terminal. But it will print the above stack trace instead and keeps running the command till it finishes producing 1000 messages or till it finishes consuming 1000 messages respectively.

What did you expect to see?

When the user presses Ctrl-C to terminate the currently running shell operation it should terminate the current execution and return to the shell terminal.

What did you see instead?

On pressing Ctrl-C during a shell operation, the current shell operation keeps on running. In addition, it also prints the below stack trace:

^CException in thread "SIGINT handler" org.apache.pulsar.shell.PulsarShell$InterruptShellException
	at org.apache.pulsar.shell.PulsarShell.lambda$run$2(PulsarShell.java:230)
	at org.jline.terminal.impl.AbstractTerminal.raise(AbstractTerminal.java:89)
	at org.jline.terminal.impl.PosixSysTerminal.lambda$handle$1(PosixSysTerminal.java:65)
	at org.jline.utils.Signals.lambda$register$1(Signals.java:53)
	at jdk.proxy2/jdk.proxy2.$Proxy3.handle(Unknown Source)
	at jdk.unsupported/sun.misc.Signal$InternalMiscHandler.handle(Signal.java:198)
	at java.base/jdk.internal.misc.Signal$1.run(Signal.java:219)
	at java.base/java.lang.Thread.run(Thread.java:840)

Anything else?

This PR is related which fixes #19218.

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@mukesh154 mukesh154 added the type/bug The PR fixed a bug or issue reported a bug label May 8, 2024
@nodece
Copy link
Member

nodece commented May 10, 2024

The latest(3.3.0-SHAPSHOT) version works fine.

Welcome to Pulsar shell!
  Service URL: pulsar://localhost:6650/
  Admin URL: http://localhost:8080/

Type help to get started or try the autocompletion (TAB button).
Type exit or quit to end the shell session.

test(localhost)> 
Goodbye!

control + C, and you can see Goodbye!.

@mukesh154
Copy link
Contributor Author

mukesh154 commented May 13, 2024

@nodece I tried with latest(3.3.0-SHAPSHOT) version. And i see the same issue. It is reproducible on this version as well.
Might be you are misunderstanding the issue at hand.

The issue is not about exiting the shell with message Goodbye! on Ctrl+C. I know this part is working as expected but the issue I'm talking about is different.
The problem is when a user the presses Ctrl-C during an ongoing operation let's say client consume -s s1 my-topic -n 1000, the user wants to terminate the client consume command but as per current behaviour, the shell keeps running the command until it finishes. It just print an exception on pressing Ctrl-C org.apache.pulsar.shell.PulsarShell$InterruptShellException the stack trace is added in the issue description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

No branches or pull requests

2 participants