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

XMLWordPrintableJSON

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

      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
              Reporter:
              Neal Beeken
              None
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: