Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

SERVER-3555 prevent some implicit yielding in MultiCursor usage

  • Loading branch information...
commit acebc5e05e97b6a6d3d0c2d217f63058b1987b13 1 parent 18fa82a
@astaple astaple authored
Showing with 35 additions and 13 deletions.
  1. +21 −7 db/ops/delete.cpp
  2. +14 −2 db/ops/update.cpp
  3. +0 −4 jstests/orm.js
View
28 db/ops/delete.cpp
@@ -26,16 +26,20 @@ namespace mongo {
// Just try to identify best plan.
class DeleteOp : public MultiCursor::CursorOp {
public:
- DeleteOp( bool justOne, int& bestCount ) :
+ DeleteOp( bool justOne, int& bestCount, int orClauseIndex = -1 ) :
justOne_( justOne ),
count_(),
bestCount_( bestCount ),
- _nscanned() {
+ _nscanned(),
+ _orClauseIndex( orClauseIndex ) {
}
virtual void _init() {
c_ = qp().newCursor();
}
virtual bool prepareToYield() {
+ if ( _orClauseIndex > 0 ) {
+ return false;
+ }
if ( ! _cc ) {
_cc.reset( new ClientCursor( QueryOption_NoCursorTimeout , c_ , qp().ns() ) );
}
@@ -66,6 +70,12 @@ namespace mongo {
c_->advance();
_nscanned = c_->nscanned();
+
+ if ( _orClauseIndex > 0 && _nscanned >= 100 ) {
+ setComplete();
+ return;
+ }
+
if ( count_ > bestCount_ )
bestCount_ = count_;
@@ -79,7 +89,7 @@ namespace mongo {
virtual bool mayRecordPlan() const { return !justOne_; }
virtual QueryOp *_createChild() const {
bestCount_ = 0; // should be safe to reset this in contexts where createChild() is called
- return new DeleteOp( justOne_, bestCount_ );
+ return new DeleteOp( justOne_, bestCount_, _orClauseIndex + 1 );
}
virtual shared_ptr<Cursor> newCursor() const { return qp().newCursor(); }
private:
@@ -90,6 +100,8 @@ namespace mongo {
shared_ptr<Cursor> c_;
ClientCursor::CleanupPointer _cc;
ClientCursor::YieldData _yieldData;
+ // Avoid yielding in the MultiPlanScanner when not the first $or clause - just a temporary implementaiton for now.
+ int _orClauseIndex;
};
/* ns: namespace, e.g. <database>.<collection>
@@ -112,10 +124,12 @@ namespace mongo {
}
}
- NamespaceDetails *d = nsdetails( ns );
- if ( ! d )
- return 0;
- uassert( 10101 , "can't remove from a capped collection" , ! d->capped );
+ {
+ NamespaceDetails *d = nsdetails( ns );
+ if ( ! d )
+ return 0;
+ uassert( 10101 , "can't remove from a capped collection" , ! d->capped );
+ }
long long nDeleted = 0;
View
16 db/ops/update.cpp
@@ -901,7 +901,10 @@ namespace mongo {
class UpdateOp : public MultiCursor::CursorOp {
public:
- UpdateOp( bool hasPositionalField ) : _nscanned(), _hasPositionalField( hasPositionalField ) {}
+ UpdateOp( bool hasPositionalField, int orClauseIndex = -1 ) :
+ _nscanned(),
+ _hasPositionalField( hasPositionalField ),
+ _orClauseIndex( orClauseIndex ) {}
virtual void _init() {
_c = qp().newCursor();
if ( ! _c->ok() ) {
@@ -909,6 +912,9 @@ namespace mongo {
}
}
virtual bool prepareToYield() {
+ if ( _orClauseIndex > 0 ) {
+ return false;
+ }
if ( ! _cc ) {
_cc.reset( new ClientCursor( QueryOption_NoCursorTimeout , _c , qp().ns() ) );
}
@@ -930,6 +936,10 @@ namespace mongo {
return;
}
_nscanned = _c->nscanned();
+ if ( _orClauseIndex > 0 && _nscanned >= 100 ) {
+ setComplete();
+ return;
+ }
if ( matcher( _c )->matchesCurrent(_c.get(), &_details ) ) {
setComplete();
return;
@@ -939,7 +949,7 @@ namespace mongo {
virtual bool mayRecordPlan() const { return false; }
virtual QueryOp *_createChild() const {
- return new UpdateOp( _hasPositionalField );
+ return new UpdateOp( _hasPositionalField, _orClauseIndex + 1 );
}
// already scanned to the first match, so return _c
virtual shared_ptr< Cursor > newCursor() const { return _c; }
@@ -951,6 +961,8 @@ namespace mongo {
MatchDetails _details;
ClientCursor::CleanupPointer _cc;
ClientCursor::YieldData _yieldData;
+ // Avoid yielding in the MultiPlanScanner when not the first $or clause - just a temporary implementaiton for now.
+ int _orClauseIndex;
};
static void checkTooLarge(const BSONObj& newObj) {
View
4 jstests/orm.js
@@ -1,7 +1,5 @@
// Test dropping during a $or yield SERVER-3555
-if ( 0 ) { // SERVER-3555
-
t = db.jstests_orm;
t.drop();
@@ -29,5 +27,3 @@ for( j = 0; j < 5; ++j ) {
db.getLastError();
}
p();
-
-}
Please sign in to comment.
Something went wrong with that request. Please try again.