wsry commented on a change in pull request #11877: URL: https://github.com/apache/flink/pull/11877#discussion_r662003058
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/PipelinedSubpartition.java ########## @@ -513,19 +514,20 @@ private void increaseBuffersInBacklog(BufferConsumer buffer) { } } - /** - * Gets the number of non-event buffers in this subpartition. - * - * <p><strong>Beware:</strong> This method should only be used in tests in non-concurrent access - * scenarios since it does not make any concurrency guarantees. - */ - @SuppressWarnings("FieldAccessNotGuarded") - @VisibleForTesting + /** Gets the number of non-event buffers in this subpartition. */ public int getBuffersInBacklog() { - if (flushRequested || isFinished) { - return buffersInBacklog; - } else { - return Math.max(buffersInBacklog - 1, 0); + synchronized (buffers) { + if (isBlocked || buffers.isEmpty()) { Review comment: After the channel is blocked, we do not need to allocated any credit at the downstream, because no buffer will be sent. As mentioned in your comment, if the initialCredit is 0, it should return 0. If the initialCredit is not 0, we always have exclusive credits, we still do not need allocate any floating credit. Maybe returning the actual value instead of 0 is a small improvement. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org