zhijiangW opened a new pull request #12261:
URL: https://github.com/apache/flink/pull/12261
## What is the purpose of the change
RemoteInputChannel#releaseAllResources might be called by canceler thread.
Meanwhile, the task thread can also call RemoteInputChannel#getNextBuffer.
There probably cause two potential problems:
1. Task thread might get null buffer after canceler thread already released
all the buffers, then it might cause misleading NPE in getNextBuffer.
2. Task thread and canceler thread might pull the same buffer concurrently,
which causes unexpected exception when the same buffer is recycled twice.
The solution is to properly synchronize the buffer queue in release method
to avoid the same buffer pulled by both canceler thread and task thread.
And in getNextBuffer method, we add some explicit checks to avoid misleading
NPE and hint some valid exceptions.
## Brief change log
- Fix the synchronized `receivedBuffers` in
`RemoteInputChannel#releaseAllResources`
- check the released state and give proper exceptions in
`RemoteInputChannel#getNextBuffer`
## Verifying this change
New unit test in
`RemoteInputChannelTest#testConcurrentGetNextBufferAndRelease
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (yes / **no**)
- The public API, i.e., is any changed class annotated with
`@Public(Evolving)`: (yes / **no**)
- The serializers: (yes / **no** / don't know)
- The runtime per-record code paths (performance sensitive): (yes / **no**
/ don't know)
- Anything that affects deployment or recovery: JobManager (and its
components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (yes / **no** /
don't know)
- The S3 file system connector: (yes / **no** / don't know)
## Documentation
- Does this pull request introduce a new feature? (yes / **no**)
- If yes, how is the feature documented? (**not applicable** / docs /
JavaDocs / not documented)
----------------------------------------------------------------
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]