0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

SERVER-31828 endSession in js should end sessions

endSessions is of the form

{ endSessions: [] },

not

{ endSessions: 1, lsids: []}.

fix it up and add a test
This commit is contained in:
Jason Carey 2017-11-03 16:07:49 -04:00
parent df03dc67fa
commit dc04d7d6f2
3 changed files with 18 additions and 15 deletions

View File

@ -68,4 +68,20 @@
res = admin.runCommand(refresh);
assert.commandWorked(res, "failed to refresh");
// verify that end on the session handle actually ends sessions
{
var session = conn.startSession();
assert.commandWorked(session.getDatabase("admin").runCommand(refresh), "failed to refresh");
assert.eq(
config.system.sessions.count(), 1, "refresh should have written 1 session record");
session.endSession();
assert.commandWorked(admin.runCommand(refresh), "failed to refresh");
assert.eq(config.system.sessions.count(),
0,
"endSessions and refresh should result in 0 remaining sessions");
}
MongoRunner.stopMongod(conn);
}());

View File

@ -29,9 +29,4 @@ structs:
description: "A struct representing an endSessions command"
strict: true
fields:
endSessions: int
ids: array<object>
"$clusterTime":
cpp_name: clusterTime
type: object
optional: true
endSessions: array<object>

View File

@ -76,15 +76,7 @@ void endSession(SessionHolder* holder) {
EndSessions es;
es.setEndSessions(1);
es.setIds({holder->lsid});
if (holder->client->isMongos()) {
auto clusterTime = MongoBase::getClusterTime();
if (!clusterTime.isEmpty()) {
es.setClusterTime(clusterTime);
}
}
es.setEndSessions({holder->lsid});
BSONObj out;
holder->client->runCommand("admin", es.toBSON(), out);