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

Update balancer to use client local Prng for thread-safe shuffling

    • Sharding EMEA
    • Fully Compatible
    • ALL
    • v7.0
    • Sharding EMEA 2023-04-17
    • 0

      As part of introducing the defragmentation policy, we introduced new threads in the balancer. These different threads are using the same random_device to shuffle different vectors, causing data races.

      Currently, we are using std::random_device in:

      We instead need to use the Client local Prng when using std::shuffle as:

      Client * client = ...;
      std::shuffle(begin, end, client->getPrng().urbg());

      With this implementation, we will not worry about thread-safety because the RNG is thread-local.

            Assignee:
            pol.pinol@mongodb.com Pol Pinol
            Reporter:
            pol.pinol@mongodb.com Pol Pinol
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: