Permalink
Browse files

SERVER-6305 command-line option to turn off auto-splitting on particu…

…lar mongoses
  • Loading branch information...
1 parent 2ff57e1 commit f198c21e4bd5dbbc9d989ff5ddf2bf05f72ff2a0 Greg Studer committed Jul 6, 2012
Showing with 54 additions and 1 deletion.
  1. +40 −0 jstests/sharding/disable_autosplit.js
  2. +2 −0 s/chunk.cpp
  3. +2 −0 s/chunk.h
  4. +2 −1 s/client.h
  5. +8 −0 s/server.cpp
@@ -0,0 +1,40 @@
+//
+// Tests disabling of autosplit from mongos
+//
+
+var chunkSize = 1 //MB
+
+var st = new ShardingTest({ shards : 1,
+ mongos : 1,
+ other : {
+
+ chunksize : chunkSize,
+ extraOptions : { noAutoSplit : "" }
+
+ } })
+
+var data = "x"
+while( data.length < chunkSize * 1024 * 1024 ){
+ data += data
+}
+
+var mongos = st.s0
+var admin = mongos.getDB( "admin" )
+var config = mongos.getDB( "config" )
+var coll = mongos.getCollection( "foo.bar" )
+
+printjson( admin.runCommand({ enableSharding : coll.getDB() + "" }) )
+printjson( admin.runCommand({ shardCollection : coll + "", key : { _id : 1 } }) )
+
+for( var i = 0; i < 20; i++ ){
+ coll.insert({ data : data })
+}
+
+// Make sure we haven't split
+assert.eq( 1, config.chunks.find({ ns : coll + "" }).count() )
+
+st.printShardingStatus()
+
+jsTestLog( "Done!" )
+
+st.stop()
View
@@ -49,6 +49,8 @@ namespace mongo {
int Chunk::MaxChunkSize = 1024 * 1024 * 64;
int Chunk::MaxObjectPerChunk = 250000;
+ // Can be overridden from command line
+ bool Chunk::ShouldAutoSplit = true;
Chunk::Chunk(const ChunkManager * manager, BSONObj from)
: _manager(manager), _lastmod(0), _dataWritten(mkDataWritten())
View
@@ -160,6 +160,8 @@ namespace mongo {
static string chunkMetadataNS;
static int MaxChunkSize;
static int MaxObjectPerChunk;
+ static bool ShouldAutoSplit;
+
//
// accessors and helpers
//
View
@@ -17,6 +17,7 @@
*/
#include "../pch.h"
+#include "chunk.h"
#include "writeback_listener.h"
#include "../db/security.h"
@@ -78,7 +79,7 @@ namespace mongo {
bool getLastError( const BSONObj& options , BSONObjBuilder& result , bool fromWriteBackListener = false );
/** @return if its ok to auto split from this client */
- bool autoSplitOk() const { return _autoSplitOk; }
+ bool autoSplitOk() const { return _autoSplitOk && Chunk::ShouldAutoSplit; }
void noAutoSplit() { _autoSplitOk = false; }
View
@@ -205,6 +205,9 @@ int _main(int argc, char* argv[]) {
("noscripting", "disable scripting engine")
;
+ hidden.add_options()
+ ( "noAutoSplit", "do not send split commands with writes" );
+
options.add(sharding_options);
// parse options
po::variables_map params;
@@ -248,6 +251,11 @@ int _main(int argc, char* argv[]) {
scriptingEnabled = false;
}
+ if (params.count("noAutoSplit")) {
+ warning() << "running with auto-splitting disabled" << endl;
+ Chunk::ShouldAutoSplit = false;
+ }
+
if ( ! params.count( "configdb" ) ) {
out() << "error: no args for --configdb" << endl;
return 4;

0 comments on commit f198c21

Please sign in to comment.