I have a server program that randomly selects 10 from a group of network peers to accomplish a task. The code that generates the random indices of the peers is as follows:
indices = let index = getStdRandom $ randomR (0, number_of_peers - 1) in sequence $ replicate 10 index
The program has been running for months, generating thousands of `indices' each day, and has been working fine until yesterday, when I noticed that something has gone wrong: the random numbers generated seem to "converge" to a few repeating values (the result is that the corresponding network peers are heavily loaded).
To see the change, below is from the server log a few days ago:
peers selected: [55,47,80,74,183,85,04,33,72,58]
and the log from today's (as you can see, peer 53, 37 and 195 are repeatedly selected):
peers selected: [53,53,37,37,37,37,195,195,195,21]
The program is running on an x86_64 version of Ubuntu 10.10.
After investigation this turns out to be an embarrassing bug of my own: the root user on this server has a limit of maximum open files of 1024, which is unexpectedly low (but I heard that this is the default on Ubuntu). When the server program has too many open sockets, some part of the system starts to reject the peers, making their status 'inactive'. The actual 'indices' is:
indices = let index = getStdRandom $ randomR (0, M.size active - 1) in sequence $ replicate (n * 2) index
I'm sorry if this question is causing any trouble or confusion. I'll try to post more prudently next time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With