Fix read_pref_cmd.js to handle profiler entries being silently discarded

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.0.0-rc0, 8.0.27, 8.3.5
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Integration
    • Fully Compatible
    • ALL
    • v8.3, v8.2, v8.0
    • 200
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Overview

      The test jstests/sharding/read_pref_cmd.js has been intermittently failing in the sharding_clustered_collections suite on enterprise-amazon-linux2023-arm64 after SERVER-111191 was backported to v8.0.

      Root Cause

      SERVER-111191 changed the profiler to discard writes to system.profile when it cannot acquire a lock within internalQueryGlobalProfilingLockDeadlineMs (default: 1ms on master, 0ms on v8.0 at time of backport). On a secondary under load—e.g. during replication batch application—the profiler can fail to acquire an IX lock on the database, causing the profile entry to be silently dropped.

      read_pref_cmd.js relies on profiler entries to verify that commands were routed to the expected node. When an entry is discarded, the assertion assert.eq(getNumNodesCmdRanOn(...), 1) fires because it finds 0 matching entries instead of 1.

      Fix

      Set internalQueryGlobalProfilingLockDeadlineMs: 1000 on all replica set nodes before running the test. This gives the profiler 1 second to acquire the lock, sufficient to absorb transient contention from replication. This matches the pattern used in other profiler-dependent tests (e.g. profile_agg.js, profile3.js).

            Assignee:
            Mariano Shaar
            Reporter:
            Mariano Shaar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: