Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-10954

Random values from __wt_random() from different seeds converge

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • WT11.2.0, 7.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None

      Summary

      Our random-number generator function __wt_random(), even when it is initialized from different seeds, eventually converges to the same state.

       

      Analysis

      The convergence happen as soon as z or w become 0:

          if (z == 0 || w == 0) {
              __wt_random_init(&rnd);
              w = M_W(rnd);
              z = M_Z(rnd);
          }

      Function __wt_random_init() uses fixed values, so as soon as this branch is hit, the generation of random numbers across different runs (even with the same seed) converges.

       

      Near-instant convergence

      To make the matter worse, this converges instantly in test push_pull! The test initializes the seed like this:

          /* Seed the random number generator */
          v = (uint32_t)getpid() + num_records + (2 * counter);
          __wt_random_init_custom_seed(&rnd, v);
      

      This generates a number that is less than 2^32, which means that value z of the test state starts by being initialized to 0. This triggers re-initialization to the fixed values as explained above on the first use of the function.

            Assignee:
            peter.macko@mongodb.com Peter Macko
            Reporter:
            peter.macko@mongodb.com Peter Macko
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: