Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

COMPASS-3943: Update to latest node driver 3.3.4 #154

Merged
merged 4 commits into from
Nov 12, 2019
Merged

Conversation

imlucas
Copy link
Contributor

@imlucas imlucas commented Oct 28, 2019

Description

This PR updates the node.js driver from 3.3.2 to the latest release 3.3.4. It contains many improvements and bug fixes. The full changelog is below.

Changelog Highlights

High Priority SDAM Fixes

NODE-2274 "Unified topology never regains nodes which temporarily go down"

Fixes the underlying cause of timeout-related errors such as "Server selection timed out" with more details in COMPASS-3849 COMPASS-3728. The pull request mongodb/node-mongodb-native#2197 contains much more context on the fix, and a new design document includes how and why the node.js driver team chose this architecture and future improvements it will enable.

Fix unsafe Buffer usage

connect: Switch new Buffer(size) -> Buffer.alloc(size) (da90c3a)

Removes the last unsafe buffer usage warning from the devtools console/terminal output when using or developing Compass. Rejoice!

Update from an Aggregation Pipeline

Update: add the ability to specify a pipeline to an update command (#2017) (44a4110)

While it has yet to come up, it is worth noting for the future that Compass can now technically add support for updates in aggregation pipeline stages which are new in MongoDB 4.2.

sdam_viz

sdam_viz: add new tool for visualizing driver sdam changes (738189a)

An internal tool for debugging SDAM (Server Discovery and Monitoring) that could be used as a base for a more productive connection debugging feature in Compass or merely adding to data-service debug logs.

mongodb-core "deprecation"

The mongodb-core dependency has been removed from mongodb-data-service because it has been moved back into the driver codebase as of ~mongodb@3.3.0. mongodb-core will be officially deprecated in the future by the driver team.

node.js driver changelog

Diff v3.3.2...v3.3.4

3.3.4 (2019-11-11)

Bug Fixes

  • close: the unified topology emits a close event on close now (ee0db01)
  • connect: prevent multiple callbacks in error scenarios (5f6a787)
  • monitoring: incorrect states used to determine rescheduling (ec1e04c)
  • pool: don't reset a pool if we'not already connected (32316e4)
  • pool: only transition to DISCONNECTED if reconnect enabled (43d461e)
  • replset: don't leak servers failing to connect (f209160)
  • replset: use correct topologyId for event emission (19549ff)
  • sdam: minHeartbeatIntervalMS => minHeartbeatFrequencyMS (af9fb45)
  • sdam: don't emit close every time a child server closes (818055a)
  • sdam: don't lose servers when they fail monitoring (8a534bb)
  • sdam: don't remove unknown servers in topology updates (1147ebf)
  • sdam: ignore server errors when closing/closed (49d7235)
  • server: don't emit error in connect if closing/closed (62ada2a)
  • server: ensure state is transitioned to closed on connect fail (a471707)
  • topology: report unified topology as nodejs (d126665)
  • topology: set max listeners to infinity for db event relay (edb1335)

Features

  • sdam_viz: add new tool for visualizing driver sdam changes (738189a)
  • sdam_viz: support legacy topologies in sdam_viz tool (1a5537e)
  • update-hints: add support for hint to all update methods (720f5e5)

3.3.3 (2019-10-16)

Bug Fixes

  • change_stream: emit 'close' event if reconnecting failed (f24c084)
  • ChangeStream: remove startAtOperationTime once we have resumeToken (362afd8)
  • connect: Switch new Buffer(size) -> Buffer.alloc(size) (da90c3a)
  • MongoClient: only check own properties for valid options (9cde4b9)
  • mongos: disconnect proxies which are not mongos instances (ee53983)
  • mongos: force close servers during reconnect flow (186263f)
  • monitoring: correct spelling mistake for heartbeat event (21aa117)
  • replset: correct server leak on initial connect (da39d1e)
  • replset: destroy primary before removing from replsetstate (45ac09a)
  • replset: destroy servers that are removed during SDAM flow (9ea0190)
  • saslprep: add in missing saslprep dependency (41f1165)
  • topology: don't early abort server selection on network errors (2b6a359)
  • topology: don't emit server closed event on network error (194dcf0)
  • topology: include all BSON types in ctor for bson-ext support (aa4c832)
  • topology: respect the force parameter for topology close (d6e8936)

Features

  • Update: add the ability to specify a pipeline to an update command (#2017) (44a4110)
  • urlParser: default useNewUrlParser to true (52d76e3)

Checklist

  • Tests have been updated

Two tests were failing with this update because of assumptions made on much older releases of the driver. These tests were for smoke testing functional side effects only, for example, calling count() after disconnect() always throws an immediate error. I've removed them. correct2aac96d208122cd2a92132d2dff2740eaca5cd87

  1. Test connectivity with mongodb-connection-model#test() not via a connect() call because a test should use different timeout values than a connection that will be used more than once. In the case of this test, the selection timeout in the driver is 30000ms, which caused this test to fail with exceeded test timeout of 2000.

  2. The driver supports retryable reads and writes, which invalidates the state the disconnect() test relied upon, resulting in a Topology Destroyed error for subsequent calls to the client once closed. Like Unpin Kerberos so we don't have multiple versions in Compass #1 above, after 30000ms, the count() would eventually error, but again, there are already other test cases covering these code paths.

Motivation and Context

Dependents

Depended on by mongodb-js/compass#1834

Types of changes

  • Patch (non-breaking change which fixes an issue)

@imlucas imlucas changed the title chore: update to mongodb@3.3.3 chore: update to latest node driver Oct 28, 2019
@imlucas
Copy link
Contributor Author

imlucas commented Oct 28, 2019

We'll wait for mongodb@3.3.4 to ship this PR but we can start any low hanging fruit. For example, mongnodb@3.3.3 currently causing test failure:

  1) NativeClient #connect when an invalid connection was provided maps the error message:
     Error: Timeout of 20000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
  
  2) NativeClient #disconnect disconnects the database:
     Uncaught AssertionError: expected 'Server selection timed out after 30000 ms' to include 'connect'
      at test/native-client.test.js:115:36
      at connect (lib/native-client.js:101:18)
      at async.series (node_modules/mongodb-connection-model/lib/connect.js:304:14)
      at node_modules/async/dist/async.js:3888:9
      at node_modules/async/dist/async.js:473:16

