Skip to content

Commit b425fe5

Browse files
committed
refactor(topology): remove extra timers around selection monitoring
1 parent 2d976bd commit b425fe5

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

lib/core/sdam/server_selection.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ const MongoTimeoutError = require('../error').MongoTimeoutError;
88

99
const common = require('./common');
1010
const STATE_CLOSED = common.STATE_CLOSED;
11-
const TOPOLOGY_DEFAULTS = common.TOPOLOGY_DEFAULTS;
12-
const drainTimerQueue = common.drainTimerQueue;
1311
const clearAndRemoveTimerFrom = common.clearAndRemoveTimerFrom;
1412

1513
// max staleness constants
@@ -183,7 +181,8 @@ function readPreferenceServerSelector(readPreference) {
183181
const commonWireVersion = topologyDescription.commonWireVersion;
184182
if (
185183
commonWireVersion &&
186-
(readPreference.minWireVersion && readPreference.minWireVersion > commonWireVersion)
184+
readPreference.minWireVersion &&
185+
readPreference.minWireVersion > commonWireVersion
187186
) {
188187
throw new MongoError(
189188
`Minimum wire version '${
@@ -298,18 +297,10 @@ function selectServers(topology, selector, timeout, start, callback) {
298297
}
299298

300299
const retrySelection = () => {
301-
// clear all existing monitor timers
302-
drainTimerQueue(topology.s.monitorTimers);
303-
304300
// ensure all server monitors attempt monitoring soon
305-
topology.s.servers.forEach(server => {
306-
const timer = setTimeout(
307-
() => server.monitor({ heartbeatFrequencyMS: topology.description.heartbeatFrequencyMS }),
308-
TOPOLOGY_DEFAULTS.minHeartbeatFrequencyMS
309-
);
310-
311-
topology.s.monitorTimers.add(timer);
312-
});
301+
topology.s.servers.forEach(server =>
302+
server.monitor({ heartbeatFrequencyMS: topology.description.heartbeatFrequencyMS })
303+
);
313304

314305
const iterationTimer = setTimeout(() => {
315306
topology.removeListener('topologyDescriptionChanged', descriptionChangedHandler);

lib/core/sdam/topology.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ class Topology extends EventEmitter {
175175
clusterTime: null,
176176

177177
// timer management
178-
monitorTimers: new Set(),
179178
iterationTimers: new Set(),
180179
connectionTimers: new Set()
181180
};
@@ -334,7 +333,6 @@ class Topology extends EventEmitter {
334333
}
335334

336335
// clear all existing monitor timers
337-
drainTimerQueue(this.s.monitorTimers);
338336
drainTimerQueue(this.s.iterationTimers);
339337
drainTimerQueue(this.s.connectionTimers);
340338

0 commit comments

Comments
 (0)