Skip to content

Commit

Permalink
don't replay broadcast writes SERVER-1350
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Jul 23, 2010
1 parent a23b97a commit 90f70ba
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
17 changes: 15 additions & 2 deletions s/d_logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,22 @@ namespace mongo {
|| op == dbGetMore // cursors are weird
)
return false;


const char *ns = m.singleData()->_data + 4;
DbMessage d(m);
if ( op == dbUpdate ){
if ( d.getInt(0) & UpdateOption_Broadcast ){
assert(0);
return false;
}
}
else if ( op == dbDelete ){
if ( d.getInt(0) & RemoveOption_Broadcast ){
assert(0);
return false;
}
}

const char *ns = d.getns();
string errmsg;
if ( shardVersionOk( ns , errmsg ) ){
return false;
Expand Down
5 changes: 5 additions & 0 deletions s/shard.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ namespace mongo {
}

static void sync();

void donotCheckVersion(){
_setVersion = false;
_finishedInit = true;
}

private:
void _init();
Expand Down
4 changes: 3 additions & 1 deletion s/strategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ namespace mongo {

// ----- Strategy ------

void Strategy::doWrite( int op , Request& r , const Shard& shard ){
void Strategy::doWrite( int op , Request& r , const Shard& shard , bool checkVersion ){
ShardConnection conn( shard , r.getns() );
if ( ! checkVersion )
conn.donotCheckVersion();
conn->say( r.m() );
conn.done();
}
Expand Down
2 changes: 1 addition & 1 deletion s/strategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace mongo {
virtual void writeOp( int op , Request& r ) = 0;

protected:
void doWrite( int op , Request& r , const Shard& shard );
void doWrite( int op , Request& r , const Shard& shard , bool checkVersion = true );
void doQuery( Request& r , const Shard& shard );

void insert( const Shard& shard , const char * ns , const BSONObj& obj );
Expand Down
8 changes: 6 additions & 2 deletions s/strategy_shard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,10 @@ namespace mongo {
if ( multi ){
set<Shard> shards;
manager->getShardsForQuery( shards , chunkFinder );
int * x = (int*)(r.d().afterNS());
x[0] |= UpdateOption_Broadcast;
for ( set<Shard>::iterator i=shards.begin(); i!=shards.end(); i++){
doWrite( dbUpdate , r , *i );
doWrite( dbUpdate , r , *i , false );
}
}
else {
Expand Down Expand Up @@ -251,7 +253,9 @@ namespace mongo {
throw UserException( 8015 , "can only delete with a non-shard key pattern if can delete as many as we find" );

for ( set<Shard>::iterator i=shards.begin(); i!=shards.end(); i++){
doWrite( dbDelete , r , *i );
int * x = (int*)(r.d().afterNS());
x[0] |= RemoveOption_Broadcast;
doWrite( dbDelete , r , *i , false );
}
}

Expand Down

0 comments on commit 90f70ba

Please sign in to comment.