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

Fix race caused by concurrent reads and writes to serverGlobalParams.clusterRole in unit tests

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 7.3.0-rc0
    • None
    • None
    • None
    • Fully Compatible
    • 139

    Description

      The race was introduced as part of SERVER-82751 because every time we create a Client, we read serverGlobalParams.clusterRole to check if is a router client. This is safe in production since serverGlobalParams.clusterRole is only set during startup. However, it is causing race in unit tests because we deliberately set serverGlobalParams.clusterRole to whatever each unit test needs to do the testing. Given that Session::isFromRouterPort() can only be true when the transport layer has a router port which can only be true on a mongod with RouterServer role. There is no need to the roles in addition to check isFromRouterPort() when creating a Client, especially since it causes races in a lot of unit tests which would require a lot of effort to rewrite to avoid the race.

      Attachments

        Activity

          People

            cheahuychou.mao@mongodb.com Cheahuychou Mao
            cheahuychou.mao@mongodb.com Cheahuychou Mao
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: