diff options
author | Daniel Gottlieb <daniel.gottlieb@mongodb.com> | 2021-03-23 15:29:54 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-03-24 14:34:16 +0000 |
commit | 8b64da4e43b7318a7ab8a7580708195b6de91200 (patch) | |
tree | 87dc086db325b5b2dcda530d2752d52c4e43cd1a /jstests | |
parent | 7cfa7de2c1b8cefa90e0b6f4a24f13a0aa3c448a (diff) | |
download | mongo-8b64da4e43b7318a7ab8a7580708195b6de91200.tar.gz |
SERVER-54064: Periodically clear out the logical session cache on arbiters.
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/noPassthrough/server54064.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/jstests/noPassthrough/server54064.js b/jstests/noPassthrough/server54064.js new file mode 100644 index 00000000000..e4bbad6e7fd --- /dev/null +++ b/jstests/noPassthrough/server54064.js @@ -0,0 +1,57 @@ +/** + * Assert that arbiters periodically clear out their logical session cache. Inability to do so + * prohibits new clients from connecting. + * + * @tags: [requires_replication] + */ +(function() { +const name = "server54064"; +const replSet = new ReplSetTest({ + name: name, + nodes: 2, + // `disableLogicalSessionCacheRefresh` is true by default, but is disabled for testing purposes + // in servers spawned from the shell. + nodeOptions: { + setParameter: { + // Each refresh on an arbiter will empty the cache. + logicalSessionRefreshMillis: 10000, + // The number of connections/sessions before the cache is full, prohibiting new clients + // from connecting. + maxSessions: 3, + disableLogicalSessionCacheRefresh: false + } + } +}); +const nodes = replSet.nodeList(); + +replSet.startSet(); +replSet.initiate({ + _id: name, + members: [{_id: 0, host: nodes[0]}, {_id: 1, host: nodes[1], arbiterOnly: true}], +}); + +let arbConn = replSet.getArbiter(); +assert.soon(() => { + // Connect to mongo in a tight loop to exhaust the number of available logical sessions in the + // cache. + const result = new Mongo(arbConn.host).adminCommand({hello: 1}); + if (result['ok'] === 0) { + assert.commandFailedWithCode(result, ErrorCodes.TooManyLogicalSessions); + return true; + } + return false; +}); + +assert.soon(() => { + // Once we observe that the number of sessions is maxed out, loop again to confirm that the + // cache eventually does get cleared. + const result = new Mongo(arbConn.host).adminCommand({hello: 1}); + if (result['ok'] === 0) { + assert.commandFailedWithCode(result, ErrorCodes.TooManyLogicalSessions); + return false; + } + return true; +}); + +replSet.stopSet(); +})(); |