Closed vladak closed 5 years ago
For me this looks more like race condition. I'm able to reproduce this even with 2 projects (every project is checked with separate thread).
Code I used to reproduce it is:
private static long thr1ID = -1;
synchronized (lock) {
if (thr1ID == -1) {
thr1ID = Thread.currentThread().getId();
}
}
if (timestamp.exists()) {
if (!timestamp.setLastModified(System.currentTimeMillis())) {
LOGGER.log(Level.WARNING, "Failed to set last modified time on ''{0}'', {1}",
new Object[]{timestamp.getAbsolutePath(), purpose});
}
} else {
if (Thread.currentThread().getId() == thr1ID) {
try {
Thread.currentThread().sleep(3000);
} catch (InterruptedException ex) {
}
}
if (!timestamp.createNewFile()) {
LOGGER.log(Level.WARNING, "Failed to create file ''{0}'', {1}",
new Object[]{timestamp.getAbsolutePath(), purpose});
}
}
This produces the warning:
WARNING: Failed to create file '/var/opengrok/data/timestamp', used for timestamping the index database.
It might be the problem, the creation of the file should be synchronized. However there might be also something different.
Is this still relevant?
Just indexed large-ish code base from scratch with 1.1-rc, need to check the logs.
The log does not contain the warning message anymore.
A candidate for closing.
When indexing some 600+ projects from scratch, this message appeared on the console couple of times:
It looks that there is some code calling
timestamp.createNewFile()
inIndexDatabase.java#update
after it was created.