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

connect: fix terminal after executing os.exit() #440

Merged
merged 1 commit into from
May 2, 2023

Conversation

better0fdead
Copy link
Contributor

@better0fdead better0fdead commented Apr 27, 2023

Fixed terminal brake after os.exit() in tt connect session. Have done it by adding workaround for the bug(c-bata/go-prompt#228) in case of executing os.exit().

Proof:

Terminal 1:

tarantool> better0fdead@better0fdead:~/.local/share/Trash$ tarantool
Tarantool 2.11.0-entrypoint-635-g5a38c5c90
type 'help' for interactive help
tarantool> box.cfg{listen=3305}
2023-04-27 12:44:48.029 [34240] main/103/interactive I> Tarantool 2.11.0-entrypoint-635-g5a38c5c90
2023-04-27 12:44:48.029 [34240] main/103/interactive I> log level 5
2023-04-27 12:44:48.030 [34240] main/103/interactive I> wal/engine cleanup is paused
2023-04-27 12:44:48.030 [34240] main/103/interactive I> mapping 268435456 bytes for memtx tuple arena...
2023-04-27 12:44:48.030 [34240] main/103/interactive I> Actual slab_alloc_factor calculated on the basis of desired slab_alloc_factor = 1.044274
2023-04-27 12:44:48.030 [34240] main/103/interactive I> mapping 134217728 bytes for vinyl tuple arena...
2023-04-27 12:44:48.034 [34240] main/103/interactive I> Recovering snapshot with schema version 2.11.0
2023-04-27 12:44:48.043 [34240] main/103/interactive I> update replication_synchro_quorum = 1
2023-04-27 12:44:48.043 [34240] main/103/interactive I> instance uuid 7a61e056-9b15-4c30-b6a1-f0110ea030aa
2023-04-27 12:44:48.044 [34240] main/103/interactive I> instance vclock {1: 5}
2023-04-27 12:44:48.044 [34240] main/103/interactive I> tx_binary: bound to 0.0.0.0:3305
2023-04-27 12:44:48.044 [34240] main/103/interactive I> recovery start
2023-04-27 12:44:48.044 [34240] main/103/interactive I> recovering from `./00000000000000000000.snap'
2023-04-27 12:44:48.057 [34240] main/103/interactive I> cluster uuid f0bd4cd7-d6df-42d0-8a9c-930cd9727f65
2023-04-27 12:44:48.065 [34240] main/103/interactive I> assigned id 1 to replica 7a61e056-9b15-4c30-b6a1-f0110ea030aa
2023-04-27 12:44:48.065 [34240] main/103/interactive I> update replication_synchro_quorum = 1
2023-04-27 12:44:48.065 [34240] main/103/interactive I> recover from `./00000000000000000000.xlog'
2023-04-27 12:44:48.065 [34240] main/103/interactive I> done `./00000000000000000000.xlog'
2023-04-27 12:44:48.065 [34240] main/103/interactive I> recover from `./00000000000000000005.xlog'
2023-04-27 12:44:48.065 [34240] main/103/interactive I> done `./00000000000000000005.xlog'
2023-04-27 12:44:48.066 [34240] main/103/interactive I> ready to accept requests
2023-04-27 12:44:48.066 [34240] main/103/interactive I> leaving orphan mode
2023-04-27 12:44:48.066 [34240] main/104/gc I> wal/engine cleanup is resumed
2023-04-27 12:44:48.066 [34240] main/103/interactive I> set 'listen' configuration option to 3305
2023-04-27 12:44:48.066 [34240] main/103/interactive I> set 'log_level' configuration option to 5
2023-04-27 12:44:48.066 [34240] main/103/interactive I> set 'log_format' configuration option to "plain"
---
...

2023-04-27 12:44:48.066 [34240] main/105/checkpoint_daemon I> scheduled next checkpoint for Thu Apr 27 14:20:21 2023
tarantool> box.schema.user.create("user", { password = "password", if_not_exists = true })
---
...

tarantool> box.schema.user.grant("user", "super", nil, nil, { if_not_exists = true })
---
...

2023-04-27 12:45:10.627 [34240] main/114/iproto.shutdown I> tx_binary: stopped
2023-04-27 12:45:13.619 [34240] main/102/on_shutdown fiber.c:642 E> TimedOut: timed out
2023-04-27 12:45:13.619 [34240] main/102/on_shutdown main.cc:157 E> on_shutdown triggers failed
2023-04-27 12:45:13.620 [34240] main/102/on_shutdown trigger.cc:251 E> TimedOut: timed out

Terminal 2:

better0fdead@better0fdead:~/tt$ ./tt connect 127.0.0.1:3305 -u user -p password
   • Connecting to the instance...
   • Connected to 127.0.0.1:3305

127.0.0.1:3305> os.exit()
   ⨯ Connection was closed. Probably instance process isn't running anymore
better0fdead@better0fdead:~/tt$ ps
    PID TTY          TIME CMD
  33829 pts/1    00:00:00 bash
  34276 pts/1    00:00:00 ps

Closes #425

@better0fdead better0fdead marked this pull request as ready for review April 27, 2023 09:58
cli/connect/console.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@LeonidVas LeonidVas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Thank you for the patch.
See a comment bellow.

@@ -247,6 +247,14 @@ func getExecutor(console *Console) prompt.Executor {
var data string
if _, err := console.conn.Eval(consoleEvalFuncBody, args, opts); err != nil {
if err == io.EOF {
if strings.Contains(console.input, "os.exit(") {
console.Close()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't dug deep, but the same problem has already been fixed in f1111a9 .
Maybe we should

  • move the code fixing the console into a separate function
  • call it from console.close().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f1111a9 Doesn't fix it. Moved code

@better0fdead better0fdead force-pushed the better0fdead/gh-425-terminal branch 2 times, most recently from 2504007 to d331a2d Compare April 28, 2023 14:38
Fixed terminal brake after os.exit() in tt connect session.
Have done it by adding workaround for the bug(c-bata/go-prompt#228)
in case of executing os.exit().

Closes #425
@LeonidVas LeonidVas added the full-ci Enables full ci tests label Apr 28, 2023
@psergee psergee merged commit 9596508 into master May 2, 2023
@psergee psergee deleted the better0fdead/gh-425-terminal branch May 2, 2023 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
full-ci Enables full ci tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

terminal session is broken after os.exit() in tt connect session
3 participants