kezhuw commented on a change in pull request #15273:
URL: https://github.com/apache/flink/pull/15273#discussion_r599277345



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/memory/MemoryManager.java
##########
@@ -346,9 +346,6 @@ private MemorySegment releaseSegmentsForOwnerUntilNextOwner(
                     while (segmentsIterator.hasNext()) {
                         MemorySegment segment = segmentsIterator.next();
                         try {
-                            if (segment == null || segment.isFreed()) {

Review comment:
       I am also not sure. But old code passes following testing code, while 
new code fails.
   
   ```java
       @Test
       public void testMemoryManagerReleaseNullInMedian() throws Exception {
           List<MemorySegment> segments = memoryManager.allocatePages(this, 5);
           segments.add(null);
           memoryManager.allocatePages(this, segments, 5);
           memoryManager.release(segments);
       }
   ```
   
   I raised this solely because explicit null-tolerance in 
`MemoryManager.release` not my preference. If we want drop null-tolerance, I 
think a dedicated follow up is needed anyway. Otherwise, following code still 
passes in new code.
   
   ```java
       @Test
       public void testMemoryManagerReleaseNullInHead() throws Exception {
           List<MemorySegment> segments = new ArrayList<>();
           segments.add(null);
           memoryManager.allocatePages(this, segments, 5);
           memoryManager.release(segments);
       }
   ```
   
   A dedicated follow up express strong opinion to drop null-tolerance.
   
   I am ok with current situation if there is a consensus and a followup to 
drop this null-tolerance. Otherwise, I think it introduce inconsistent in codes.




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


Reply via email to