StephanEwen opened a new pull request #11018: [FLINK-15905][runtime] Fix race 
condition between allocation and release of OpaqueMemoryResource
URL: https://github.com/apache/flink/pull/11018
 
 
   ## What is the purpose of the change
   
   Fixes the race condition when releasing `OpaqueMemoryResource`between the 
following lines: 
   ```java
   final boolean allDisposed = sharedResources.release(type, leaseHolder);
   if (allDisposed) {
        releaseMemory(type, MemoryType.OFF_HEAP, size);
   }
   ```
     - The shared resource release happens under lock
     - Releasing the memory to the memory manager is outside the lock
     - Another thread can find the resource released, but the memory not yet 
returned
   
   The solution is to push the memory release (via a lambda) into the 
`sharedResources` such that the release also happens under the lock.
   
   ## Verifying this change
   
   This extends the existing unit tests.
   Thread safety is not verified in unit tests, as this is not easily possible.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): **no**
     - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: **no**
     - The serializers: **no**
     - The runtime per-record code paths (performance sensitive): **no**
     - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Yarn/Mesos, ZooKeeper: **no**
     - The S3 file system connector: **no**
   
   ## Documentation
   
     - Does this pull request introduce a new feature? **no**
     - If yes, how is the feature documented? **not applicable**
   

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to