From 7555a1915da4107e76e4fa2eba718246f0780bd5 Mon Sep 17 00:00:00 2001 From: aaron-congo Date: Mon, 30 Nov 2026 15:40:01 -0700 Subject: [PATCH] docs(ruby): document the missing cluster_instance_host_pattern warning and immediate failover failure When the connection host isn't a recognized RDS endpoint and cluster_instance_host_pattern isn't set, the wrapper logs a warning at connect on Aurora and RDS Multi-AZ DB clusters, and failover raises FailoverFailedError immediately. Document that behavior, the '?' opt-out for environments where bare instance identifiers resolve, and which host pattern applies for gdb_failover on Global Databases vs regional dialects. --- content/compatibility.yaml | 2 +- content/failover.yaml | 25 ++++++++++++++++---- content/plugins.yaml | 2 +- content/templates/enhanced-failover.md.j2 | 4 ++++ site/docs-ruby/compatibility/endpoints.md | 2 +- site/docs-ruby/enhanced-failover.md | 21 ++++++++++++++-- site/docs-ruby/using-plugins/gdb-failover.md | 2 +- 7 files changed, 48 insertions(+), 10 deletions(-) diff --git a/content/compatibility.yaml b/content/compatibility.yaml index f43033a..0324e59 100644 --- a/content/compatibility.yaml +++ b/content/compatibility.yaml @@ -88,7 +88,7 @@ notes: iamNeedsInitialConn: "Requires the {plugin:initialConnection} plugin. A global endpoint carries no region and points at the current primary cluster, so it must be resolved to the writer instance before the IAM token is generated." # ✅-cell notes for IP-address / custom-domain (CNAME) endpoints, which the wrapper # cannot recognize as RDS endpoints. Each states the exact parameter(s) to set. - failoverNeedsHostPattern: "Supported, but the wrapper cannot recognize an IP address or custom domain as an RDS endpoint, so set `cluster_instance_host_pattern` (using `?` as the instance-identifier placeholder) so topology can build per-instance endpoints; set the cluster identifier as well when using a custom domain." + failoverNeedsHostPattern: "Supported, but the wrapper cannot recognize an IP address or custom domain as an RDS endpoint, so set `cluster_instance_host_pattern` (using `?` as the instance-identifier placeholder) so topology can build per-instance endpoints; set the cluster identifier as well when using a custom domain. Without the pattern, the wrapper logs a warning when the connection opens, and failover raises `FailoverFailedError` immediately." gdbNeedsHostPattern: "Supported, but the wrapper cannot recognize an IP address or custom domain as an RDS endpoint, so set `global_cluster_instance_host_patterns` (one region-prefixed pattern per region) and `failover_home_region` so the plugin can build per-region topology." iamNeedsHostOverride: "Supported, but the wrapper cannot derive the token host or region from an IP address or custom domain, so set `iam_host` to a valid RDS endpoint (and `iam_region` if it cannot be parsed) so the IAM token is generated for the right host." secretsNeedsRegion: "Supported, but the region cannot be parsed from an IP address or custom domain, so set `secret_region` (unless the secret id is an ARN, which already contains the region)." diff --git a/content/failover.yaml b/content/failover.yaml index ab59dbc..5cae53b 100644 --- a/content/failover.yaml +++ b/content/failover.yaml @@ -311,7 +311,7 @@ parameters: spellings: ruby: name: cluster_instance_host_pattern - required: "If connecting using an IP address or custom domain URL: Yes

Otherwise: No" + required: "If connecting to an Aurora or RDS Multi-AZ DB cluster using an IP address or custom domain URL: Yes

