GitHub user lukecwik opened a pull request: https://github.com/apache/beam/pull/3992
[BEAM-1487, BEAM-3016] Address termination correctness issues in BufferingStreamObserver & BeamFnLoggingClient The issue with BeamFnLoggingClient is that we can't arriveAndDeregister during termination since the onReadyHandler may also arrive at the same time which is why we swap to using forced termination. Also, I added code that would guarantee that log messages produced by the thread which is shutting down are guaranteed to make it (this was being caught occassionally by the testLogging test). The BufferingStreamObserver was incorrectly shutting down since it may attempt to enqueue something into a full queue with a reading thread that has already exitted for some reason so it would loop forever attempting to insert the poison pill. Follow this checklist to help us incorporate your contribution quickly and easily: - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/projects/BEAM/issues/) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [ ] Each commit in the pull request should have a meaningful subject line and body. - [ ] Format the pull request title like `[BEAM-XXX] Fixes bug in ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA issue. - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [ ] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). --- You can merge this pull request into a Git repository by running: $ git pull https://github.com/lukecwik/incubator-beam master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/beam/pull/3992.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #3992 ---- commit 9dd1c5be1c79de55a49e827e8cd9d2418a9a55b8 Author: Luke Cwik <lc...@google.com> Date: 2017-10-12T23:26:29Z [BEAM-1487, BEAM-3016] Address termination correctness issues in BufferingStreamObserver & BeamFnLoggingClient The issue with BeamFnLoggingClient is that we can't arriveAndDeregister during termination since the onReadyHandler may also arrive at the same time which is why we swap to using forced termination. Also, I added code that would guarantee that log messages produced by the thread which is shutting down are guaranteed to make it (this was being caught occassionally by the testLogging test). The BufferingStreamObserver was incorrectly shutting down since it may attempt to enqueue something into a full queue with a reading thread that has already exitted for some reason so it would loop forever attempting to insert the poison pill. ---- ---