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:
parent
df03dc67fa
commit
dc04d7d6f2
@ -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);
|
||||
}());
|
||||
|
@ -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>
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user