-
Notifications
You must be signed in to change notification settings - Fork 11
feat: efm v2 support #930
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
base: main
Are you sure you want to change the base?
feat: efm v2 support #930
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -176,6 +176,30 @@ HostMonitoringPlugin.ConfigurationNotSupported=[HostMonitoringPlugin] Aborting c | |||||
HostMonitoringPlugin.UnableToIdentifyConnection=[HostMonitoringPlugin] Unable to identify the connected database instance: '{}', please ensure the correct host list provider is specified. The host list provider in use is: '{}'. | ||||||
HostMonitoringPlugin.UnavailableHost=[HostMonitoringPlugin] Host '{}' is unavailable. | ||||||
|
||||||
HostMonitoringV2Plugin.ActivatedMonitoring=[HostMonitoringV2Plugin] Executing method '{}', monitoring is activated. | ||||||
HostMonitoringV2Plugin.ClusterEndpointHostInfo=[HostMonitoringV2Plugin] The HostInfo to monitor is associated with a cluster endpoint. The plugin will attempt to identify the connected database instance. | ||||||
HostMonitoringV2Plugin.ErrorIdentifyingConnection=[HostMonitoringV2Plugin] An error occurred while identifying the connection database instance: '{}'. | ||||||
HostMonitoringV2Plugin.MonitoringDeactivated=[HostMonitoringV2Plugin] Monitoring deactivated for method '{}'. | ||||||
HostMonitoringV2Plugin.ConnectionNone=[HostMonitoringV2Plugin] Attempted to execute method '{}' but the current connection is None. | ||||||
HostMonitoringV2Plugin.HostInfoNone=[HostMonitoringV2Plugin] Could not find HostInfo to monitor for the current connection. | ||||||
HostMonitoringV2Plugin.ConfigurationNotSupported=[HostMonitoringV2Plugin] Aborting connections from a separate thread is not supported for the detected driver dialect: '{}'. The EFM V2 plugin requires this feature to be supported. | ||||||
HostMonitoringV2Plugin.UnableToIdentifyConnection=[HostMonitoringV2Plugin] Unable to identify the connected database instance: '{}', please ensure the correct host list provider is specified. The host list provider in use is: '{}'. | ||||||
|
||||||
HostMonitorV2.ExceptionDuringMonitoringStop=[HostMonitorV2] Stopping monitoring after unhandled exception was thrown in monitoring thread for node '{}'. | ||||||
HostMonitorV2.MonitorIsStopped=[HostMonitorV2] Monitoring was already stopped for node '{}'. | ||||||
HostMonitorV2.StartMonitoringThreadNewContext=[HostMonitorV2] Start monitoring thread for checking new contexts for '{}'. | ||||||
HostMonitorV2.StopMonitoringThreadNewContext=[HostMonitorV2] Stop monitoring thread for checking new contexts for '{}'. | ||||||
HostMonitorV2.StartMonitoringThread=[HostMonitorV2] Start monitoring thread for '{}'. | ||||||
HostMonitorV2.OpeningMonitoringConnection=[HostMonitorV2] Opening a monitoring connection to '{}' | ||||||
HostMonitorV2.OpenedMonitoringConnection=[HostMonitorV2] Opened monitoring connection: '{}' | ||||||
HostMonitorV2.ExceptionAbortingConnection=[HostMonitorV2] Exception during aborting connection: '{}' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
HostMonitorV2.HostDead=[HostMonitorV2] Host '{}' is *dead*. | ||||||
HostMonitorV2.HostNotResponding=[HostMonitorV2] Host '{}' is not *responding* '{}'. | ||||||
HostMonitorV2.HostAlive=[HostMonitorV2] Host '{}' is *alive*. | ||||||
|
||||||
MonitorServiceV2.ExceptionAbortingConnection=[MonitorServiceV2] Exception during aborting connection: '{}' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
MonitorServiceV2.HostNotResponding=[MonitorServiceV2] Host '{}' is not *responding* '{}'. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a duplicate of 197 |
||||||
|
||||||
HostSelector.NoEligibleHost=[HostSelector] No Eligible Hosts Found. | ||||||
HostSelector.NoHostsMatchingRole=[HostSelector] No hosts were found matching the requested role: '{}'. | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
# limitations under the License. | ||
|
||
from threading import Lock | ||
from typing import Any | ||
|
||
|
||
class AtomicInt: | ||
|
@@ -59,3 +60,31 @@ def compare_and_set(self, expected_value: int, new_value: int) -> bool: | |
self._value = new_value | ||
return True | ||
return False | ||
|
||
|
||
class AtomicBoolean: | ||
def __init__(self, initial_value: bool): | ||
self._value: bool = initial_value | ||
self._lock: Lock = Lock() | ||
|
||
def get(self) -> bool: | ||
with self._lock: | ||
return self._value | ||
|
||
def set(self, value: bool) -> None: | ||
with self._lock: | ||
self._value = value | ||
|
||
|
||
class AtomicReference: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does it make sense to use generics here instead of Any? might be an overkill |
||
def __init__(self, initial_value): | ||
self._value = initial_value | ||
self._lock: Lock = Lock() | ||
|
||
def get(self) -> Any: | ||
with self._lock: | ||
return self._value | ||
|
||
def set(self, new_value: Any) -> None: | ||
with self._lock: | ||
self._value = new_value |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -79,3 +79,19 @@ conn = AwsWrapperConnection.connect( | |||||
> We recommend you either disable the Host Monitoring Connection Plugin or avoid using RDS Proxy endpoints when the Host Monitoring Connection Plugin is active. | ||||||
> | ||||||
> Although using RDS Proxy endpoints with the AWS Advanced Python Driver with Enhanced Failure Monitoring doesn't cause any critical issues, we don't recommend this approach. The main reason is that RDS Proxy transparently re-routes requests to a single database instance. RDS Proxy decides which database instance is used based on many criteria (on a per-request basis). Switching between different instances makes the Host Monitoring Connection Plugin useless in terms of instance health monitoring because the plugin will be unable to identify which instance it's connected to, and which one it's monitoring. This could result in false positive failure detections. At the same time, the plugin will still proactively monitor network connectivity to RDS Proxy endpoints and report outages back to a user application if they occur. | ||||||
|
||||||
# Host Monitoring Plugin v2 | ||||||
|
||||||
Host Monitoring Plugin v2, also known as `host_monitoring_v2`, is an alternative implementation of enhanced failure monitoring and it is functionally equal to the Host Monitoring Plugin described above. Both plugins share the same set of [configuration parameters](#enhanced-failure-monitoring-parameters). The `host_monitoring_v2` plugin is designed to be a drop-in replacement for the `host_monitoring` plugin. | ||||||
JuanLeee marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
The `host_monitoring_v2` plugin can be used in any scenario where the `host_monitoring` plugin is mentioned. This plugin is enabled by default. The original EFM plugin can still be used by specifying `host_monitoring` in the `plugins` parameter. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The value There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to update the DEFAULT_PLUGINS value in utils\properties.py so that it uses the new plugin by default instead of v1 |
||||||
|
||||||
> [!NOTE]\ | ||||||
> Since these two plugins are separate plugins, users may decide to use them together with a single connection. While this should not have any negative side effects, it is not recommended. It is recommended to use either the `host_monitoring` plugin, or the `host_monitoring_v2` plugin where it's needed. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit:
Suggested change
|
||||||
|
||||||
|
||||||
The `host_monitoring_v2` plugin is designed to address [some of the issues](https://github.com/aws/aws-advanced-jdbc-wrapper/issues/675) that have been reported by multiple users. The following changes have been made: | ||||||
- Used weak pointers to ease garbage collection | ||||||
- Split monitoring logic into two separate threads to increase overall monitoring stability | ||||||
- Reviewed locks for monitoring context | ||||||
- Reviewed and redesigned stopping of idle monitoring threads | ||||||
- Reviewed and simplified monitoring logic |
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 there are a couple unnecessary new lines in this file