reswqa commented on code in PR #22381:
URL: https://github.com/apache/flink/pull/22381#discussion_r1166961006
##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/LocalBufferPool.java:
##########
@@ -766,13 +776,12 @@ private void returnExcessMemorySegments() {
@GuardedBy("availableMemorySegments")
private boolean hasExcessBuffers() {
- return numberOfRequestedOverdraftMemorySegments > 0
- || numberOfRequestedMemorySegments > currentPoolSize;
+ return numberOfRequestedOverdraftMemorySegments > 0;
}
@GuardedBy("availableMemorySegments")
private boolean isRequestedSizeReached() {
- return numberOfRequestedMemorySegments >= currentPoolSize;
+ return numberOfRequestedMemorySegments == currentPoolSize;
Review Comment:
> In my opinion, the rule of thumb for concurrent code looks something like
this: "If the value physically can be greater than the border value we should
also compare it with the border as >= even if logically it can not be greater".
This rule really make sense to me and thanks for telling me about this!
Maybe I was a little too radical before. After all, the world full of
concurrency is not safe at all. 😞
--
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]