Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4510

SDAM Server Description Equality logic does not handle nullishness as spec-ed

    • Type: Icon: Improvement Improvement
    • Resolution: Works as Designed
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Not Needed

      The following is the rules for topologyVersion comparison

      1. If the response topologyVersion is unset or the ServerDescription's topologyVersion is null, the client MUST assume the response is more recent.
      2. If the response's topologyVersion.processId is not equal to the ServerDescription's, the client MUST assume the response is more recent.
      3. If the response's topologyVersion.processId is equal to the ServerDescription's, the client MUST use the counter field to determine which topologyVersion is more recent.

      Point 1 is not correctly checked by our driver:

      const topologyVersionsEqual =
            this.topologyVersion === other?.topologyVersion ||
            compareTopologyVersion(this.topologyVersion, other?.topologyVersion) === 0;
      

      Here, if both topologyVersions are null we'll true for equality when actually other should always be greater. Fixing this causes a spec test to fail:

      Monitoring a direct connection - suppress update events for equal server descriptions
      

      Extra events are emitted because now the serverDescription changes with nullish topologyVersions are considered different

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: