Add Java process information to UUIDs.makeNode() hash


Currently there is a chance of collision if multiple Java processes on the same machine are using DataStax Java Driver to generate UUIDs. This is because the hash in UUIDs.makeNode() ( doesn't include any process information, such as PID. A simple fix would be to append the value of ManagementFactory.getRuntimeMXBean().getName() to the hash too.

The driver now tries various methods to include the PID in the hash, look at the javadocs of UUIDs for the detailed description.



Pull Requests



Alex Dutra
February 16, 2016, 6:14 PM

thank you for your initial patch. There has been indeed some discussion about how to properly obtain the PID.

First of all, as pointed out in your initial pull request, Sigar is too heavyweight for the Java driver and its binaries do not seem to be up-to-date in Maven Central.

Secondly, thanks to JAVA-727, the driver can now use JNR when available.

So my suggestion here is to try the following methods one by one, in the order they are listed below:

  1. If the System property com.datastax.driver.PID is set then the value to use as a PID will be read from that property;

  2. Otherwise, if a native call to getpid() is possible, then the PID will be read from that call;

  3. Otherwise, an attempt will be made to read the PID from JMX's RuntimeMXBean name, which is a well-known, yet undocumented "hack";

  4. If all of the above methods fail, a random integer will be generated and used as a surrogate PID.

February 15, 2016, 1:35 PM

Good to see this issue is now in progress. Please note that there has been some discussion about the patch supplied to this ticket:

November 12, 2015, 10:29 AM

Same Issue within Cassandra Server is now planned for C* v2.2

Alex Popescu
October 8, 2015, 1:54 AM

can you guys double check in the other drivers? thanks



Francesco Animali


Drew Kutcharian

Fix versions