summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorKevin Pulo <kevin.pulo@mongodb.com>2020-01-14 07:12:23 +0000
committerevergreen <evergreen@mongodb.com>2020-01-14 07:12:23 +0000
commit348a2c6ae2d903fb49601846ba5cbcd9d1a65cbb (patch)
tree74af53b03437aaaacfd1f453bf0e873916a397d8 /jstests
parentffe43eabfb262487b1ccc0403138744e361d8c93 (diff)
downloadmongo-348a2c6ae2d903fb49601846ba5cbcd9d1a65cbb.tar.gz
SERVER-43246 Add a log line for when a cursor is reaped due to logical session cleanup
(cherry picked from commit 89c93866980e924c7ae91ca30b5bd3674727fe4f) SERVER-45277 Temporarily blacklist sharding/kill_sessions.js in multiversion (cherry picked from commit 532b4a761e27d3ffa3b852fd3e936190dd5d2461)
Diffstat (limited to 'jstests')
-rw-r--r--jstests/libs/kill_sessions.js34
-rw-r--r--jstests/sharding/kill_sessions.js8
2 files changed, 40 insertions, 2 deletions
diff --git a/jstests/libs/kill_sessions.js b/jstests/libs/kill_sessions.js
index 4941274c02d..8cf809740c6 100644
--- a/jstests/libs/kill_sessions.js
+++ b/jstests/libs/kill_sessions.js
@@ -1,4 +1,5 @@
load("jstests/libs/parallelTester.js");
+load("jstests/libs/check_log.js");
/**
* Implements a kill session test helper
@@ -223,8 +224,14 @@ var _kill_sessions_api_module = (function() {
});
};
- function CursorHandle(session) {
+ Fixture.prototype.assertCursorKillLogMessages = function(cursorHandles) {
+ cursorHandles.forEach(
+ cursorHandle => cursorHandle.assertCursorKillLogMessages(this._clientsToVerifyVia));
+ };
+
+ function CursorHandle(session, cursors) {
this._session = session;
+ this._cursors = cursors;
}
CursorHandle.prototype.getLsid = function() {
@@ -235,6 +242,18 @@ var _kill_sessions_api_module = (function() {
this._session.endSession();
};
+ CursorHandle.prototype.assertCursorKillLogMessages = function(hostsToCheck) {
+ for (let hostToCheck of hostsToCheck) {
+ if (hostToCheck.host in this._cursors) {
+ assert(checkLog.checkContainsOnce(
+ hostToCheck,
+ 'killing cursor: ' + this._cursors[hostToCheck.host].exactValueString +
+ ' as part of killing session(s)'),
+ "cursor kill was not logged by " + hostToCheck.host);
+ }
+ }
+ };
+
/**
* We start cursors on all nodes in a very artificial way. In particular, we run currentOp
* (because it's a data source that's always there) and use an agg pipeline to get enough
@@ -259,18 +278,23 @@ var _kill_sessions_api_module = (function() {
},
};
+ var cursors = {};
var result;
if (this._clientToExecuteViaIsdbgrid) {
result = db.runCommand({multicast: cmd});
+ for (let host of Object.keys(result.hosts)) {
+ cursors[host] = result.hosts[host].data.cursor.id;
+ }
} else {
result = db.runCommand(cmd);
+ cursors[db.getMongo().host] = result.cursor.id;
}
if (!result.ok) {
print(tojson(result));
}
assert(result.ok);
- return new CursorHandle(session);
+ return new CursorHandle(session, cursors);
};
/**
@@ -309,6 +333,7 @@ var _kill_sessions_api_module = (function() {
fixture.assertSessionsInCursors([handle], []);
fixture.kill("admin", obj);
fixture.assertNoSessionsInCursors();
+ fixture.assertCursorKillLogMessages([handle]);
handle.join();
},
@@ -319,6 +344,7 @@ var _kill_sessions_api_module = (function() {
fixture.assertSessionsInCursors([handle1, handle2], []);
fixture.kill("admin", obj);
fixture.assertNoSessionsInCursors();
+ fixture.assertCursorKillLogMessages([handle1, handle2]);
handle1.join();
handle2.join();
},
@@ -368,6 +394,7 @@ var _kill_sessions_api_module = (function() {
fixture.kill("admin", obj);
}
fixture.assertSessionsInCursors([handle3], [handle1, handle2]);
+ fixture.assertCursorKillLogMessages([handle1, handle2]);
handle1.join();
handle2.join();
@@ -377,6 +404,7 @@ var _kill_sessions_api_module = (function() {
fixture.kill("admin", obj);
}
fixture.assertNoSessionsInCursors();
+ fixture.assertCursorKillLogMessages([handle3]);
handle3.join();
},
];
@@ -524,6 +552,7 @@ var _kill_sessions_api_module = (function() {
fixture.kill("admin", obj);
}
fixture.assertSessionsInCursors([handle3], [handle1, handle2]);
+ fixture.assertCursorKillLogMessages([handle1, handle2]);
handle1.join();
handle2.join();
@@ -533,6 +562,7 @@ var _kill_sessions_api_module = (function() {
fixture.kill("admin", obj);
}
fixture.assertNoSessionsInCursors();
+ fixture.assertCursorKillLogMessages([handle3]);
handle3.join();
},
];
diff --git a/jstests/sharding/kill_sessions.js b/jstests/sharding/kill_sessions.js
index a3ad23139a0..902023c5671 100644
--- a/jstests/sharding/kill_sessions.js
+++ b/jstests/sharding/kill_sessions.js
@@ -1,3 +1,11 @@
+/*
+ * Run the kill_sessions tests against a sharded cluster.
+ *
+ * TODO SERVER-45385: These tests can be enabled in multiversion once the logging of session cursor
+ * cleanup has been backported and released in last-stable.
+ * @tags: [multiversion_incompatible]
+ */
+
load("jstests/libs/kill_sessions.js");
(function() {