You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/05/15 09:04:38 UTC

[GitHub] [flink] StefanRRichter commented on a change in pull request #8443: [FLINK-12510][network] Fix deadlock in InputGates

StefanRRichter commented on a change in pull request #8443: [FLINK-12510][network] Fix deadlock in InputGates
URL: https://github.com/apache/flink/pull/8443#discussion_r284155595
 
 

 ##########
 File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/consumer/UnionInputGate.java
 ##########
 @@ -210,12 +211,16 @@ public void requestPartitions() throws IOException, InterruptedException {
 				}
 
 				Iterator<InputGate> inputGateIterator = inputGatesWithData.iterator();
-				final InputGate inputGate = inputGateIterator.next();
+				inputGate = inputGateIterator.next();
 				inputGateIterator.remove();
+			}
 
-				// In case of inputGatesWithData being inaccurate do not block on an empty inputGate, but just poll the data.
-				Optional<BufferOrEvent> bufferOrEvent = inputGate.pollNextBufferOrEvent();
+			// In case of inputGatesWithData being inaccurate do not block on an empty inputGate, but just poll the data.
+			// Do not poll the gate under inputGatesWithData lock, since this can trigger notifications
+			// that could deadlock because of wrong locks taking order.
+			Optional<BufferOrEvent> bufferOrEvent = inputGate.pollNextBufferOrEvent();
 
+			synchronized (inputGatesWithData) {
 
 Review comment:
   I can see that this can fix the deadlock, but it also splits up a previously atomic operation into two parts. I could not spot a concrete problem with it, just wanted to make sure that we don't miss a potential problem here.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services