-
Notifications
You must be signed in to change notification settings - Fork 49
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
Optimize thread locks and expiring cache for Enhanced Monitoring plugin #356
Conversation
2f85114
to
758aa81
Compare
expiring cache
758aa81
to
67627c5
Compare
src/main/user-impl/java/com/mysql/cj/jdbc/ha/plugins/Monitor.java
Outdated
Show resolved
Hide resolved
src/main/user-impl/java/com/mysql/cj/jdbc/ha/plugins/Monitor.java
Outdated
Show resolved
Hide resolved
src/main/user-impl/java/com/mysql/cj/jdbc/ha/plugins/Monitor.java
Outdated
Show resolved
Hide resolved
src/main/user-impl/java/com/mysql/cj/jdbc/ha/plugins/NodeMonitoringConnectionPlugin.java
Outdated
Show resolved
Hide resolved
src/main/user-impl/java/com/mysql/cj/jdbc/ha/plugins/failover/AuroraTopologyService.java
Outdated
Show resolved
Hide resolved
verify cluster status before each test increase session token expiration time
d5500ba
to
f387f13
Compare
// Check for min delay between node health check | ||
if (delayMillis < MIN_CONNECTION_CHECK_TIMEOUT_MILLIS) { | ||
delayMillis = MIN_CONNECTION_CHECK_TIMEOUT_MILLIS; | ||
} |
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.
should the elapsedTime subtraction come after this reset to the MIN_CONNECTION timeout? For example, if we spent 1s on the status check and the MIN_CONNECTION timeout is 3s, we only have to wait 2s
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.
I was thinking about this scenario but I guess it makes sense to avoid checking node status too often. So MIN_CONNECTION is applied to delayMillis.
src/main/user-impl/java/com/mysql/cj/jdbc/ha/plugins/Monitor.java
Outdated
Show resolved
Hide resolved
CacheItem<V> cacheItem = cache.computeIfPresent(key, (kk, vv) -> vv.isExpired() ? null : vv); | ||
return cacheItem == null ? null : cacheItem.item; | ||
} | ||
|
||
public V get(final K key, final V defaultItemValue, long itemExpirationNano) { | ||
CacheItem<V> cacheItem = cache.compute(key, | ||
(kk, vv) -> (vv == null || vv.isExpired()) | ||
? new CacheItem<>(defaultItemValue, System.nanoTime() + itemExpirationNano) | ||
: vv); | ||
return cacheItem.item; | ||
} |
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.
I think these methods can be simplified if you add a getter for cacheItem.item:
public V getItem() {
return isExpired() ? null : item;
}
Co-authored-by: Karen <[email protected]>
Co-authored-by: Karen <[email protected]>
This PR address #333 |
Porting over optimizations from the aws-mysql-jdbc driver: awslabs/aws-mysql-jdbc#356 ### By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Co-authored-by: Aaron Congo <[email protected]> Co-authored-by: sergiyv-bitquill <[email protected]>
this fix have bug will case #412 |
Summary
Optimize thread locks and expiring cache for Enhanced Monitoring plugin.
Description
Additional Reviewers
@karenc-bq
@congoamz