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

ReshardingOpObserver performs an invalid CollectionShardingRuntime cast on config servers

    XMLWordPrintable

Details

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

    Description

      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.

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

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

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: