-
Notifications
You must be signed in to change notification settings - Fork 1
Fix network recovering #62
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
Conversation
Codecov Report
@@ Coverage Diff @@
## 1-dev #62 +/- ##
==========================================
+ Coverage 82.60% 82.67% +0.06%
==========================================
Files 34 34
Lines 1696 1743 +47
Branches 201 205 +4
==========================================
+ Hits 1401 1441 +40
- Misses 272 278 +6
- Partials 23 24 +1
Continue to review full report at Codecov.
|
Aschen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My dear c#, long time no see but looks good to me 👍
# [1.0.4](https://github.com/kuzzleio/sdk-csharp/releases/tag/1.0.4) (2020-09-25) #### Bug fixes - [ [#62](#62) ] Fix network recovering ([scottinet](https://github.com/scottinet)) ---
Fix a number of problems when handling disconnections, and with asynchronous tasks in general. When `AbstractProtocol.AutoRecover` is set to true: * requests sent through the network would never be resolved when the connection is lost before they receive a response. This means that clients awaiting for a response would freeze forever. With this PR, those tasks are correctly rejected with a `ConnectionLost` exception (we cannot queue them: as far as the SDK is concerned, it cannot know if these requests were received and processed by Kuzzle or not) * there was a race condition when triggering the threaded recovering process where, in rare cases, 2 reconnection attempts would run in parallel, doubling the number of opened sockets * Race conditions could occur and corrupt the requests cache, or freeze the SDK because of an unhandled exception, because of an incorrect use of `lock` (this keyword has no impact when multiple accesses are made to the same "locked" object within the same thread) => semaphores are now used to circumvent the problem * Requests tasks were incorrectly configured, making their resolution synchronous. This means that resolving tasks in the SDK event handlers (which manage network state changes) could prevent them to finish in a timely fashion (or... ever) because they would synchronously trigger awaiting code * Save our standard code style directly in the solution to share it to whomever works on the project
# Description Fix a number of problems when handling disconnections, and with asynchronous tasks in general. ## Network disconnection When `AbstractProtocol.AutoRecover` is set to true: * requests sent through the network would never be resolved when the connection is lost before they receive a response. This means that clients awaiting for a response would freeze forever. With this PR, those tasks are correctly rejected with a `ConnectionLost` exception (we cannot queue them: as far as the SDK is concerned, it cannot know if these requests were received and processed by Kuzzle or not) * there was a race condition when triggering the threaded recovering process where, in rare cases, 2 reconnection attempts would run in parallel, doubling the number of opened sockets ## Asynchronous tasks * Race conditions could occur and corrupt the requests cache, or freeze the SDK because of an unhandled exception, because of an incorrect use of `lock` (this keyword has no impact when multiple accesses are made to the same "locked" object within the same thread) => semaphores are now used to circumvent the problem * Requests tasks were incorrectly configured, making their resolution synchronous. This means that resolving tasks in the SDK event handlers (which manage network state changes) could prevent them to finish in a timely fashion (or... ever) because they would synchronously trigger awaiting code # Boyscout * Save our standard code style directly in the solution to share it to whomever works on the project
Description
Fix a number of problems when handling disconnections, and with asynchronous tasks in general.
Network disconnection
When
AbstractProtocol.AutoRecoveris set to true:ConnectionLostexception (we cannot queue them: as far as the SDK is concerned, it cannot know if these requests were received and processed by Kuzzle or not)Asynchronous tasks
lock(this keyword has no impact when multiple accesses are made to the same "locked" object within the same thread) => semaphores are now used to circumvent the problemBoyscout