summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2013-12-02 16:00:51 -0500
committerEliot Horowitz <eliot@10gen.com>2013-12-03 21:24:55 -0500
commitf2b96d98f8c5be601832d984fe089940a4012624 (patch)
treed3e6f463520e6a2955b168063c30c0b19d1ecdcd /src/mongo/db
parent1766b460efaaee908ebe664cb6e5b28c702ab12d (diff)
downloadmongo-f2b96d98f8c5be601832d984fe089940a4012624.tar.gz
SERVER-11665: add timing in writeConcern result for sync time
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/write_concern.cpp12
-rw-r--r--src/mongo/db/write_concern.h2
2 files changed, 13 insertions, 1 deletions
diff --git a/src/mongo/db/write_concern.cpp b/src/mongo/db/write_concern.cpp
index 56b646a70aa..e6605c1d92c 100644
--- a/src/mongo/db/write_concern.cpp
+++ b/src/mongo/db/write_concern.cpp
@@ -83,6 +83,9 @@ namespace mongo {
}
void WriteConcernResult::appendTo( BSONObjBuilder* result ) const {
+ if ( syncMillis >= 0 )
+ result->appendNumber( "syncMillis", syncMillis );
+
if ( fsyncFiles >= 0 )
result->appendNumber( "fsyncFiles", fsyncFiles );
@@ -112,6 +115,7 @@ namespace mongo {
WriteConcernResult* result ) {
// first handle blocking on disk
+ Timer syncTimer;
switch( writeConcern.syncMode ) {
case WriteConcernOptions::NONE:
break;
@@ -126,6 +130,7 @@ namespace mongo {
result->fsyncFiles = MemoryMappedFile::flushAll( true );
break;
}
+ result->syncMillis = syncTimer.millis();
// now wait for replication
@@ -181,7 +186,12 @@ namespace mongo {
}
if ( !writeConcern.wMode.empty() && !theReplSet ) {
- return Status( ErrorCodes::BadValue, "asked for a w mode with master/slave" );
+ // TODO: want to return the status, but is backwards breaking
+ // only for master/slave, which is deprecated
+ //return Status( ErrorCodes::BadValue,
+ //str::stream() << "asked for a w mode with master/slave ["
+ //<< writeConcern.wMode << "]" );
+ return Status::OK();
}
// now that we've done the prep, now we actually wait
diff --git a/src/mongo/db/write_concern.h b/src/mongo/db/write_concern.h
index e5cb4138d87..865507acd91 100644
--- a/src/mongo/db/write_concern.h
+++ b/src/mongo/db/write_concern.h
@@ -58,6 +58,7 @@ namespace mongo {
}
void reset() {
+ syncMillis = -1;
fsyncFiles = -1;
wTimedOut = false;
wTime = -1;
@@ -66,6 +67,7 @@ namespace mongo {
void appendTo( BSONObjBuilder* result ) const;
+ int syncMillis;
int fsyncFiles;
bool wTimedOut;