Otherwise: No" defaultNote: "auto-derived" errors: @@ -321,7 +321,7 @@ errors: reusable: "No" action: "Failover could not find a new instance. Wait until the server is available, then reconnect." detail: - ruby: "The original connection failed, and the wrapper could not reconnect to a new instance before the failover attempt ended. Wait until the server is available, then reconnect." + ruby: "The original connection failed, and the wrapper could not reconnect to a new instance before the failover attempt ended. Wait until the server is available, then reconnect. If the message starts with `Failover is not possible` and names `cluster_instance_host_pattern`, the connection host is not a recognized RDS endpoint and the pattern is not set, so the wrapper cannot build DB instance hosts. Set `cluster_instance_host_pattern` instead of retrying." - concept: failoverSuccess ruby: "FailoverSuccessError" connectionValid: "Yes" @@ -386,6 +386,23 @@ enhanced: availableSince: "1.0.0 (default plugin)" compatibilityGuide: "./compatibility" hostPatternParam: cluster_instance_host_pattern + hostPatternMissingNote: | + The wrapper checks for a missing pattern when a connection opens, once it has identified the + database as an Aurora or RDS Multi-AZ DB cluster. A single RDS instance or a community database behind an + IP address does not need the pattern, so it is not affected. If the connection host is not a + recognized RDS endpoint and `cluster_instance_host_pattern` is not set, the wrapper logs a warning + once per host and the connection opens. The warning names the host and the two fixes: set + `cluster_instance_host_pattern` (for example, `?.XXX.us-east-1.rds.amazonaws.com`), or remove + `failover` from `wrapper_plugins` (when `wrapper_plugins` is not set, `failover` comes from the + default plugin list). + + If a failover starts in this configuration, it raises `FailoverFailedError` immediately, with the + same explanation as the warning, instead of retrying instance hosts that can't be resolved until + `failover_timeout_sec` passes. + + If bare instance identifiers resolve in your environment, for example through a DNS search domain, + set `cluster_instance_host_pattern: "?"`. An explicitly set pattern turns off both the warning and + the immediate failure, so failover connects to the bare instance identifiers as before. monitoringPrefix: "topology_monitoring_" connectSnippet: | require 'aws_advanced_ruby_driver_wrapper/postgresql' @@ -426,10 +443,10 @@ enhanced: spellings: ruby: name: cluster_instance_host_pattern - required: "Required for IP addresses and custom domains; otherwise No" + required: "Required for IP addresses and custom domains in front of an Aurora or RDS Multi-AZ DB cluster; otherwise No" defaultNote: "auto-derived for recognizable RDS endpoints" description: - ruby: "Pattern used to build instance endpoints when the connection host is not a recognizable RDS endpoint. Use `?` as the instance identifier placeholder." + ruby: "Pattern used to build instance endpoints when the connection host is not a recognizable RDS endpoint. Use `?` as the instance identifier placeholder. If the connection host is not a recognized RDS endpoint and this is not set on an Aurora or RDS Multi-AZ DB cluster, the wrapper logs a warning when the connection opens, and failover raises `FailoverFailedError` immediately. Set it to `?` if bare instance identifiers resolve in your environment. See [Host pattern](#host-pattern)." - concept: clusterTopologyRefreshRate type: integer unitTrap: true diff --git a/content/plugins.yaml b/content/plugins.yaml index d14d1ab..f4abb4a 100644 --- a/content/plugins.yaml +++ b/content/plugins.yaml @@ -1898,7 +1898,7 @@ plugins: ruby: { name: out_of_home_failover_mode, required: "No", defaultNote: "depends on URL", example: "strict_any_reader" } - concept: globalHostPatterns type: string - description: "Comma-separated instance host patterns for every Global Database region. Prefix custom-domain patterns with `[region]`. Required for Aurora Global Databases; ignored otherwise." + description: "Comma-separated instance host patterns for every Global Database region. Prefix custom-domain patterns with `[region]`. Required for Aurora Global Databases, and the only host pattern they need: `cluster_instance_host_pattern` is not required. It is only read when the database is identified as a Global Database (a `global-aurora-pg` / `global-aurora-mysql` dialect). Without `wrapper_dialect`, a Global Database is only identified when it spans more than one region. If the database is identified as a regional cluster instead (for example because `wrapper_dialect` is set to `aurora-pg`), this setting is ignored and `cluster_instance_host_pattern` applies, as with the `failover` plugin. In that case, if the connection host is an IP address or custom domain and `cluster_instance_host_pattern` is not set, the wrapper logs a warning explaining that this setting does not apply, and failover raises `FailoverFailedError` immediately. For a Global Database, set `wrapper_dialect` to a `global-aurora-*` dialect and keep this setting; for a standalone cluster, use the `failover` plugin with `cluster_instance_host_pattern`." spellings: ruby: { name: global_cluster_instance_host_patterns, required: "Yes for Global Databases; otherwise No", defaultNote: "none", example: "?.xyz1.us-east-1.rds.amazonaws.com,?.xyz2.us-west-1.rds.amazonaws.com" } - concept: accessibleRegions diff --git a/content/templates/enhanced-failover.md.j2 b/content/templates/enhanced-failover.md.j2 index 8302737..03cee40 100644 --- a/content/templates/enhanced-failover.md.j2 +++ b/content/templates/enhanced-failover.md.j2 @@ -153,6 +153,10 @@ In addition to parameters for the underlying database driver, configure the foll ### Host pattern When connecting through an IP address, CNAME, custom domain, or another endpoint that does not contain a recognizable RDS instance pattern, set `{{ enhanced.wrappers[wrapper_id].hostPatternParam }}`. Use `?` as the placeholder for the DB instance identifier. For example, if instance endpoints follow `instanceIdentifier.customHost`, use `?.customHost` as the pattern. The wrapper uses this pattern to build per-instance endpoints while it discovers topology. +{% if enhanced.wrappers[wrapper_id].hostPatternMissingNote %} + +{{ enhanced.wrappers[wrapper_id].hostPatternMissingNote }} +{%- endif %} :::warning When using a CNAME or custom domain, set both the instance host pattern and the cluster identifier. Without the pattern, topology discovery cannot construct resolvable per-instance hostnames. diff --git a/site/docs-ruby/compatibility/endpoints.md b/site/docs-ruby/compatibility/endpoints.md index b66bf52..eaf6499 100644 --- a/site/docs-ruby/compatibility/endpoints.md +++ b/site/docs-ruby/compatibility/endpoints.md @@ -42,7 +42,7 @@ Legend: ✅ compatible · ❌ not compatible · a numbered footnote `[^n]` links [^3]: Aurora Limitless shard groups manage their own routing; the failover plugin does not operate on the Limitless shard-group endpoint. -[^4]: Supported, but the wrapper cannot recognize an IP address or custom domain as an RDS endpoint, so set `cluster_instance_host_pattern` (using `?` as the instance-identifier placeholder) so topology can build per-instance endpoints; set the cluster identifier as well when using a custom domain. +[^4]: Supported, but the wrapper cannot recognize an IP address or custom domain as an RDS endpoint, so set `cluster_instance_host_pattern` (using `?` as the instance-identifier placeholder) so topology can build per-instance endpoints; set the cluster identifier as well when using a custom domain. Without the pattern, the wrapper logs a warning when the connection opens, and failover raises `FailoverFailedError` immediately. [^5]: Aurora Limitless shard groups manage their own routing; the global database failover plugin does not operate on the Limitless shard-group endpoint. diff --git a/site/docs-ruby/enhanced-failover.md b/site/docs-ruby/enhanced-failover.md index d52c778..b47619d 100644 --- a/site/docs-ruby/enhanced-failover.md +++ b/site/docs-ruby/enhanced-failover.md @@ -154,7 +154,7 @@ In addition to parameters for the underlying database driver, configure the foll | Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | `failover_mode` | String | No | depends on URL | Defines the target role during failover: `strict_writer`, `reader_or_writer`, or `strict_reader`. A read-only cluster endpoint defaults to `reader_or_writer`; other URLs default to `strict_writer`. | -| `cluster_instance_host_pattern` | String | Required for IP addresses and custom domains; otherwise No | auto-derived for recognizable RDS endpoints | Pattern used to build instance endpoints when the connection host is not a recognizable RDS endpoint. Use `?` as the instance identifier placeholder. | +| `cluster_instance_host_pattern` | String | Required for IP addresses and custom domains in front of an Aurora or RDS Multi-AZ DB cluster; otherwise No | auto-derived for recognizable RDS endpoints | Pattern used to build instance endpoints when the connection host is not a recognizable RDS endpoint. Use `?` as the instance identifier placeholder. If the connection host is not a recognized RDS endpoint and this is not set on an Aurora or RDS Multi-AZ DB cluster, the wrapper logs a warning when the connection opens, and failover raises `FailoverFailedError` immediately. Set it to `?` if bare instance identifiers resolve in your environment. See [Host pattern](#host-pattern). | | `cluster_topology_refresh_rate_sec` | Float | No | `5.0` | Regular interval at which the topology monitor refreshes the cluster when it is stable. *(sec)* | | `failover_timeout_sec` | Float | No | `300.0` | Maximum time allowed to reconnect to a new writer or reader after failover starts. *(sec)* | | `cluster_topology_high_refresh_rate_sec` | Float | No | `0.1` | Interval between topology updates during the high-rate period after a new writer is detected. *(sec)* | @@ -167,6 +167,23 @@ In addition to parameters for the underlying database driver, configure the foll When connecting through an IP address, CNAME, custom domain, or another endpoint that does not contain a recognizable RDS instance pattern, set `cluster_instance_host_pattern`. Use `?` as the placeholder for the DB instance identifier. For example, if instance endpoints follow `instanceIdentifier.customHost`, use `?.customHost` as the pattern. The wrapper uses this pattern to build per-instance endpoints while it discovers topology. +The wrapper checks for a missing pattern when a connection opens, once it has identified the +database as an Aurora or RDS Multi-AZ DB cluster. A single RDS instance or a community database behind an +IP address does not need the pattern, so it is not affected. If the connection host is not a +recognized RDS endpoint and `cluster_instance_host_pattern` is not set, the wrapper logs a warning +once per host and the connection opens. The warning names the host and the two fixes: set +`cluster_instance_host_pattern` (for example, `?.XXX.us-east-1.rds.amazonaws.com`), or remove +`failover` from `wrapper_plugins` (when `wrapper_plugins` is not set, `failover` comes from the +default plugin list). + +If a failover starts in this configuration, it raises `FailoverFailedError` immediately, with the +same explanation as the warning, instead of retrying instance hosts that can't be resolved until +`failover_timeout_sec` passes. + +If bare instance identifiers resolve in your environment, for example through a DNS search domain, +set `cluster_instance_host_pattern: "?"`. An explicitly set pattern turns off both the warning and +the immediate failure, so failover connects to the bare instance identifiers as before. + :::warning When using a CNAME or custom domain, set both the instance host pattern and the cluster identifier. Without the pattern, topology discovery cannot construct resolvable per-instance hostnames. ::: @@ -206,7 +223,7 @@ a specific **error class**. ### FailoverFailedError -The original connection failed, and the wrapper could not reconnect to a new instance before the failover attempt ended. Wait until the server is available, then reconnect. +The original connection failed, and the wrapper could not reconnect to a new instance before the failover attempt ended. Wait until the server is available, then reconnect. If the message starts with `Failover is not possible` and names `cluster_instance_host_pattern`, the connection host is not a recognized RDS endpoint and the pattern is not set, so the wrapper cannot build DB instance hosts. Set `cluster_instance_host_pattern` instead of retrying. ### FailoverSuccessError diff --git a/site/docs-ruby/using-plugins/gdb-failover.md b/site/docs-ruby/using-plugins/gdb-failover.md index c7d2277..e806d37 100644 --- a/site/docs-ruby/using-plugins/gdb-failover.md +++ b/site/docs-ruby/using-plugins/gdb-failover.md @@ -100,7 +100,7 @@ Verify plugin compatibility within your Ruby configuration using the [compatibil | `failover_home_region` | String | Yes for endpoints with no region; otherwise No | parsed from URL | The AWS region the application runs in. Determines which of the in-home and out-of-home modes applies. Defaults to the region parsed from the connection endpoint, and is required when the endpoint carries no region (a Global Database endpoint, an IP address, or a custom domain).

Example: `us-west-1` | | `in_home_failover_mode` | String | No | depends on URL | Failover mode used while the Global Database primary region **is** the home region. Values include `strict_writer`, `home_reader_or_writer`, `strict_home_reader`, `strict_out_of_home_reader`, `strict_any_reader`, `out_of_home_reader_or_writer`, and `any_reader_or_writer`. When unset, the mode is derived from the initial connection endpoint: a writer or global writer cluster endpoint defaults to `strict_writer`, and any other endpoint defaults to `home_reader_or_writer`. This plugin does not read `failover_mode`; use this parameter and `out_of_home_failover_mode` instead.

Example: `strict_writer` | | `out_of_home_failover_mode` | String | No | depends on URL | Failover mode used while the Global Database primary region **is not** the home region. Accepts the same values as the in-home mode. When unset, it is derived from the initial endpoint the same way as the in-home mode: a writer or global writer cluster endpoint defaults to `strict_writer`, and any other endpoint defaults to `home_reader_or_writer`.

Example: `strict_any_reader` | -| `global_cluster_instance_host_patterns` | String | Yes for Global Databases; otherwise No | none | Comma-separated instance host patterns for every Global Database region. Prefix custom-domain patterns with `[region]`. Required for Aurora Global Databases; ignored otherwise.

Example: `?.xyz1.us-east-1.rds.amazonaws.com,?.xyz2.us-west-1.rds.amazonaws.com` | +| `global_cluster_instance_host_patterns` | String | Yes for Global Databases; otherwise No | none | Comma-separated instance host patterns for every Global Database region. Prefix custom-domain patterns with `[region]`. Required for Aurora Global Databases, and the only host pattern they need: `cluster_instance_host_pattern` is not required. It is only read when the database is identified as a Global Database (a `global-aurora-pg` / `global-aurora-mysql` dialect). Without `wrapper_dialect`, a Global Database is only identified when it spans more than one region. If the database is identified as a regional cluster instead (for example because `wrapper_dialect` is set to `aurora-pg`), this setting is ignored and `cluster_instance_host_pattern` applies, as with the `failover` plugin. In that case, if the connection host is an IP address or custom domain and `cluster_instance_host_pattern` is not set, the wrapper logs a warning explaining that this setting does not apply, and failover raises `FailoverFailedError` immediately. For a Global Database, set `wrapper_dialect` to a `global-aurora-*` dialect and keep this setting; for a standalone cluster, use the `failover` plugin with `cluster_instance_host_pattern`.

Example: `?.xyz1.us-east-1.rds.amazonaws.com,?.xyz2.us-west-1.rds.amazonaws.com` | | `accessible_regions` | String | No | all regions | Comma-separated list of AWS regions the application can reach. When set, failover only considers nodes in these regions as candidates; topology monitoring still tracks every region. If the home region is also set, it must be included.

Example: `us-east-1,us-west-1` | | `failover_timeout_sec` | Float | No | `300.0` | Maximum allowed time to attempt reconnecting to a new writer or reader instance after a cluster failover is initiated. *(sec)*

Example: `300.0` | | `cluster_topology_refresh_rate_sec` | Float | No | `5.0` | Cluster topology refresh rate while the cluster is not in failover (the regular slow monitoring rate). *(sec)*

Example: `5.0` |