Blue/Green plugin has no effect on cluster endpoint connections

Abierto
#718 0 comentarios 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
aws, mysql, node.js, typescript
Área
backend, database

Línea de trabajo

Start with collectTopology() in blue_green_status_monitor.ts and isMatch in routing/base_connect_routing.ts and routing/base_execute_routing.ts; compare how the Python and JDBC wrappers retain cluster endpoints. Then check the bg imports in blue_green_plugin.ts against UsingTheBlueGreenPlugin.md for the dependency note. Done means cluster endpoint connections are suspended and routed to the green IP during switchover, with the required dependencies documented; investigate the reported delay in detecting IN_PROGRESS separately.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug
Describe the bug

With plugins: "bg" and the cluster writer endpoint, the plugin neither suspends calls during switchover nor reconnects to the green IP. Downtime is the same as plain mysql2. Two defects, plus a missing dependency note:

1. Cluster endpoints are dropped from hostNames
blue_green_status_monitor.ts L311: collectTopology() replaces the set that collectStatus() filled with cluster endpoints (~L377/L404):

this.hostNames = new Set(currentTopologyCopy.map((hostSpec) => hostSpec.host));

roleByHost then contains instance endpoints only, so connections via the cluster endpoint get no role and are not handled. JDBC (addAll) and Python (update) add to the set instead.

2. isMatch compares a string with an object
routing/base_connect_routing.ts L28 and base_execute_routing.ts L27:

this.hostAndPort === (hostInfo ?? hostInfo.hostAndPort.toLowerCase())

hostInfo ?? ... returns the HostInfo object, so this is always false and endpoint-specific routings (e.g. SubstituteConnectRouting) never apply.

3. Undocumented dependencies
bg fails to load unless both @aws-sdk/credential-providers and @aws-sdk/rds-signer are installed (blue_green_plugin.ts L26 imports IamAuthenticationPlugin). UsingTheBlueGreenPlugin.md doesn't mention this. Similar class of issue to #515, different dependency chain.

AwsWrapperError: The plugin could not be imported due to error 'Cannot find package '@aws-sdk/credential-providers' ...' Plugin: 'BlueGreenPluginFactory'
Expected Behavior

Calls via the cluster endpoint are suspended during IN_PROGRESS and reconnect to the green IP, as with the JDBC wrapper (~3.9 s write downtime in the same test).

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

plugins: "bg", dialect: "aurora-mysql", clusterId: , ssl: { ca }, wrapperConnectTimeout: 10000, wrapperQueryTimeout: 10000, host = cluster writer endpoint (AwsMySQLClient, mysql2 3.22.3). Also with plugins: "initialConnection,auroraConnectionTracker,bg,failover2"

Current Behavior
  • Original 3.0.1: roleByHost lists 4 instance endpoints only (Python wrapper in the same environment: 8 incl. cluster endpoints). Calls get --read-only errors like plain mysql2. Write downtime ~24.6 s vs ~21.9 s plain mysql2.
  • With fix 1 only: cluster endpoints present (8 entries), still ~24.8 s (reconnect waits for DNS).
  • With fixes 1+2: ~5.3 s.
  • Note: Node.js detected IN_PROGRESS ~1.1-1.7 s later than the Python/JDBC wrappers in the same switchover, so a few --read-only errors still occur before suspension. Cause not investigated.
Reproduction Steps
  1. Aurora MySQL cluster + Blue/Green deployment (same version), wait for AVAILABLE.
  2. Write every 100 ms:
import { AwsMySQLClient } from "aws-advanced-nodejs-wrapper/mysql";
const client = new AwsMySQLClient({ host: "<cluster-endpoint>", user, password, database: "test", ssl: { ca },
  plugins: "bg", dialect: "aurora-mysql", wrapperConnectTimeout: 10000, wrapperQueryTimeout: 10000 });
await client.connect();
setInterval(async () => { try { await client.query("INSERT INTO t(v) VALUES (1)"); console.log(Date.now()); } catch (e) { console.log(e.message); } }, 100);
  1. After the plugin logs CREATED (LOG_LEVEL=debug), start the switchover. Check roleByHost and the write gap.
Possible Solution
 // blue_green_status_monitor.ts
-      this.hostNames = new Set(currentTopologyCopy.map((hostSpec) => hostSpec.host));
+      currentTopologyCopy.forEach((hostSpec) => this.hostNames.add(hostSpec.host));

 // base_connect_routing.ts, base_execute_routing.ts
-    this.hostAndPort === (hostInfo ?? hostInfo.hostAndPort.toLowerCase())
+    this.hostAndPort === (hostInfo?.hostAndPort.toLowerCase() ?? null)

Also document (or avoid statically importing) the two @aws-sdk/* dependencies for bg.

Additional Information/Context

Aurora MySQL 8.4.10, db.r8g.large x2, same-version Blue/Green deployment.

The AWS Advanced NodeJs Wrapper version used

3.0.1

Node version used

v22.23.4

Operating System and version

Amazon Linux 2023 (aarch64)

Lenguaje dominante
TypeScript
Estrellas
38
Forks
17
Merge medio
3 d 11 h
PR fusionados (30 d)
4

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de aws/aws-advanced-nodejs-wrapper

Todos los issues de aws/aws-advanced-nodejs-wrapper

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.