https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34470

--- Comment #3 from Emily Lamancusa <emily.lamanc...@montgomerycountymd.gov> ---
The logging makes it clear that the call to shuffle() in
load_branches_to_pull_from is "randomizing" deterministically for some reason.
According to the List::Utils docs, shuffle() depends on Perl's rand() function
(unless an alternative method is set).

I think the bug has to do with the scenario described here:
https://stackoverflow.com/questions/58120618/how-to-get-random-number-in-forked-processes

We do fork at minimum one process to process a background job (or more
depending on configuration after bug 32558). According to the above, if a
parent process uses rand() and later spawns a child process which also calls
rand(), every child process will inherit the same seed and thus produce an
identical random number sequence unless the seed is reset with srand() after
the fork.

The official docs for rand() don't quite spell this out but they allude to the
need to call srand() in a child process (though they also warn that srand()
should not be called more than once per process).

The results I'm seeing are consistent with this, and that would also explain
why this doesn't happen in the cron job (which does not fork).

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
Koha-bugs@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to