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

Race in TicketHolderTests

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Storage Execution
    • ALL
    • Hide
      • Comment out all tests in ticketholder_test.cpp except for PriorityTwoQueuedOperations.
      • Apply this diff
        diff --git a/src/mongo/util/concurrency/priority_ticketholder.cpp b/src/mongo/util/concurrency/priority_ticketholder.cpp
        index ab234ee3c8f..f48d68d3745 100644
        --- a/src/mongo/util/concurrency/priority_ticketholder.cpp
        +++ b/src/mongo/util/concurrency/priority_ticketholder.cpp
        @@ -85,6 +85,10 @@ boost::optional<Ticket> PriorityTicketHolder::_waitForTicketUntilImpl(OperationC
             _enqueuedElements.addAndFetch(1);
             ON_BLOCK_EXIT([&] { _enqueuedElements.subtractAndFetch(1); });
         
        +    if (admCtx->getPriority() == AdmissionContext::Priority::kNormal) {
        +        sleep(100);
        +    }
        +
             ticket_queues::UniqueLockGuard uniqueQueueLock(_queueMutex);
             do {
                 while (_ticketsAvailable.load() <= 0 ||
        
      • Run ninja -j400 +ticketholder_test
      Show
      Comment out all tests in ticketholder_test.cpp except for PriorityTwoQueuedOperations. Apply this diff diff --git a/src/mongo/util/concurrency/priority_ticketholder.cpp b/src/mongo/util/concurrency/priority_ticketholder.cpp index ab234ee3c8f..f48d68d3745 100644 --- a/src/mongo/util/concurrency/priority_ticketholder.cpp +++ b/src/mongo/util/concurrency/priority_ticketholder.cpp @@ -85,6 +85,10 @@ boost::optional<Ticket> PriorityTicketHolder::_waitForTicketUntilImpl(OperationC _enqueuedElements.addAndFetch(1); ON_BLOCK_EXIT([&] { _enqueuedElements.subtractAndFetch(1); }); + if (admCtx->getPriority() == AdmissionContext::Priority::kNormal) { + sleep(100); + } + ticket_queues::UniqueLockGuard uniqueQueueLock(_queueMutex); do { while (_ticketsAvailable.load() <= 0 || Run ninja -j400 +ticketholder_test
    • 60

      Multiple tests in the TicketHolder test suite can fail when adding a sleep between the time _enqueuedElements and the _queueMutex is acquired (see linked BFs). It is not safe to rely on _enqueuedElements to determine when an operation has successfully been enqueued. The way the TicketHolder is tested should be changed to account for this.

      Original Description:
      This test (PriorityTwoQueuedOperations) checks whether both the low and normal priority ticket operations have been enqueued by checking a metric that's incremented before the tickets are actually enqueued (see here). This can result in a hang here as the low priority operation can get the ticket before the normal priority operation.

            Assignee:
            backlog-server-execution [DO NOT USE] Backlog - Storage Execution Team
            Reporter:
            gregory.wlodarek@mongodb.com Gregory Wlodarek
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: