On Fri, Sep 25, 2020 at 03:26:05PM +0200, Maciej Zdeb wrote:
> > Here I can suggest to implement Yarrow PRGN (that is very simple to
> > implement) with some lua-pure cryptographic hash function.
> 
> We're using lrandom because of the algorithm Mersenne Twister and its well
> known weaknesses and strengths.
> 
> > In fact I know it's possible to call haproxy's internal sample fetch
> > functions from Lua (I never can figure how to do that, I always need
> > to lookup an example for this unfortunately). But once you figure out how
> > to do it, you can call the "rand()" sample fetch that will call the
> > internal thread-safe random number generator.
> 
> Rand() sample fetch cannot be seeded (at the time we checked) so on HAProxy
> servers with nbproc > 1 we got multiple sequences of the same random
> numbers - it was one of the reasons we couldn't use it.

That was fixed long ago in 2.2-dev4 exactly for this reason:

  commit 52bf839394e683eec2fa8aafff5a0dd51d2dd365
  Author: Willy Tarreau <w...@1wt.eu>
  Date:   Sun Mar 8 00:42:37 2020 +0100

    BUG/MEDIUM: random: implement a thread-safe and process-safe PRNG
    
    This is the replacement of failed attempt to add thread safety and
    per-process sequences of random numbers initally tried with commit
    1c306aa84d ("BUG/MEDIUM: random: implement per-thread and per-process
    random sequences").
    (...)
    It supports fast jumps allowing to cut the period into smaller
    non-overlapping sequences, which we use here to support up to 2^32
    processes each having their own, non-overlapping sequence of 2^96
    numbers (~7*10^28). This is enough to provide 1 billion randoms per
    second and per process for 2200 billion years.

This was backported into 2.0.14 as well. So if you know how to use it
you definitely can right now. But as I mentioned, the thread-unsafety
of lrandom isn't related to your issue at the moment anyway.

> I was mailing outside the list with Willy and Christopher but it's worth
> sharing that the problem occurs even with nbthread = 1. I've managed to
> confirm it today.

Yes, thanks for the info by the way, however being blocked on something
else at the moment I didn't have the opportunity to have a look at it yet.

Regards,
Willy

Reply via email to