• Type: Sub-task
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Integration
    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      We will add a new field to MongotExtensionCatalogContext:

       

      typedef struct MongoExtensionCatalogContext {
          // ... 
          const MongoExtensionByteView shardId;
      } MongoExtensionCatalogContext; 

       

      ShardId in the server is a wrapper around std::string and will be treated as such when being passed across the extension-host boundary (e.g. passed as “shard0”). When AstNode::bind() is called on mongos or in a standalone environment, shardId will be empty with a length of 0. The extension will be able to check shardId.length to determine whether the value is meaningful or not.

      On the host, the CatalogContext adapter will populate this field upon construction:

       

      CatalogContext(...)
              : // ...
                _shardId([&]() -> std::string {
                    auto* opCtx = expCtx.getOperationContext();
                    if (opCtx) {
                        auto* shardingState = ShardingState::get(opCtx)
                        if (shardingState && shardingState->enabled()) {
                            return shardingState->shardId().toString();
                        }
                    }
                    return {};
                }()),
                _api(// ... 
                     stringDataAsByteView(StringData(_shardId))) {} 

      Unit Tests

      Append to the existing catalog_context_test.cpp with a test checking shardId initialization in CatalogContext.

            Assignee:
            Josh Siegel
            Reporter:
            Josh Siegel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: