Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-54507

Can't execute $merge if sharding catalog cache is empty

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.0-rc0
    • Affects Version/s: 4.4.4
    • Component/s: Querying
    • Labels:
      None
    • Fully Compatible
    • ALL
    • v4.9, v4.4, v4.2, v4.0
    • Hide

      Even though it can be reproduced by a far more easy test case, I've been able to reproduce consistently this bug by just flushing the cache for the target collection in jstests/sharding/query/merge_write_concern.js before to execute the $merge aggregation command.

      merge_cache_bug.patch

      Show
      Even though it can be reproduced by a far more easy test case, I've been able to reproduce consistently this bug by just flushing the cache for the target collection in jstests/sharding/query/merge_write_concern.js before to execute the $merge aggregation command. merge_cache_bug.patch
    • Query Execution 2021-03-08, Query Execution 2021-03-22, Query Execution 2021-04-05, Query Execution 2021-04-19, Query Execution 2021-05-03, Query Execution 2021-05-17
    • 145

      Manifestation of the bug: The impossibility to execute the $merge pipeline stage

      Consider the case in which the $merge pipeline stage is executed in a shard that:

      • Has the CollectionShardingState correctly updated with the latest shard version of the target collection.
      • Doesn't currently hold any entry in the cache for the target collection.

      (This is possible because the sharding catalog cache is a LRU cache in which not frequently used entries can be evicted.)

      The shard executes DocumentSourceMerge::createFromBson() that triggers a call to MongoProcessInterface::ensureFieldsUniqueOrResolveDocumentKey().  This function in the end throws a StaleConfigInfo because the target collection is not present in the cache. The error is correctly handled by the shard that will execute the onShardVersionMismatch() procedure.

      Since the CollectionShardingState already contains the latest shard version for the target collection no action will be taken and no refresh of the catalog cache will be triggered.

      In other words if the CollectionShardingState is up to date, the StaleConfigInfo won't guarantee that the catalog cache will be refreshed.

            Assignee:
            eric.cox@mongodb.com Eric Cox (Inactive)
            Reporter:
            tommaso.tocci@mongodb.com Tommaso Tocci
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: