You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/10/20 13:41:44 UTC
[lucene-solr] 01/02: @1041 ensureBufferTlog should thread saftey
should work same as ensureLog.
This is an automated email from the ASF dual-hosted git repository.
markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit 93bc02afc418668a42bfbd7c03bf3b468b8a7615
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Mon Oct 19 22:48:46 2020 -0500
@1041 ensureBufferTlog should thread saftey should work same as ensureLog.
---
solr/core/src/java/org/apache/solr/update/UpdateLog.java | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
index 30b6792..d36aaf8 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
@@ -1410,9 +1410,19 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
protected void ensureBufferTlog() {
if (bufferTlog != null) return;
- String newLogName = String.format(Locale.ROOT, LOG_FILENAME_PATTERN, BUFFER_TLOG_NAME, System.nanoTime());
- bufferTlog = newTransactionLog(new File(tlogDir, newLogName), globalStrings, false);
- bufferTlog.isBuffer = true;
+
+ if (bufferTlog == null) {
+ tlogLock.lock();
+ try {
+ if (bufferTlog == null) {
+ String newLogName = String.format(Locale.ROOT, LOG_FILENAME_PATTERN, BUFFER_TLOG_NAME, System.nanoTime());
+ bufferTlog = newTransactionLog(new File(tlogDir, newLogName), globalStrings, false);
+ bufferTlog.isBuffer = true;
+ }
+ } finally {
+ tlogLock.unlock();
+ }
+ }
}
// Cleanup old buffer tlogs