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

XMLWordPrintableJSON

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

      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
              Reporter:
              Pol Pinol
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: