spuru9 commented on code in PR #29056:
URL: https://github.com/apache/flink/pull/29056#discussion_r3913033200


##########
flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/PipelinedSubpartitionTest.java:
##########
@@ -472,6 +473,35 @@ void testConcurrentTimeoutableCheckpointBarrier() throws 
Exception {
                 .isInstanceOf(ExecutionException.class);
     }
 
+    @TestTemplate
+    void testPriorityBarrierAvailableToCreditedReaderWhileBlocked() throws 
Exception {
+        PipelinedSubpartition subpartition = createSubpartition();
+        subpartition.setChannelStateWriter(ChannelStateWriter.NO_OP);
+
+        // Block the subpartition, mirroring the RECOVERY_COMPLETION event 
emitted during recovery.
+        subpartition.add(
+                
EventSerializer.toBufferConsumer(EndOfOutputChannelStateEvent.INSTANCE, false));
+        pollBufferAndCheckType(subpartition, 
Buffer.DataType.RECOVERY_COMPLETION);
+
+        // While blocked and without any priority element, a credited reader 
sees no data.
+        
assertThat(subpartition.getAvailabilityAndBacklog(true).isAvailable()).isFalse();
+        assertThat(subpartition.pollBuffer()).isNull();
+
+        // Enqueue an unaligned checkpoint barrier as a priority element.
+        CheckpointOptions options =
+                CheckpointOptions.unaligned(
+                        CheckpointType.CHECKPOINT, 
CheckpointStorageLocationReference.getDefault());
+        subpartition.add(
+                EventSerializer.toBufferConsumer(
+                        new CheckpointBarrier(1L, System.currentTimeMillis(), 
options), true));
+
+        // The credited-reader availability check must now report available so 
the remote reader is
+        // enqueued and the priority barrier is delivered even though the 
subpartition
+        // stays blocked.
+        
assertThat(subpartition.getAvailabilityAndBacklog(true).isAvailable()).isTrue();
+        pollBufferAndCheckType(subpartition, 
Buffer.DataType.PRIORITIZED_EVENT_BUFFER);

Review Comment:
   (Optional) nit: We could also assert that after the priority buffer is 
polled, the subpartition immediately returns to the blocked state (no longer 
available, pollBuffer() returns null).
   ```suggestion
           pollBufferAndCheckType(subpartition, 
Buffer.DataType.PRIORITIZED_EVENT_BUFFER);
           
           // After the priority element is consumed, the subpartition should 
immediately re-block.
           
assertThat(subpartition.getAvailabilityAndBacklog(true).isAvailable()).isFalse();
           assertThat(subpartition.pollBuffer()).isNull();
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to