Problem of repetitive TUUID

Hi all,
Recently, I’m working on an application based on TRef and TProcessID of ROOT(5.34/11). But here’s the problem, we’ve found multiple jobs generated the exactly same UUID. Here’s some part of log information of two jobs as an example:


JOB1: *** NODE Info: (‘Linux’, ‘xxxx028.xxxx.xx.xx’, ‘2.6.32-504.3.3.el6.x86_64’,
#1 SMP Tue Dec 16 14:29:22 CST 2014’, ‘x86_64’, ‘x86_64’) ***
*** CURRENT PID: 31479 ***

JOB2: *** NODE Info: (‘Linux’, ‘xxxx028.xxxx.xx.xx’, ‘2.6.32-504.3.3.el6.x86_64’,
#1 SMP Tue Dec 16 14:29:22 CST 2014’, ‘x86_64’, ‘x86_64’) ***
*** CURRENT PID: 31483 ***


These two jobs started at the same time(almost) on the same node, and they generated TProcessIDs with the same UUID: 2b4ad90a-8931-11e5-9717-2855a8c0beef  :frowning: 
I believe it's not the problem of algorithm of TUUID. So is there anything else that could be wrong? The machine, the OS, or anything else?

Hi,

do you have access to a ROOT file the job might have generated? If yes, it would be interesting to see what was the ProcessID ROOT detected at runtime.

Danilo

I’ve looked into the code of ROOT(6.34/11) core and found a reason that may cause this problem. This is part of the constructor of TUUID:

   // Create a UUID.
   
   std::cout << "ROOT is creating a UUID" << std::endl;
   static uuid_time_t time_last;
   static UShort_t    clockseq;
   static Bool_t firstTime = kTRUE;
   if (firstTime) {
      std::cout << "gSystem: " << gSystem << std::endl;
      if (gSystem) {
         // try to get a unique seed per process
         UInt_t seed = (UInt_t) (Long64_t(gSystem->Now()) + gSystem->GetPid());
#ifdef R__WIN32
         srand(seed);
#else
         srandom(seed);
#endif
      }
      GetCurrentTime(&time_last);
#ifdef R__WIN32
      clockseq = 1+(UShort_t)(65536*rand()/(RAND_MAX+1.0));
#else
      clockseq = 1+(UShort_t)(65536*random()/(RAND_MAX+1.0));
#endif
      firstTime = kFALSE;
      std::cout << "clockseq: " << clockseq << std::endl;
   }

Of one process, ROOT sets the random seed for the first time creating a TUUID. However, the gSystem is not yet initialized then. So the seed is never set. For every process, we get the same clockseq.
I’ve added several cout to track the code, also in TROOT::InitSystem() ( std::cout << “ROOT is initializing TSystem!” << std::endl;) And this is the result:


ROOT is creating a UUID
gSystem: 0
clockseq: 55063
e8df2eb0-8d98-31e5-9717-fc6d3c417d00
ROOT is initializing TSystem!
ROOT is creating a UUID
e8e18ca0-8d98-11e5-9717-8403c2cabeef


ROOT creates two TUUIDs in my example, and I don’t know what the first TUUID is for, but the second is for the TProcessID. So is this my misuse? And if not, any solutions?

Hi,

I fixed the problem in v6 (where I can use std::chrono).

However I don’t quite understand how it is failing for you yet. gSystem is supposed to be created (via InitSystem()) before the TProcessID is created … Isn’t that your case?

Cheers,
Philippe.