on exit, wait for replication to finish up
This commit is contained in:
@@ -66,7 +66,7 @@ namespace mongo {
|
||||
void closeAllSockets();
|
||||
void flushOpLog( stringstream &ss ) {
|
||||
if( _oplog.f && _oplog.f->is_open() ) {
|
||||
ss << "flushing op log and files";
|
||||
ss << "flushing op log and files\n";
|
||||
_oplog.flush();
|
||||
}
|
||||
}
|
||||
@@ -594,11 +594,12 @@ namespace mongo {
|
||||
DBDirectClient::AlwaysAuthorized DBDirectClient::Authorizer::always;
|
||||
|
||||
void recCacheCloseAll();
|
||||
|
||||
|
||||
boost::mutex &exitMutex( *( new boost::mutex ) );
|
||||
bool firstExit = true;
|
||||
|
||||
extern const char *replAllDead;
|
||||
extern int syncing;
|
||||
|
||||
/* not using log() herein in case we are already locked */
|
||||
void dbexit(int rc, const char *why) {
|
||||
{
|
||||
@@ -612,17 +613,34 @@ namespace mongo {
|
||||
firstExit = false;
|
||||
}
|
||||
|
||||
replAllDead = "server exiting"; // tell replication to stop
|
||||
|
||||
stringstream ss;
|
||||
ss << "dbexit: " << why << endl;
|
||||
rawOut( ss.str() );
|
||||
|
||||
stringstream ss2;
|
||||
flushOpLog( ss2 );
|
||||
ss2 << "\n";
|
||||
rawOut( ss2.str() );
|
||||
|
||||
/* wait for replication to finish */
|
||||
if( syncing == 1 ) {
|
||||
rawOut("waiting for replication to finish");
|
||||
int n = 60 * 4;
|
||||
while( 1 ) {
|
||||
sleepmillis(250);
|
||||
if( syncing != 1 )
|
||||
break;
|
||||
if( --n <= 0 ) {
|
||||
rawOut("timeout waiting for replication to finish -- attempting to exit anyway");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* must do this before unmapping mem or you may get a seg fault */
|
||||
closeAllSockets();
|
||||
|
||||
stringstream ss3;
|
||||
MemoryMappedFile::closeAllFiles( ss3 );
|
||||
rawOut( ss3.str() );
|
||||
|
||||
Reference in New Issue
Block a user