bruno-roustant commented on code in PR #3412: URL: https://github.com/apache/solr/pull/3412#discussion_r2176850958
########## solr/core/src/java/org/apache/solr/update/UpdateLog.java: ########## @@ -1592,10 +1595,45 @@ protected void deleteBufferLogs() { } } + /** + * Ensures a transaction log is ready. It is either the current one, or a new one. This method + * must be called with the synchronization monitor on this {@link UpdateLog}. + */ protected void ensureLog() { if (tlog == null) { - String newLogName = String.format(Locale.ROOT, LOG_FILENAME_PATTERN, TLOG_NAME, id); - tlog = newTransactionLog(tlogDir.resolve(newLogName), globalStrings, false); + Path newLogPath; + int numAttempts = 0; + while (true) { + String newLogName = String.format(Locale.ROOT, LOG_FILENAME_PATTERN, TLOG_NAME, id); + newLogPath = tlogDir.resolve(newLogName); + // We expect that the log file does not exist since id is designed to give the index of the + // next transaction log to create. But in very rare cases, the log files listed in the + // init() method may be stale here (file system delay?), and id may point to an existing + // file. + if (!Files.exists(newLogPath)) { + break; + } + // If the "new" log file already exists, refresh the log list and recompute id. Review Comment: Yes, it's probably simpler. I suppose there will still be some risk of race condition, but if it happens the TransactionLog constructor will throw the "new transaction log already exist" blocking only the current update. Next updates will try again to find a new non-existing file. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org