elloooooo closed pull request #6454: Fix race condition in AppenderatorImpl
URL: https://github.com/apache/incubator-druid/pull/6454
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/server/src/main/java/io/druid/segment/realtime/appenderator/AppenderatorImpl.java
 
b/server/src/main/java/io/druid/segment/realtime/appenderator/AppenderatorImpl.java
index a9eb40611d0..96a4accb331 100644
--- 
a/server/src/main/java/io/druid/segment/realtime/appenderator/AppenderatorImpl.java
+++ 
b/server/src/main/java/io/druid/segment/realtime/appenderator/AppenderatorImpl.java
@@ -147,6 +147,7 @@
   private volatile FileLock basePersistDirLock = null;
   private volatile FileChannel basePersistDirLockChannel = null;
   private AtomicBoolean closed = new AtomicBoolean(false);
+  private final Object sinkLock = new Object();
 
   AppenderatorImpl(
       DataSchema schema,
@@ -474,9 +475,10 @@ public Object call() throws Exception
           indexesToPersist.add(Pair.of(hydrant, identifier));
         }
       }
-
-      if (sink.swappable()) {
-        indexesToPersist.add(Pair.of(sink.swap(), identifier));
+      synchronized (sinkLock) {
+        if (sink.swappable()) {
+          indexesToPersist.add(Pair.of(sink.swap(), identifier));
+        }
       }
     }
 
@@ -611,7 +613,8 @@ public Object doCall()
   private ListenableFuture<?> pushBarrier()
   {
     return intermediateTempExecutor.submit(
-        (Runnable) () -> pushExecutor.submit(() -> {})
+        (Runnable) () -> pushExecutor.submit(() -> {
+        })
     );
   }
 
@@ -619,8 +622,8 @@ public Object doCall()
    * Merge segment, push to deep storage. Should only be used on segments that 
have been fully persisted. Must only
    * be run in the single-threaded pushExecutor.
    *
-   * @param identifier sink identifier
-   * @param sink       sink to push
+   * @param identifier    sink identifier
+   * @param sink          sink to push
    * @param useUniquePath true if the segment should be written to a path with 
a unique identifier
    *
    * @return segment descriptor, or null if the sink is no longer valid


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to