The ContinuousAddRemoveShard validation the shard is empty on decommission always succeeds due to broken iteration code

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: 8.0.0, 8.3.0, 9.1.0-rc0, 9.0.0
    • Component/s: None
    • None
    • Catalog and Routing
    • ALL
    • 馃煩 Routing and Topology
    • None
    • None
    • None
    • None
    • None
    • None

      [Test only issue]

      Problem

      In the ContinuousAddRemoveShard hook, after removing a shard, we decommission it, including a final sanity check validating all collections on the shard are empty.

      However this check always passes due to misuse of pymongo, there are at least 4 issues:

      • In this line we run listCollections on a DB literally called "db_name", not the one referenced by the db_name variable.
      • listCollections returns a dict {ok:1, cursor: ..., ...}. In this line we are iterating over the dict keys ("ok", "cursor", ...), not the collection names.
      • In this line similarly we run find on a collection literally called "coll", not the one referenced by the coll variable.
      • listCollections may return multiple batches but we never iterate them.

      The attached repro demonstrates a shard with non-empty collections is not detected by the hook.

      Proposed solution

      Fix and test the hook code, and create tickets for any issues the fixed code may find.

        1. repro-SERVER-134524.patch
          3 kB
          Joan Bruguera Mic贸

            Assignee:
            Unassigned
            Reporter:
            Joan Bruguera Mic贸
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: