Coverity: convert cloner and service stats counters to AtomicWord

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Replication
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      What

      Convert diagnostic counter fields in `Stats` structs from `size_t` / `long long` to `AtomicWord<long long>`. Update write sites to `.fetchAndAdd(1)` / `.store(0)` and read sites to `.load()`. `AllDatabaseCloner` is already patched (SERVER-112562); apply the same pattern to `CollectionCloner`, `BackupFileCloner`, and `PrimaryOnlyService`.

      Files: `all_database_cloner.cpp/.h`, `collection_cloner.cpp` (lines 609–614), `backup_file_cloner.h` (line 27), `backup_file_cloner.cpp` (line 350), `primary_only_service.cpp` (line 390).

      Resolves: SERVER-110597, SERVER-110605, SERVER-112000, SERVER-112562, SERVER-110244, SERVER-110586, SERVER-110593, SERVER-110596, SERVER-110598, SERVER-108638, SERVER-108708, SERVER-108717, SERVER-108729, SERVER-108730, SERVER-108735, SERVER-110700

      Why

      Stats counters are incremented under the cloner mutex in the hot path but read in `append()` without holding it — intentional, to avoid stalling the clone pipeline. On 32-bit memory buses a 64-bit counter read without synchronization can produce a torn value in `$currentOp` or `replSetGetStatus`. `AtomicWord` provides a sequentially-consistent load with no mutex. Because Coverity cannot be run locally, the type change itself is the proof: Coverity understands `AtomicWord` semantics and will no longer flag the lock-free reads once the type is changed, and the fix is self-evident in the declaration.

            Assignee:
            Unassigned
            Reporter:
            Denis Trailin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: