XComp opened a new pull request, #23296:
URL: https://github.com/apache/flink/pull/23296

   ## What is the purpose of the change
   
   The changes in https://github.com/apache/flink/pull/23180 caused more 
instabilities. Another investigation round revealed that we have, indeed, a 
race condition between the `CollectSinkOperatorCoordinator`'s close operation 
and the request handling. It can be that the `close()` call closes the socket 
while a request is handled. The request handler will only check whether a 
socket is null and reopen it if it's the case (see 
[CollectSinkOperatorCoordinator.java:160](https://github.com/apache/flink/blob/master/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/collect/CollectSinkOperatorCoordinator.java#L160).
   
   This PR also improves the coverage of `CollectSinkOperatorCoordinatorTest`.
   
   ## Brief change log
   
   * Introduces `running` volatile field in `CollectSinkOperatorCoordinator`
   * Introduces `SocketConnection` class to collect socket-related components 
in a single place.
   
   ## Verifying this change
   
   * `CollectSinkOperatorCoordinatorTest.ServerThread` is replaced by 
`CollectSinkOperatorCoordinatorTest.TestingSocketServer`
     * Any obsolete test code (e.g. version forwarding and offset setting) was 
removed because related asserts only verified test code
     * `handle` methods were added to give explicit control over how the 
request should be handled
   * Helper constructors were added to `CollectSinkOperatorCoordinator` (to be 
able to inject custom executors)
   * New test cases were added:
     * `testNoAddress`: (Already existed before) tests the behavior if a no 
server is registered, yet.
     * `testCloseBeforeConnecting`: Covers the actual bug and checks how the 
coordinator behaves if the coordinator is closed before handling the request
     * `testSuccessfulResponse`: Successful handling of the request by the 
server
     * `testServerSideClosingTheServerSocket`: the server shuts down entirely 
while processing a request
     * `testServerSideClosingTheAcceptingSocket`: checks how the coordinator 
behaves when the server side stops accepting requests before handling the 
request
     * `testServerSideNotResponding`: checks how the coordinator behaves if the 
server doesn't respond and the coordinator is closed
     * `testServerSideDisconnectWithReconnect`: checks the reconnect scenario 
(essentially a operator failover)
   
   ## 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): yes
     - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Kubernetes/Yarn, 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.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to