diff options
author | Spencer T Brody <spencer@mongodb.com> | 2014-03-10 14:53:21 -0400 |
---|---|---|
committer | Spencer T Brody <spencer@mongodb.com> | 2014-03-13 11:32:24 -0400 |
commit | 169da10f6c36eeed1655c897612f1ace16114257 (patch) | |
tree | e28f68c4f364577b37f83fd7d9b59cb8900477b8 /src/mongo/s/cluster_write.cpp | |
parent | a21a6a47fab341155a08bf0505c86f5ac520379b (diff) | |
download | mongo-169da10f6c36eeed1655c897612f1ace16114257.tar.gz |
SERVER-13087 Better error messages for invalid config server writes
Diffstat (limited to 'src/mongo/s/cluster_write.cpp')
-rw-r--r-- | src/mongo/s/cluster_write.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/mongo/s/cluster_write.cpp b/src/mongo/s/cluster_write.cpp index a680849408f..5a8e690d61e 100644 --- a/src/mongo/s/cluster_write.cpp +++ b/src/mongo/s/cluster_write.cpp @@ -42,6 +42,7 @@ #include "mongo/s/grid.h" #include "mongo/s/write_ops/batch_write_exec.h" #include "mongo/s/write_ops/config_coordinator.h" +#include "mongo/util/mongoutils/str.h" #include "mongo/util/net/hostandport.h" namespace mongo { @@ -352,13 +353,21 @@ namespace mongo { bool verboseWC = request.isVerboseWC(); - // We only support batch sizes of one and {w:0} write concern for config writes - if ( request.sizeWriteOps() != 1 || - ( request.isWriteConcernSet() && - !validConfigWC( request.getWriteConcern() ))) { + // We only support batch sizes of one for config writes + if ( request.sizeWriteOps() != 1 ) { + toBatchError( Status( ErrorCodes::InvalidOptions, + mongoutils::str::stream() << "Writes to config servers must " + "have batch size of 1, found " + << request.sizeWriteOps() ), + response ); + return; + } + // We only support {w: 0}, {w: 1}, and {w: 'majority'} write concern for config writes + if ( request.isWriteConcernSet() && !validConfigWC( request.getWriteConcern() )) { toBatchError( Status( ErrorCodes::InvalidOptions, - "invalid batch request for config write" ), + mongoutils::str::stream() << "Invalid write concern for write" + " to config servers: " << request.getWriteConcern() ), response ); return; } |