[SERVER-2414] no clean shutdown under cygwin bash shell on ctrl-C Created: 27/Jan/11  Updated: 15/Aug/12  Resolved: 03/Jun/12

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 1.7.5
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Scott Hernandez (Inactive) Assignee: Tad Marshall
Resolution: Duplicate Votes: 1
Labels: Windows
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7; Cygwin bash shell


Issue Links:
Duplicate
duplicates SERVER-4423 Using MongoDB in the Cygwin shell Closed
Operating System: Windows
Participants:

 Description   

I was running with --dur and did a ctrl-c and it shutdown, but didn't cleanup the lock file.

When starting without --dur it complains about the lock, and when starting with --dur it started fine.

After removing the lock file it says it can't run without --dur because of the dur files.

win7x64



 Comments   
Comment by Tad Marshall [ 03/Jun/12 ]

Issue is being tracked in SERVER-4423.

Comment by Tad Marshall [ 03/Jun/12 ]

This is the same issue we see with some configurations of Cygwin, where ctrl-C isn't delivered correctly.

Comment by Tad Marshall [ 03/Dec/11 ]

I reopened this because of SERVER-4423 and some more testing with cygwin. This is just to make sure we deal with this bug properly.

Comment by Tad Marshall [ 28/Nov/11 ]

The problem is that our ctrl-C handler is written to run inside of a Windows console, and Cygwin doesn't provide one. We could write our own code to try to detect when we are running under Cygwin and allocate our own console, or we could write Cygwin-based code to accept Cygwin Unix-like signals, but none of this brings any actual benefit to users since they could just run us as a service and not rely on ctrl-C, or issue shutdownServer() from a client, or run us in a normal Windows command window. I'm calling it "Won't fix", it is not worth writing new code to deal with this.

Comment by Daniel Betz [ 25/Nov/11 ]

The same issue appears with MongoDB 2.0.1 under msys bash.

Comment by Scott Hernandez (Inactive) [ 27/Jan/11 ]

I did some more tests and there is indeed a difference in the behavior with 1.7.4/5. It is not some cygwin change...

//ctlr-c killed, and resulted in clean shutdown, but no shutdown output

$ ./mongod
C:\temp\mongodb-win32-x86_64-1.7.4\bin\mongod.exe --help for help and startup options
Thu Jan 27 10:29:02 MongoDB starting : pid=5044 port=27017 dbpath=/data/db/ 64-bit

    • NOTE: This is a development version (1.7.4) of MongoDB.
    • Not recommended for production.

Thu Jan 27 10:29:02 db version v1.7.4, pdfile version 4.5
Thu Jan 27 10:29:02 git version: fecf14def3bd51b91e0af55d61e9de2b9f918dcf
Thu Jan 27 10:29:02 sys info: windows (6, 1, 7600, 2, '') BOOST_LIB_VERSION=1_42
Thu Jan 27 10:29:02 [initandlisten] waiting for connections on port 27017
Thu Jan 27 10:29:02 [websvr] web admin interface listening on port 28017

//"shutdown" command issued from client

skot@tip ~/temp/mongodb-win32-x86_64-1.7.4/bin
$ ./mongod
C:\temp\mongodb-win32-x86_64-1.7.4\bin\mongod.exe --help for help and startup options
Thu Jan 27 10:29:23 MongoDB starting : pid=5520 port=27017 dbpath=/data/db/ 64-bit

    • NOTE: This is a development version (1.7.4) of MongoDB.
    • Not recommended for production.

Thu Jan 27 10:29:23 db version v1.7.4, pdfile version 4.5
Thu Jan 27 10:29:23 git version: fecf14def3bd51b91e0af55d61e9de2b9f918dcf
Thu Jan 27 10:29:23 sys info: windows (6, 1, 7600, 2, '') BOOST_LIB_VERSION=1_42
Thu Jan 27 10:29:23 [initandlisten] waiting for connections on port 27017
Thu Jan 27 10:29:23 [websvr] web admin interface listening on port 28017
Thu Jan 27 10:29:31 [initandlisten] connection accepted from 127.0.0.1:63845 #1
Thu Jan 27 10:29:51 [conn1] terminating, shutdown command received
Thu Jan 27 10:29:51 dbexit: shutdown called
Thu Jan 27 10:29:51 [conn1] shutdown: going to close listening sockets...
Thu Jan 27 10:29:51 [conn1] closing listening socket: 252
Thu Jan 27 10:29:51 [conn1] closing listening socket: 276
Thu Jan 27 10:29:51 [conn1] shutdown: going to flush oplog...
Thu Jan 27 10:29:51 [conn1] shutdown: going to close sockets...
Thu Jan 27 10:29:51 [conn1] shutdown: waiting for fs preallocator...
Thu Jan 27 10:29:51 [conn1] shutdown: closing all files...
Thu Jan 27 10:29:51 closeAllFiles() finished
Thu Jan 27 10:29:51 dbexit: really exiting now

