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

ReshardingOpObserver performs an invalid CollectionShardingRuntime cast on config servers

    • Fully Compatible
    • ALL
    • v5.0
    • Sharding 2021-09-20, Sharding 2021-10-04
    • 163
    • 1

      ReshardingOpObserver is enabled on both --configsvrs and --shardsvrs. However, config servers use CollectionShardingStateStandalone rather than CollectionShardingRuntime and means calling CollectionShardingRuntime::get() on a config server is incorrect.

      void assertCanExtractShardKeyFromDocs(OperationContext* opCtx,
                                            const NamespaceString& nss,
                                            std::vector<InsertStatement>::const_iterator begin,
                                            std::vector<InsertStatement>::const_iterator end) {
          const auto metadata = CollectionShardingRuntime::get(opCtx, nss)->getCurrentMetadataIfKnown();
          // A user can manually create a 'db.system.resharding.' collection that isn't guaranteed to be
          // sharded outside of running reshardCollection.
          uassert(ErrorCodes::NamespaceNotSharded,
                  str::stream() << "Temporary resharding collection " << nss.toString()
                                << " is not sharded",
                  metadata && metadata->isSharded());
      
          ...
      }
      

      https://github.com/mongodb/mongo/blob/7d58a3a7d1f1a8766c6f289f21ebd977385c4252/src/mongo/db/s/resharding/resharding_op_observer.cpp#L73

            Assignee:
            brett.nawrocki@mongodb.com Brett Nawrocki
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: