NicoK closed pull request #6974: [FLINK-10727][network] remove unnecessary 
synchronization in SingleInputGate#requestPartitions()
URL: https://github.com/apache/flink/pull/6974
 
 
   

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/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/consumer/SingleInputGate.java
 
b/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/consumer/SingleInputGate.java
index f51dc7417ab..2856ca1c33a 100644
--- 
a/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/consumer/SingleInputGate.java
+++ 
b/flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/consumer/SingleInputGate.java
@@ -477,26 +477,28 @@ public boolean isFinished() {
 
        @Override
        public void requestPartitions() throws IOException, 
InterruptedException {
-               synchronized (requestLock) {
-                       if (!requestedPartitionsFlag) {
-                               if (isReleased) {
-                                       throw new 
IllegalStateException("Already released.");
-                               }
+               if (requestedPartitionsFlag) {
+                       return;
+               }
 
-                               // Sanity checks
-                               if (numberOfInputChannels != 
inputChannels.size()) {
-                                       throw new IllegalStateException("Bug in 
input gate setup logic: mismatch between" +
-                                                       "number of total input 
channels and the currently set number of input " +
-                                                       "channels.");
-                               }
+               synchronized (requestLock) {
+                       if (isReleased) {
+                               throw new IllegalStateException("Already 
released.");
+                       }
 
-                               for (InputChannel inputChannel : 
inputChannels.values()) {
-                                       
inputChannel.requestSubpartition(consumedSubpartitionIndex);
-                               }
+                       // Sanity checks
+                       if (numberOfInputChannels != inputChannels.size()) {
+                               throw new IllegalStateException("Bug in input 
gate setup logic: mismatch between" +
+                                               "number of total input channels 
and the currently set number of input " +
+                                               "channels.");
                        }
 
-                       requestedPartitionsFlag = true;
+                       for (InputChannel inputChannel : 
inputChannels.values()) {
+                               
inputChannel.requestSubpartition(consumedSubpartitionIndex);
+                       }
                }
+
+               requestedPartitionsFlag = true;
        }
 
        // 
------------------------------------------------------------------------


 

----------------------------------------------------------------
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

Reply via email to