HTTP Bridge: Replace thread pool - #3956
Open
simon-lgb wants to merge 2 commits into
Open
Conversation
This fixes an issue with the thread pool not allowing concurrency regardless of the maximum pool size
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #3956 +/- ##
=============================================
+ Coverage 55.32% 55.34% +0.03%
- Complexity 19440 19446 +6
=============================================
Files 3840 3840
Lines 177236 177265 +29
Branches 14801 14802 +1
=============================================
+ Hits 98035 98088 +53
+ Misses 75321 75297 -24
Partials 3880 3880 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change fixes an issue that prevented http bridge requests from running concurrently, as discussed in https://community.openems.io/t/broken-thread-pools-in-openems/10947.
With this appraoch, I tried to mirror the original intended behavior as closely as possible. However, moving the initialization of the maximum pool size from a method to the constructor would enable the custom subclass of Semaphore to be dropped entirely and the code could be simplified quite a bit. Also, the debug logging could be reduced if desired to remove the need for separate counters.
Originally, I tested this using the MetadataOdoo provider. I also expanded the debug logging there and fixed a deadlock with one of the ConcurrentHashMaps that I discovered once several requests were running concurrently. However, the use of the HTTP bridge in that class was removed in aa79e27, so those changes are not included in this PR. If desired, I can also revert that commit and include those additional changes.
The flawed thread pool pattern exists in other places in the code as well, however this initial PR only touches the HTTP bridge.
I'm looking forward to your feedback :)