in src/main/java/com/googlesource/gerrit/plugins/events/fsstore/EventSequence.java [85:105]
protected UniqueUpdate spinSubmit(String event, long maxTries) throws IOException {
try (EventBuilder b = new EventBuilder(paths, event)) {
for (long tries = 0; tries < maxTries; tries++) {
// Phase 1 (can only succeed if update is empty or non-existant)
if (Fs.tryAtomicMove(b.dir, paths.update)) { // rename build/<tmp>/ -> update/
// now there should be: update/<uuid>/next/event
synchronized (this) {
totalUpdates++;
totalSpins += tries - 1;
}
return createUniqueUpdate(b.uuid, true, maxTries - tries); // Advance phases 2 - 6
}
UniqueUpdate update = (UniqueUpdate) completeOngoing(maxTries - tries);
if (update != null) {
tries += update.tries - 1;
}
}
throw new IOException("Cannot submit event " + paths.base + " after " + maxTries + " tries.");
}
}