Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reworks InMemoryResumableFramesStore and improves its tests coverage #1014

Merged
merged 3 commits into from
Jun 4, 2021

Conversation

OlegDokuka
Copy link
Member

@OlegDokuka OlegDokuka commented May 31, 2021

Main Changes Description

At the moment Resumability implementation is unstable due to its non-well-covered reworked impl.

As it was uncovered, the main root-cause of the problem is the incorrect state synchronization in InMemoryResumableFrameStore when it comes to the connection reestablishment (e.g. the previous connection was lost so we need to go through the resume handshake phase).

As it was observed, the local producers may produce more elements while the new subscriber iterating over the cached value may miss some updates.

To resolve the mentioned problem, InmemoryResumableFrameStore is reworked again with the thought of backpressure (via ASYNC fusion) and fully sequentially signals processing (using WorkInProgress pattern).

The first improvements allow draining elements from the upfront Publisher (at the moment UnboundedProcessor which does not support backpressure but we should have a proper once #752 is implemented) only when there is an active connection. In general, relying on queue.poll only (instead of handling data from onNext) decreases the amount of potentially concurrent signals we have to deal with and ensures that the new connection does not have to mess with duplicates-checking logic.

The second improvement eliminates the need for synchronized keyword and replaces it with volatile long state machine over which we can expose various changes without introducing an expensive MpScQueue

Side Changes Description

There are some LocalDuplexConnection and UnboundedProcessor modifications as a part of this PR. These modifications are mainly to ensure that e2e resumability tests pass with LocalTransport. LocalDuplexConnection (used in LocalClient/ServerTransport) embraces UnboundedProcessor to exchange frames between peers. Before these changes, it was not possible to track when all the frames are delivered / discarded. Thus, it was not possible to notify about the real termination of the DuplexConnection. The modifications to UnboundedProcessor provide a ondisposehook handle which allows tracking when the queue is cleaned and closed - hence notify the duplex connection that it can be terminated as well.

@OlegDokuka OlegDokuka added the bug label May 31, 2021
@OlegDokuka OlegDokuka added this to the 1.1.1 milestone May 31, 2021
@OlegDokuka OlegDokuka force-pushed the bugfix/i-memory-frame-store branch 2 times, most recently from ef1572b to 64c050f Compare May 31, 2021 20:26
@OlegDokuka OlegDokuka linked an issue Jun 1, 2021 that may be closed by this pull request
@OlegDokuka OlegDokuka force-pushed the bugfix/i-memory-frame-store branch 2 times, most recently from 9ea7cd3 to 81db43f Compare June 2, 2021 09:44
@OlegDokuka OlegDokuka force-pushed the bugfix/i-memory-frame-store branch 2 times, most recently from f14efe3 to 8895956 Compare June 3, 2021 04:58
this includes:
  * rework of InMemoryResumableFramesStore and improvement in its tests coverage
  * improvements in Client/Server resume Session and ensuring that if connection is rejected for any reasons - it is fully closed on both outbound and inbound ends (This fix is needed for LocalDuplexConnection scenario which may be in unterminated state if it will not be subscribed on the inbound)
  * enabling resumability tests for LocalTransport
  * improvements in logging
  * general cleanups and polishing

Signed-off-by: Oleh Dokuka <[email protected]>
Signed-off-by: Oleh Dokuka <[email protected]>
…ases)

At the moment, the onClose hook has no "wait until cleaned" logic, which leads to unpredicted behaviors when used with resumability or others scenarios where we need to wait until all the queues are cleaned and there are no other resources in use (e.g. ByteBufs). For that porpuse, this commit adds onFinalizeHook to the UnboundedProcessor so we can now listen when the UnboundedProcessor is finalized and only after that send the onClose signal

Signed-off-by: Oleh Dokuka <[email protected]>
Signed-off-by: Oleh Dokuka <[email protected]>
@OlegDokuka OlegDokuka force-pushed the bugfix/i-memory-frame-store branch from 05051c5 to f70cd35 Compare June 4, 2021 18:35
@OlegDokuka OlegDokuka merged commit 7e8b785 into master Jun 4, 2021
@OlegDokuka OlegDokuka deleted the bugfix/i-memory-frame-store branch June 4, 2021 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Local and remote state disagreement
2 participants