//Now, with 1.7.5 things have changed (same order: ctrl-c, shutdown command):

skot@tip ~/temp/mongodb-win32-x86_64-1.7.5/bin
$ ./mongod
C:\temp\mongodb-win32-x86_64-1.7.5\bin\mongod.exe --help for help and startup options
Thu Jan 27 12:32:23 [initandlisten] MongoDB starting : pid=8544 port=27017 dbpath=/data/db/ 64-bit

    • NOTE: This is a development version (1.7.5) of MongoDB.
    • Not recommended for production.

Thu Jan 27 12:32:23 [initandlisten] db version v1.7.5, pdfile version 4.5
Thu Jan 27 12:32:23 [initandlisten] git version: 1978898d7a013657e5400133defdc996fb4c2c15
Thu Jan 27 12:32:23 [initandlisten] sys info: windows (6, 1, 7600, 2, '') BOOST_LIB_VERSION=1_42
Thu Jan 27 12:32:23 [initandlisten] waiting for connections on port 27017
Thu Jan 27 12:32:23 [websvr] web admin interface listening on port 28017

skot@tip ~/temp/mongodb-win32-x86_64-1.7.5/bin
$ ./mongod
C:\temp\mongodb-win32-x86_64-1.7.5\bin\mongod.exe --help for help and startup options
Thu Jan 27 12:32:28 [initandlisten] MongoDB starting : pid=7516 port=27017 dbpath=/data/db/ 64-bit

    • NOTE: This is a development version (1.7.5) of MongoDB.
    • Not recommended for production.

Thu Jan 27 12:32:28 [initandlisten] db version v1.7.5, pdfile version 4.5
Thu Jan 27 12:32:28 [initandlisten] git version: 1978898d7a013657e5400133defdc996fb4c2c15
Thu Jan 27 12:32:28 [initandlisten] sys info: windows (6, 1, 7600, 2, '') BOOST_LIB_VERSION=1_42
**************
old lock file: \data\db\mongod.lock. probably means unclean shutdown
recommend removing file and running --repair
see: http://dochub.mongodb.org/core/repair for more information
*************
Thu Jan 27 12:32:28 [initandlisten] exception in initAndListen std::exception: old lock file, terminating
Thu Jan 27 12:32:28 dbexit:
Thu Jan 27 12:32:28 [initandlisten] shutdown: going to close listening sockets...
Thu Jan 27 12:32:28 [initandlisten] shutdown: going to flush diaglog...
Thu Jan 27 12:32:28 [initandlisten] shutdown: going to close sockets...
Thu Jan 27 12:32:28 [initandlisten] shutdown: waiting for fs preallocator...
Thu Jan 27 12:32:28 [initandlisten] shutdown: closing all files...
Thu Jan 27 12:32:28 closeAllFiles() finished
Thu Jan 27 12:32:28 dbexit: really exiting now

skot@tip ~/temp/mongodb-win32-x86_64-1.7.5/bin
$ rm /cygdrive/c/data/db/mongod.lock

skot@tip ~/temp/mongodb-win32-x86_64-1.7.5/bin
$ ./mongod
C:\temp\mongodb-win32-x86_64-1.7.5\bin\mongod.exe --help for help and startup options
Thu Jan 27 12:33:00 [initandlisten] MongoDB starting : pid=5916 port=27017 dbpath=/data/db/ 64-bit

    • NOTE: This is a development version (1.7.5) of MongoDB.
    • Not recommended for production.

