Skip to content

Commit 6362013

Browse files
committed
Queries for rollback objects need SlaveOk bit SERVER-3650
1 parent 41f0781 commit 6362013

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

db/repl/rs_rollback.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ namespace mongo {
341341
{
342342
/* TODO : slow. lots of round trips. */
343343
n++;
344-
bo good= them->findOne(d.ns, d._id.wrap()).getOwned();
344+
bo good= them->findOne(d.ns, d._id.wrap(), NULL, QueryOption_SlaveOk).getOwned();
345345
totSize += good.objsize();
346346
uassert( 13410, "replSet too much data to roll back", totSize < 300 * 1024 * 1024 );
347347

jstests/replsets/rollback4.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if (0) { // disabled due to SERVER-3650
1+
if (1) { // SERVER-3650
22

33
var num = 7;
44
var host = getHostName();
@@ -45,25 +45,26 @@ replTest.partition(2,5)
4545
replTest.partition(2,6)
4646
printjson({endPartition: new Date()});
4747

48-
var gotOneThrough = false
48+
var gotThrough = 0
4949
try {
5050
while (true){
5151
mColl.insert({})
52-
out = master.adminCommand({getLastError:1});
52+
out = master.adminCommand({getLastError:1, w:3});
5353
if (out.err)
5454
break;
5555

56-
gotOneThrough = true;
56+
gotThrough++;
5757
}
5858
}
5959
catch (e) {
6060
print("caught exception");
6161
}
6262

63+
printjson({gotThrough: gotThrough});
6364
printjson({cantWriteOldPrimary: new Date()});
6465
printjson(master.adminCommand("replSetGetStatus"));
6566

66-
assert(gotOneThrough, "gotOneThrough");
67+
assert(gotThrough > 0, "gotOneThrough");
6768

6869
sleep(5*1000); // make sure new seconds field in opTime
6970

@@ -78,6 +79,8 @@ m2Coll.insert(sentinel);
7879
printjson(master2.adminCommand({getLastError:1, w:4, wtimeout:30*1000}));
7980
printjson(master2.adminCommand("replSetGetStatus"));
8081

82+
m2Coll.insert({}); // this shouldn't be necessary but the next GLE doesn't work without it
83+
8184
printjson({startUnPartition: new Date()});
8285
replTest.unPartition(0,3)
8386
replTest.unPartition(0,4)
@@ -93,10 +96,14 @@ replTest.unPartition(2,5)
9396
replTest.unPartition(2,6)
9497
printjson({endUnPartition: new Date()});
9598

96-
m2Coll.insert({}); // this shouldn't be necessary but the next line doesn't work without it
9799
printjson(master2.adminCommand({getLastError:1, w:7, wtimeout:30*1000}));
98100
printjson(master2.adminCommand("replSetGetStatus"));
99101

102+
assert.soon(function() {return master.adminCommand('isMaster').ismaster},
103+
"Node 0 back to primary",
104+
60*1000/*needs to be longer than LeaseTime*/);
105+
printjson(master.adminCommand("replSetGetStatus"));
106+
100107
// make sure old master rolled back to new master
101108
assert.eq(m2Coll.count(sentinel), 1, "check sentinal on node 6");
102109
assert.eq(mColl.count(sentinel), 1, "check sentinal on node 0");

0 commit comments

Comments
 (0)