Skip to content

Commit 86c72c0

Browse files
committed
SERVER-1551 check cursor ok after yield
1 parent 5a52bca commit 86c72c0

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

db/query.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ namespace mongo {
164164
// TODO should we assert or something?
165165
break;
166166
}
167+
if ( !cc->c->ok() ) {
168+
break; // if we yielded, could have hit the end
169+
}
167170

168171
// this way we can avoid calling updateLocation() every time (expensive)
169172
// as well as some other nuances handled

db/update.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,9 @@ namespace mongo {
931931
// TODO should we assert or something?
932932
break;
933933
}
934+
if ( !c->ok() ) {
935+
break;
936+
}
934937
}
935938
continue;
936939
}
@@ -1056,6 +1059,9 @@ namespace mongo {
10561059
cc.release();
10571060
break;
10581061
}
1062+
if ( !c->ok() ) {
1063+
break;
1064+
}
10591065
}
10601066

10611067
continue;

jstests/slowNightly/remove9.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
t = db.jstests_remove9;
2+
t.drop();
3+
4+
js = "while( 1 ) { for( i = 0; i < 10000; ++i ) { db.jstests_remove9.save( {i:i} ); } db.jstests_remove9.remove( {i: {$gte:0} } ); }";
5+
pid = startMongoProgramNoConnect( "mongo" , "--eval" , js , db ? db.getMongo().host : null );
6+
7+
for( var i = 0; i < 10000; ++i ) {
8+
t.remove( {i:Random.randInt( 10000 )} );
9+
assert.automsg( "!db.getLastError()" );
10+
}
11+
12+
stopMongoProgramByPid( pid );

mongo.xcodeproj/project.pbxproj

+2
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@
588588
93E8A4D01174EEAF0025F7F8 /* or2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = or2.js; sourceTree = "<group>"; };
589589
93E8A53411752FCE0025F7F8 /* or3.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = or3.js; sourceTree = "<group>"; };
590590
93EC34601207628300A95C8A /* capped7.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = capped7.js; sourceTree = "<group>"; };
591+
93EC350F1207AEB000A95C8A /* remove9.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = remove9.js; sourceTree = "<group>"; };
591592
93F0957010E165E50053380C /* basic.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = basic.js; sourceTree = "<group>"; };
592593
93F095CC10E16FF70053380C /* shellfork.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = shellfork.js; sourceTree = "<group>"; };
593594
C6859E8B029090EE04C91782 /* mongo.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = mongo.1; sourceTree = "<group>"; };
@@ -832,6 +833,7 @@
832833
934BEB9A10DFFA9600178102 /* jstests */ = {
833834
isa = PBXGroup;
834835
children = (
836+
93EC350F1207AEB000A95C8A /* remove9.js */,
835837
93EC34601207628300A95C8A /* capped7.js */,
836838
93E6E10A11FE2BBC00EDA451 /* capped6.js */,
837839
93C5BC9E11E5B7FE00F9671C /* group6.js */,

0 commit comments

Comments
 (0)