Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

[aio] host_monitoring_v2 without a topology plugin fails the first statement on cluster-endpoint connections

Ouverte
#1,288 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@AhmadMasry y travaille déjà.

Depuis le 6/10/2026.

  • #1290 par @AhmadMasry — ouverte

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
49/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
postgresql, python, sqlalchemy
Domaine
backend, databases

Piste de recherche

Start with aio/wrapper.py and _build_host_list_provider, then compare the Aurora dialect provider selection in database_dialect.py with the async behavior. Trace how AsyncHostMonitoringPlugin._get_monitoring_host_info identifies and caches a host, using the described mocked reproduction as a starting point. Done when the first statement succeeds through a cluster endpoint and monitoring targets the connected instance, with regression coverage for the failure and cache behavior.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Describe the bug

With the async API, host_monitoring_v2 used without a topology plugin (no failover, failover_v2, aurora_connection_tracker, ...) fails the first statement on every new connection made through an Aurora cluster endpoint, with AwsWrapperError: [HostMonitoringV2Plugin] Unable to identify the connected database instance. Later statements on that connection succeed, but the monitor watches the cluster endpoint's DNS name instead of the instance the connection is on.

Cause:

  • aio/wrapper.py _build_host_list_provider returns AsyncStaticHostListProvider when plugins contains none of _TOPOLOGY_REQUIRING_PLUGINS, whatever the database dialect. host_monitoring_v2 isn't in that set.
  • For a cluster endpoint, AsyncHostMonitoringPlugin._get_monitoring_host_info calls plugin_service.identify_connection. With the static provider the topology has no host_id, so it returns None and the plugin raises before running the statement.
  • _get_monitoring_host_info assigns self._monitoring_host_info = current_host_info before identifying, so on the next statement it returns the cached cluster endpoint and monitors that.

The sync wrapper doesn't hit this: Aurora dialects always use RdsHostListProvider (database_dialect.py, AuroraPgDialect.get_host_list_provider_supplier), regardless of plugins, so identify_connection resolves the instance.

Expected Behavior

As in sync, host_monitoring_v2 alone on a cluster endpoint identifies the instance the connection landed on and monitors it, and the first statement runs normally.

What plugins are used? What other connection properties were set?

wrapper_dialect=aurora-pg&wrapper_plugins=host_monitoring_v2, connecting through the cluster (writer) endpoint. With failover added, or through an instance endpoint, it works.

Current Behavior

Checked without a database by building the provider the way connect does and calling _get_monitoring_host_info with get_instance_id patched to return an instance id:

AsyncStaticHostListProvider  mydb.cluster-xyz...  -> 1st call: AwsWrapperError: Unable to identify the connected database instance
                                                     2nd call: monitors mydb.cluster-xyz.us-east-1.rds.amazonaws.com
AsyncStaticHostListProvider  inst-1.xyz...        -> monitors inst-1.xyz.us-east-1.rds.amazonaws.com
Reproduction Steps
import asyncio
from sqlalchemy import text
from sqlalchemy.ext.asyncio import create_async_engine
from aws_advanced_python_wrapper.aio import release_resources_async


async def main():
    engine = create_async_engine(
        "postgresql+aws_wrapper_psycopg://USER:PASSWORD@<name>.cluster-<id>.<region>.rds.amazonaws.com:5432/DB"
        "?wrapper_dialect=aurora-pg&wrapper_plugins=host_monitoring_v2")
    try:
        async with engine.connect() as conn:
            await conn.execute(text("SELECT 1"))  # raises AwsWrapperError
    finally:
        await engine.dispose()
        await release_resources_async()

asyncio.run(main())
Possible Solution

Match sync: pick the topology-aware provider from the Aurora/Multi-AZ/Global dialect even when no topology plugin is configured, or add host_monitoring_v2 (and host_monitoring) to _TOPOLOGY_REQUIRING_PLUGINS. Either way, resolve the instance (the topology monitor is shared per cluster after #1285, so this costs one monitoring connection per cluster). Separately, _get_monitoring_host_info shouldn't cache the cluster endpoint when identification fails.

Additional Information/Context

Found while answering a user question about using host_monitoring_v2 without failover. Related: #1284.

The AWS Advanced Python Wrapper version used

main at 8feea85 (3.1.0)

python version used

Python 3.14

Operating System and version

macOS (checked locally, not against a live cluster)

Langage dominant
Python
Étoiles
99
Forks
22
Merge moyen
1 j 7 h
PR mergées (30 j)
4

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de aws/aws-advanced-python-wrapper

Toutes les issues de aws/aws-advanced-python-wrapper

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.