You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We see some repeat Alt-ids in the database due to the code below in PromoteBanked.java returning the same value in two consecutive calls.
String uuid;
try {
uuid = uuidGen.integerToUUID(Integer.parseInt(util.getNextBankedId()), 32);
} catch (Exception e) {
throw new LimsException("UUID generation failed for sample due to " + e.getMessage());
}
the uuidGen.integerToUUID() does return distinct values from 1-100million so it appears the call to util.getNextBankedId() can, when called consecutively, return the same value.
The text was updated successfully, but these errors were encountered:
I was trying to see if I could build and debug that line of code.
I might be wrong, but it seems like some of the libraries required to build this repo are not available publicly.
I also don't do a lot of Java development so I could be doing something wrong on my end.
Anyway, if this is still an issue for you, my guess is that it's a race condition.
Here's a code snippet I wanted to use on the call to "util.getNextBankedId()".
Maybe it'll help you get to the bottom of it.
The results are random, but it always results in ID duplication in a few of the threads.
importjava.util.concurrent.Semaphore;
classEvilRaceConditionClass {
privateintevilMutableInt;
publicintgetNextBankedId() {
evilMutableInt++;
try {
// simulate a non trivial method that will // force more than one cpu core to be usedThread.sleep(1);
} catch (InterruptedExceptione) {
e.printStackTrace();
}
returnevilMutableInt;
}
}
classRunnableRaceConditionextendsThread {
privatefinalintid;
privatefinalSemaphoresemaphore;
privatefinalEvilRaceConditionClassevil;
RunnableRaceCondition(intid, Semaphoresemaphore, EvilRaceConditionClassevil) {
this.id = id;
this.semaphore = semaphore;
this.evil = evil;
}
@Overridepublicvoidrun() {
try {
// hold all the threads here so that they try to hit getNextBankedId at the same timesemaphore.acquire();
} catch (Exceptione) {
e.printStackTrace();
}
varnextId = evil.getNextBankedId();
System.out.println("Thread ID:" + id + " completed with ID:" + nextId);
}
}
classMain {
publicstaticvoidmain(String[] args) {
inttotalThreads = 10;
varsemaphore = newSemaphore(totalThreads);
varevil = newEvilRaceConditionClass();
varthreads = newRunnableRaceCondition[totalThreads];
for (inti = 0; i < totalThreads; i++) {
threads[i] = newRunnableRaceCondition(i, semaphore, evil);
}
for (Threadthread : threads) {
thread.start();
}
semaphore.release(totalThreads);
for (Threadthread : threads) {
try {
thread.join();
} catch (Exceptione) {
e.printStackTrace();
}
}
}
}
Here's an example output for the code snippet:
Thread ID:1 completed with ID:10
Thread ID:6 completed with ID:10
Thread ID:5 completed with ID:10
Thread ID:4 completed with ID:10
Thread ID:2 completed with ID:10
Thread ID:0 completed with ID:10
Thread ID:3 completed with ID:10
Thread ID:9 completed with ID:10
Thread ID:7 completed with ID:10
Thread ID:8 completed with ID:10
We see some repeat Alt-ids in the database due to the code below in PromoteBanked.java returning the same value in two consecutive calls.
the uuidGen.integerToUUID() does return distinct values from 1-100million so it appears the call to util.getNextBankedId() can, when called consecutively, return the same value.
The text was updated successfully, but these errors were encountered: