[SERVER-27576] MongoDB 3.4 'mongo' shell quit() not working Created: 04/Jan/17  Updated: 08/Jan/24  Resolved: 12/Jan/17

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 3.4.0, 3.4.1
Fix Version/s: 3.4.2, 3.5.2

Type: Bug Priority: Major - P3
Reporter: Tim Vaillancourt Assignee: Jonathan Reams
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
related to SERVER-19641 quit() in the shell quickExits from d... Closed
related to SERVER-24818 Shell should use on-thread JS engine Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.4
Steps To Reproduce:
  1. Download MongoDB 3.4.0 or 3.4.1.
  2. Connect to a MongoDB server using 3.4 'mongo' shell.
  3. Run "quit()" function.
  4. Notice the shell does not exit.
Sprint: Platforms 2017-01-23
Participants:

 Description   

Hey guys,

Hopefully this isn't a duplicate. On MongoDB 3.4.0 and 3.4.1 I am noticing the 'quit()' shell function no longer works. The function still exists in the shell but does nothing.

I have confirmed this does not occur when using the 3.2.11 'mongo' shell.

I have reproduced this with several server versions and the problem seems to be unrelated to the server version.

Issue repro using 3.4.1 'mongo' shell (had to CTRL+C to quit the shell):

$ ./mongodb3.4/mongodb-linux-x86_64-3.4.1/bin/mongo; echo $?
MongoDB shell version v3.4.1
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.1
Server has startup warnings: 
2017-01-04T14:52:34.465+0100 I CONTROL  [initandlisten] 
2017-01-04T14:52:34.465+0100 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-01-04T14:52:34.465+0100 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-01-04T14:52:34.465+0100 I CONTROL  [initandlisten] 
> 
> quit()
> quit()
> quit()
> quit
function quit() {
    [native code]
}
> ^C
bye
0
$ ./mongodb3.4/mongodb-linux-x86_64-3.4.1/bin/mongo --version
MongoDB shell version v3.4.1
git version: 5e103c4f5583e2566a45d740225dc250baacfbd7
allocator: tcmalloc
modules: none
build environment:
    distarch: x86_64
    target_arch: x86_64

To compare, 3.2.11 is working as expected:

$ ./mongodb3.2/mongodb-linux-x86_64-3.2.11/bin/mongo; echo $?
MongoDB shell version: 3.2.11
connecting to: test
Server has startup warnings: 
2017-01-04T14:52:34.465+0100 I CONTROL  [initandlisten] 
2017-01-04T14:52:34.465+0100 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-01-04T14:52:34.465+0100 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-01-04T14:52:34.465+0100 I CONTROL  [initandlisten] 
> quit()
0
$ ./mongodb3.2/mongodb-linux-x86_64-3.2.11/bin/mongo --version
MongoDB shell version: 3.2.11

And 3.0 is working too:

$ /opt/mongodb3.0/bin/mongo
MongoDB shell version: 3.0.12-15-gc0066f6
connecting to: test
Server has startup warnings: 
2017-01-04T14:52:34.465+0100 I CONTROL  [initandlisten] 
2017-01-04T14:52:34.465+0100 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-01-04T14:52:34.465+0100 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-01-04T14:52:34.465+0100 I CONTROL  [initandlisten] 
> quit()



 Comments   
Comment by Githook User [ 18/Jan/17 ]

Author:

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

Message: SERVER-27576 Fix quit() in shell and all the tests that depend on it

(cherry picked from commit f3d5da919580d6ab7a332fab604b056451994af3)
Branch: v3.4
https://github.com/mongodb/mongo/commit/4e62cebd32bfc6b5f3283b111a9a79b25ca3d791

Comment by Githook User [ 12/Jan/17 ]

Author:

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

Message: SERVER-27576 Fix quit() in shell and all the tests that depend on it
Branch: master
https://github.com/mongodb/mongo/commit/f3d5da919580d6ab7a332fab604b056451994af3

Comment by Jonathan Reams [ 09/Jan/17 ]

I talked to mira.carey@mongodb.com about this, and we were checking the quickExit flag in the proxyscope because we need to be able to free the implscope before calling quickExit to satisfy the ASAN.

Comment by Jonathan Reams [ 06/Jan/17 ]

I dug into this a bit, and it seems that the reason is that we depend on the ProxyScope to actually check whether a quit has been requested and then call quickExit, and in 3.4 we stopped using a ProxyScope for the shell's main javascript scope. I'm not sure why we don't just quick exit from within the quit() function and do this dance of setting flags and checking them later.

Comment by Eric Milkie [ 04/Jan/17 ]

Thanks for reporting this – the quit command is indeed broken! For a workaround (other than using an older shell version), you can use CTRL-C, CTRL-D, or the "exit" command.

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