Validate disaggBlockCacheNumShards is non-negative

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Minor - P4
    • 9.0.0-rc1
    • Affects Version/s: None
    • Component/s: None
    • None
    • Storage Engines - Persistence
    • Fully Compatible
    • SE Persistence backlog
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      disaggBlockCacheNumShards is declared as long long (set_at: startup) but is passed to initBlockCache(), which takes a size_t. A negative value silently converts to a huge size_t, so instead of disabling the cache (per the parameter's intent) it would attempt to construct a block cache with an enormous shard count.

      This was flagged by Copilot during review of the SERVER-129474 PR (#56406), which made disaggBlockCacheSizeBytes runtime-settable. That PR fixed the sibling parameter disaggBlockCacheSizeBytes by adding a validator: {gte: 0}, but disaggBlockCacheNumShards was outside that PR's scope.

      Review comment: https://github.com/10gen/mongo/pull/56406#discussion_r3439988141

      Proposed Solution

      Add a validator to disaggBlockCacheNumShards in src/mongo/db/modules/atlas/src/disagg_storage/server_parameters.idl so negative values are rejected at startup. This guarantees the signed-to-size_t conversion at the initBlockCache() call site in pali_callbacks.cpp is safe. Use gte: 0 (0 disables the cache, consistent with initBlockCache() only building the cache when numShards > 0); confirm with the team whether gte: 1 is preferable since a positive shard count is required for an enabled cache.

      Definition of Done

      • disaggBlockCacheNumShards rejects negative values at startup.
      • The signed-to-size_t conversion at the initBlockCache() call site can no longer produce an unintended huge value.

            Assignee:
            Etienne Petrel
            Reporter:
            Etienne Petrel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: