0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 17:10:48 +01:00

SERVER-40110 don't call OpContext::checkForInterrupt() off-thread

This commit is contained in:
Ian Boros 2019-07-02 14:29:56 -04:00 committed by Ian Boros
parent eaa3578e9f
commit 7a4fce6cfd
4 changed files with 81 additions and 2 deletions

View File

@ -123,6 +123,7 @@ selector:
- jstests/concurrency/fsm_workloads/reindex_background.js
- jstests/concurrency/fsm_workloads/remove_multiple_documents.js
- jstests/concurrency/fsm_workloads/remove_where.js
- jstests/concurrency/fsm_workloads/server_status_with_time_out_cursors.js
- jstests/concurrency/fsm_workloads/touch_base.js
- jstests/concurrency/fsm_workloads/touch_data.js
- jstests/concurrency/fsm_workloads/touch_index.js

View File

@ -125,6 +125,7 @@ selector:
- jstests/concurrency/fsm_workloads/reindex.js
- jstests/concurrency/fsm_workloads/reindex_background.js
- jstests/concurrency/fsm_workloads/remove_multiple_documents.js
- jstests/concurrency/fsm_workloads/server_status_with_time_out_cursors.js
- jstests/concurrency/fsm_workloads/touch_base.js
- jstests/concurrency/fsm_workloads/touch_data.js
- jstests/concurrency/fsm_workloads/touch_index.js

View File

@ -0,0 +1,72 @@
'use strict';
/**
* Run serverStatus() while running a large number of queries which are expected to reach maxTimeMS
* and time out.
*/
load('jstests/concurrency/fsm_workload_helpers/server_types.js'); // for isMongos
var $config = (function() {
const states = {
/**
* This is a no-op, used only as a transition state.
*/
init: function init(db, collName) {},
/**
* Runs a query on the collection with a small enough batchSize to leave the cursor open.
* If the command was successful, stores the resulting cursor in 'this.cursor'.
*/
query: function query(db, collName) {
try {
// Set a low maxTimeMs and small batch size so that it's likely the cursor will
// time out over its lifetime.
let curs = db[collName]
.find({
$where: function() {
sleep(1);
return true;
}
})
.batchSize(2)
.maxTimeMS(10);
const c = curs.itcount();
} catch (e) {
assert.commandFailedWithCode(e, [
ErrorCodes.MaxTimeMSExpired,
]);
}
},
serverStatus: function serverStatus(db, collName) {
assert.commandWorked(db.adminCommand({serverStatus: 1}));
}
};
const transitions = {
init: {
query: 0.8,
serverStatus: 0.2,
},
query: {query: 0.8, serverStatus: 0.2},
serverStatus: {query: 0.5, serverStatus: 0.5},
};
function setup(db, collName, cluster) {
// Write some data.
assertWhenOwnColl.commandWorked(
db[collName].insert(Array.from({length: 100}, _ => ({a: 1}))));
}
return {
threadCount: 10,
iterations: 100,
states: states,
startState: 'init',
transitions: transitions,
setup: setup,
};
})();

View File

@ -586,8 +586,13 @@ private:
bool isKillPending() const {
// A cursor is kill pending if it's checked out by an OperationContext that was
// interrupted.
return _operationUsingCursor &&
!_operationUsingCursor->checkForInterruptNoAssert().isOK();
if (!_operationUsingCursor) {
return false;
}
// Must hold the Client lock when calling isKillPending().
stdx::unique_lock<Client> lk(*_operationUsingCursor->getClient());
return _operationUsingCursor->isKillPending();
}
CursorType getCursorType() const {