Thu Jan 27 12:33:00 [initandlisten] db version v1.7.5, pdfile version 4.5
Thu Jan 27 12:33:00 [initandlisten] git version: 1978898d7a013657e5400133defdc996fb4c2c15
Thu Jan 27 12:33:00 [initandlisten] sys info: windows (6, 1, 7600, 2, '') BOOST_LIB_VERSION=1_42
Thu Jan 27 12:33:00 [initandlisten] waiting for connections on port 27017
Thu Jan 27 12:33:00 [websvr] web admin interface listening on port 28017
Thu Jan 27 12:33:05 [initandlisten] connection accepted from 127.0.0.1:64206 #1
Thu Jan 27 12:33:05 [conn1] terminating, shutdown command received
Thu Jan 27 12:33:05 dbexit: shutdown called
Thu Jan 27 12:33:05 [conn1] shutdown: going to close listening sockets...
Thu Jan 27 12:33:05 [conn1] closing listening socket: 260
Thu Jan 27 12:33:05 [conn1] closing listening socket: 276
Thu Jan 27 12:33:05 [conn1] shutdown: going to flush diaglog...
Thu Jan 27 12:33:05 [conn1] shutdown: going to close sockets...
Thu Jan 27 12:33:05 [conn1] shutdown: waiting for fs preallocator...
Thu Jan 27 12:33:05 [conn1] shutdown: closing all files...
Thu Jan 27 12:33:05 closeAllFiles() finished
Thu Jan 27 12:33:05 [conn1] shutdown: removing fs lock...
Thu Jan 27 12:33:05 dbexit: really exiting now

Comment by Scott Hernandez (Inactive) [ 27/Jan/11 ]

This seems to be a problem with my current (or maybe new, in that it changed) cygwin env. It is not working for 1.7.4 anymore either. I don't think this is a new issue with 1.7.5, but I will continue to debug on my end.

Comment by Scott Hernandez (Inactive) [ 27/Jan/11 ]

Only happens when started in bash/cygwin.

Under cygwin:

Wed Jan 26 16:59:27 [conn445] dropDatabase morphia_test
Wed Jan 26 16:59:28 [conn445] building new index on

{ _id: 1 }

for morphia_test.E
Wed Jan 26 16:59:28 [conn445] done for 0 records 0.002secs
Wed Jan 26 16:59:28 [conn445] end connection 127.0.0.1:58449

skot@tip ~/temp/mongodb-win32-x86_64-1.7.5/bin
$

here is output from cmd.exe console:
Wed Jan 26 17:53:40 [websvr] web admin interface listening on port 28017
Wed Jan 26 17:53:43 Ctrl-C signal
Wed Jan 26 17:53:43 got kill or ctrl-c signal, will terminate after current cmd ends
Wed Jan 26 17:53:43 [ctrlCTerminate] now exiting
Wed Jan 26 17:53:43 dbexit:
Wed Jan 26 17:53:43 [ctrlCTerminate] shutdown: going to close listening sockets...
Wed Jan 26 17:53:44 [ctrlCTerminate] closing listening socket: 176
Wed Jan 26 17:53:44 [ctrlCTerminate] closing listening socket: 192
Wed Jan 26 17:53:44 [ctrlCTerminate] shutdown: going to flush diaglog...
Wed Jan 26 17:53:44 [ctrlCTerminate] shutdown: going to close sockets...
Wed Jan 26 17:53:44 [ctrlCTerminate] shutdown: waiting for fs preallocator...
Wed Jan 26 17:53:44 [ctrlCTerminate] shutdown: closing all files...
Wed Jan 26 17:53:44 closeAllFiles() finished
Wed Jan 26 17:53:44 [ctrlCTerminate] shutdown: removing fs lock...
Wed Jan 26 17:53:44 dbexit: really exiting now

C:\temp\mongodb-win32-x86_64-1.7.5\bin>

Comment by Eliot Horowitz (Inactive) [ 27/Jan/11 ]

Can you send the console output?
I can't reproduce.

Comment by Scott Hernandez (Inactive) [ 27/Jan/11 ]

Upon further investigation this seems to be an unclean shutdown. ctrl-c no longer seems to work; It worked on 1.7.4

Comment by Scott Hernandez (Inactive) [ 27/Jan/11 ]

This seems to be unrelated to --dur. ctrl-c seems to leave the lock file no matter what.

Generated at Thu Feb 08 02:59:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.