Skip to content

Commit

Permalink
SERVER-1453 yield during geo query
Browse files Browse the repository at this point in the history
  • Loading branch information
astaple committed Aug 2, 2010
1 parent 45f9479 commit e6ad6ec
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 19 deletions.
5 changes: 3 additions & 2 deletions db/clientcursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ namespace mongo {
}
}

void ClientCursor::prepareToYield( YieldData &data ) {
bool ClientCursor::prepareToYield( YieldData &data ) {
if ( ! c->supportYields() )
return;
return false;
// need to store in case 'this' gets deleted
data._id = cursorid;

Expand Down Expand Up @@ -268,6 +268,7 @@ namespace mongo {
}
}
}
return true;
}

bool ClientCursor::recoverFromYield( const YieldData &data ) {
Expand Down
2 changes: 1 addition & 1 deletion db/clientcursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ namespace mongo {
static void staticYield( int micros );

struct YieldData { CursorId _id; bool _doingDeletes; };
void prepareToYield( YieldData &data );
bool prepareToYield( YieldData &data );
static bool recoverFromYield( const YieldData &data );

struct YieldLock : boost::noncopyable {
Expand Down
5 changes: 3 additions & 2 deletions db/oplog.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ namespace mongo {
}
}
}
void prepareToYield() {
bool prepareToYield() {
if ( _findingStartCursor ) {
_findingStartCursor->prepareToYield( _yieldData );
return _findingStartCursor->prepareToYield( _yieldData );
}
return true;
}
void recoverFromYield() {
if ( _findingStartCursor ) {
Expand Down
14 changes: 7 additions & 7 deletions db/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ namespace mongo {
virtual void _init() {
c_ = qp().newCursor();
}
virtual void prepareToYield() {
virtual bool prepareToYield() {
if ( ! _cc ) {
_cc.reset( new ClientCursor( QueryOption_NoCursorTimeout , c_ , qp().ns() ) );
}
_cc->prepareToYield( _yieldData );
return _cc->prepareToYield( _yieldData );
}
virtual void recoverFromYield() {
if ( !ClientCursor::recoverFromYield( _yieldData ) ) {
Expand Down Expand Up @@ -406,11 +406,11 @@ namespace mongo {
}
}

virtual void prepareToYield() {
virtual bool prepareToYield() {
if ( ! _cc ) {
_cc.reset( new ClientCursor( QueryOption_NoCursorTimeout , c_ , _ns.c_str() ) );
}
_cc->prepareToYield( _yieldData );
return _cc->prepareToYield( _yieldData );
}

virtual void recoverFromYield() {
Expand Down Expand Up @@ -630,14 +630,14 @@ namespace mongo {
}
}

virtual void prepareToYield() {
virtual bool prepareToYield() {
if ( _findingStartCursor.get() ) {
_findingStartCursor->prepareToYield();
return _findingStartCursor->prepareToYield();
} else {
if ( ! _cc ) {
_cc.reset( new ClientCursor( QueryOption_NoCursorTimeout , _c , _pq.ns() ) );
}
_cc->prepareToYield( _yieldData );
return _cc->prepareToYield( _yieldData );
}
}

Expand Down
8 changes: 5 additions & 3 deletions db/queryoptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,9 @@ namespace mongo {
int micros = ClientCursor::yieldSuggest();
if ( micros > 0 ) {
for( vector< shared_ptr< QueryOp > >::const_iterator i = ops.begin(); i != ops.end(); ++i ) {
prepareToYield( **i );
if ( !prepareToYield( **i ) ) {
return;
}
}
ClientCursor::staticYield( micros );
for( vector< shared_ptr< QueryOp > >::const_iterator i = ops.begin(); i != ops.end(); ++i ) {
Expand Down Expand Up @@ -615,8 +617,8 @@ namespace mongo {
GUARD_OP_EXCEPTION( op, if ( !op.error() ) { op.next(); } );
}

void QueryPlanSet::Runner::prepareToYield( QueryOp &op ) {
GUARD_OP_EXCEPTION( op, if ( !op.error() ) { op.prepareToYield(); } );
bool QueryPlanSet::Runner::prepareToYield( QueryOp &op ) {
GUARD_OP_EXCEPTION( op, if ( !op.error() ) { return op.prepareToYield(); } );
}

void QueryPlanSet::Runner::recoverFromYield( QueryOp &op ) {
Expand Down
4 changes: 2 additions & 2 deletions db/queryoptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ namespace mongo {

virtual bool mayRecordPlan() const = 0;

virtual void prepareToYield() { massert( 13335, "yield not supported", false ); }
virtual bool prepareToYield() { massert( 13335, "yield not supported", false ); return false; }
virtual void recoverFromYield() { massert( 13336, "yield not supported", false ); }

/** @return a copy of the inheriting class, which will be run with its own
Expand Down Expand Up @@ -211,7 +211,7 @@ namespace mongo {
QueryPlanSet &plans_;
static void initOp( QueryOp &op );
static void nextOp( QueryOp &op );
static void prepareToYield( QueryOp &op );
static bool prepareToYield( QueryOp &op );
static void recoverFromYield( QueryOp &op );
};
const char *ns;
Expand Down
4 changes: 2 additions & 2 deletions db/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,11 +735,11 @@ namespace mongo {
setComplete();
}
}
virtual void prepareToYield() {
virtual bool prepareToYield() {
if ( ! _cc ) {
_cc.reset( new ClientCursor( QueryOption_NoCursorTimeout , _c , qp().ns() ) );
}
_cc->prepareToYield( _yieldData );
return _cc->prepareToYield( _yieldData );
}
virtual void recoverFromYield() {
if ( !ClientCursor::recoverFromYield( _yieldData ) ) {
Expand Down

0 comments on commit e6ad6ec

Please sign in to comment.