@imlucas imlucas changed the title chore: update to latest node driver [DNM] DRAFT: chore: update to latest node driver Oct 28, 2019
@imlucas imlucas changed the title [DNM] DRAFT: chore: update to latest node driver COMPASS-3943: Update to latest node driver 3.3.4 Nov 12, 2019
These were breaking on update because of info leakage from driver.

1. Connectivity is tested with `mongodb-connection-model#test()` not via a connect() call because a test should use different timeout values than a connection which will be used more than once. In the case of this test, the selection timeout in the driver is 30000ms which caused this test to fail with `exceeded test timout of 2000`.

2. Retryable reads and writes are now supported by the driver which invalidates the state the disconnect() test relied upon, resulting in a `Topology Destroyed` errror for subsequent calls to the client once closed. Like #1 above, after 30000ms, the `count()` would eventually error but full disconnect() behavior is tested in many other code paths.
@imlucas imlucas requested review from lrlna and removed request for lrlna November 12, 2019 20:59
@imlucas imlucas merged commit 6d00ad7 into master Nov 12, 2019
@imlucas imlucas deleted the update-driver branch November 12, 2019 21:00
@imlucas
Copy link
Contributor Author

imlucas commented Nov 12, 2019

📦 mongodb-data-service@15.4.0

imlucas added a commit to mongodb-js/compass that referenced this pull request Nov 12, 2019
imlucas added a commit to mongodb-js/compass that referenced this pull request Nov 13, 2019
* chore: update to node driver@3.3.3

* chore: remove extraneous mongodb-core dependency

* COMPASS-3943: Update to mongodb@3.3.4

* chore: update to `mongodb-data-service@15.4.0`

mongodb-js/data-service#154

* fix: Deprecate usage of mongodb-core

Instead use equivalent `require('mongodb').ReadPreference`
imlucas added a commit to mongodb-js/compass that referenced this pull request Nov 13, 2019
* chore: update to node driver@3.3.3

* chore: remove extraneous mongodb-core dependency

* COMPASS-3943: Update to mongodb@3.3.4

* chore: update to `mongodb-data-service@15.4.0`

mongodb-js/data-service#154

* fix: Deprecate usage of mongodb-core

Instead use equivalent `require('mongodb').ReadPreference`
durran pushed a commit to mongodb-js/compass that referenced this pull request Nov 13, 2019
* chore: update to node driver@3.3.3

* chore: remove extraneous mongodb-core dependency

* COMPASS-3943: Update to mongodb@3.3.4

* chore: update to `mongodb-data-service@15.4.0`

mongodb-js/data-service#154

* fix: Deprecate usage of mongodb-core

Instead use equivalent `require('mongodb').ReadPreference`
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant