[SERVER-34160] Mongo client run buffered command when terminated. Created: 28/Mar/18  Updated: 29/Oct/23  Resolved: 26/Jun/18

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 3.4.10
Fix Version/s: 3.4.17, 3.6.7, 4.0.1, 4.1.1

Type: Bug Priority: Minor - P4
Reporter: 아나 하리 Assignee: Jonathan Reams
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.0, v3.6, v3.4
Steps To Reproduce:

## ------------------------
## Terminal 1
## ------------------------
$ echo $$
65551
$ mongo admin -uuser -p
MongoDB shell version v3.4.10
Enter password:
connecting to: mongodb://127.0.0.1:27017/admin
MongoDB server version: 3.4.10
 
shard01:PRIMARY (admin) 17:08:23> use admin
switched to db admin
shard01:PRIMARY (admin) 17:08:26> db.test.find()  ==> No documents in this collection
shard01:PRIMARY (admin) 17:08:33> db.test.insert({text:"not yet executed"})  ==> Not yet execute this command (just typing)

## ------------------------
## Terminal 2
## ------------------------
$ kill -SIGKILL 65551   ==> Kill terminal-1
 
## After terminal-1 is killed
$ mongo admin -uuser -p
MongoDB shell version v3.4.10
Enter password:
connecting to: mongodb://127.0.0.1:27017/admin
MongoDB server version: 3.4.10
 
shard01:PRIMARY (admin) 17:09:30> use admin
switched to db admin
shard01:PRIMARY (admin) 17:09:31> db.test.find()
{ "_id" : ObjectId("5abb4da6f63b9d80af086edd"), "text" : "not yet executed" }  ==> Document is inserted 

Sprint: Platforms 2018-07-02
Participants:

 Description   

When mongo client(mongo shell) is running within linux shell,
if linux shell is killed or terminated (sigterm), mongo client run buffered command(input command but not yet executed by ENTER/RETURN keyboard) before terminated.

I don't know this is mongo shell issue or linux terminal.
But this issue is not happened another CLI client(like mysql client in same scenario).

This is relatively critical issue what command user typed on mongo client shell.



 Comments   
Comment by Githook User [ 10/Jul/18 ]

Author:

{'username': 'jbreams', 'name': 'Jonathan Reams', 'email': 'jbreams@mongodb.com'}

Message: SERVER-34160 Exit shell cleanly on SIGHUP

(cherry picked from commit 43695048b2359962549dc11ce7d075375b7fb3cf)
Branch: v4.0
https://github.com/mongodb/mongo/commit/2d498837ce5d795b026a7f901f469e2bf8ea4cfc

Comment by Githook User [ 10/Jul/18 ]

Author:

{'username': 'jbreams', 'name': 'Jonathan Reams', 'email': 'jbreams@mongodb.com'}

Message: SERVER-34160 Exit shell cleanly on SIGHUP

(cherry picked from commit 43695048b2359962549dc11ce7d075375b7fb3cf)
Branch: v3.6
https://github.com/mongodb/mongo/commit/0de8b069393e2905eebeaa46e6e4f67b35cb67ad

Comment by Githook User [ 10/Jul/18 ]

Author:

{'username': 'jbreams', 'name': 'Jonathan Reams', 'email': 'jbreams@mongodb.com'}

Message: SERVER-34160 Exit shell cleanly on SIGHUP

(cherry picked from commit 43695048b2359962549dc11ce7d075375b7fb3cf)
Branch: v3.4
https://github.com/mongodb/mongo/commit/d507d180d9158aef73d7f77f35e690ee4610efd4

Comment by Githook User [ 26/Jun/18 ]

Author:

{'username': 'jbreams', 'name': 'Jonathan Reams', 'email': 'jbreams@mongodb.com'}

Message: SERVER-34160 Exit shell cleanly on SIGHUP
Branch: master
https://github.com/mongodb/mongo/commit/43695048b2359962549dc11ce7d075375b7fb3cf

Comment by Nick Brewer [ 18/Jun/18 ]

matt.lee

Thanks for clarifying - I was able to reproduce this behavior in my testing. We'll keep this issue updated as we look into this further.

Nick

Comment by 아나 하리 [ 15/Jun/18 ]

Hi Nick.

 

For just checking in, I have killed linux shell process not mongo client shell process.

Did you kill linux shell process during your test ?

 

 

The Linux distribution and version ( the output of cat /etc/os-release should contain everything, but it varies across distributions)

$ cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

 

The specific terminal application you're using (Konsole, Terminator, xfce4-terminal, etc)

iTerm2 (Build 3.1.6 beta5) + macOS 10.13.1

 

The shell (bash, zsh, etc), and shell version - the output of $SHELL --version should be enough

$ $SHELL --version
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

 

Logs from the time when you kill the mongo shell and the buffered command is run

==> Nothing in mongod.log and there's only "session terminating message" on /var/log/message.

 

 

Comment by Nick Brewer [ 14/Jun/18 ]

Hi matt.lee

We've had some trouble recreating this on our end - just to confirm, are you able to reproduce this behavior? If so, I'd like to get some additional information about the environment you're using when you encounter this, specifically:

  • The Linux distribution and version ( the output of cat /etc/os-release should contain everything, but it varies across distributions)
  • The specific terminal application you're using (Konsole, Terminator, xfce4-terminal, etc)
  • The shell (bash, zsh, etc), and shell version - the output of $SHELL --version should be enough
  • Logs from the time when you kill the mongo shell and the buffered command is run

Thanks,
Nick

Generated at Thu Feb 08 04:35:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.