Improvements + Added test#2
Closed
cheenamalhotra wants to merge 3 commits intosehrope:shared-timer-for-timeoutsfrom
Closed
Improvements + Added test#2cheenamalhotra wants to merge 3 commits intosehrope:shared-timer-for-timeoutsfrom
cheenamalhotra wants to merge 3 commits intosehrope:shared-timer-for-timeoutsfrom
Conversation
Replaces the timeout handling for basic and bulk TDS commands to use a new SharedTimer class. SharedTimer provides a static method for fetching an existing static object or creating one on demand. Usage is tracked through reference counting and callers are required to call removeRef() when they will no longer be using the SharedTimer. If the SharedTimer does not have any more references then its internal ScheduledThreadPoolExecutor will be shutdown. The SharedTimer is cached at the Connection level so that repeated invocations do not create new timers. Connections only create timers on first use so if no actions involve a timeout then no timer is fetched or created. If a Connection does create a timer then it will be released when the Connection closed. Properly written JDBC applications that always close their Connection objects when they are finished using them should not have any extra threads running after they are all closed. Applications that do not use query timeouts will not have any extra threads created as they are only done on demand. Applications that use timeouts and use a JDBC connection pool will have a single shared object across all JDBC connections as long as there are some open connections in the pool with timeouts enabled. Interrupt actions to handle a timeout are executed in their own thread. A handler thread is created when the timeout occurs with the thread name matching the connection id of the client connection that created the timeout. If the timeout is canceled prior to the interrupt action being executed, say because the command finished, then no handler thread is created. Note that the sharing of the timers happens across all Connections, not just Connections with the same JDBC URL and properties.
Codecov Report
@@ Coverage Diff @@
## shared-timer-for-timeouts #2 +/- ##
===============================================================
- Coverage 50.37% 50.26% -0.12%
+ Complexity 2931 2921 -10
===============================================================
Files 122 120 -2
Lines 28108 28098 -10
Branches 4692 4694 +2
===============================================================
- Hits 14160 14124 -36
- Misses 11643 11679 +36
+ Partials 2305 2295 -10
Continue to review full report at Codecov.
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## shared-timer-for-timeouts #2 +/- ##
===============================================================
- Coverage 50.37% 50.26% -0.12%
+ Complexity 2931 2921 -10
===============================================================
Files 122 120 -2
Lines 28108 28098 -10
Branches 4692 4694 +2
===============================================================
- Hits 14160 14124 -36
- Misses 11643 11679 +36
+ Partials 2305 2295 -10
Continue to review full report at Codecov.
|
fd2f3d3 to
e76e819
Compare
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.
Few improvements on the implementation:
(Removed variations of Timeout Task as in both Query Timeout and Bulk Copy Timeout cases the driver must abort connection if timeout has occurred)