mysqljs / mysql

A pure node.js JavaScript Client implementing the MySQL protocol.
MIT License
18.31k stars 2.53k forks source link

Write cluster failover, pool stuck with read-only cluster #2556

Open francisco4challenge opened 2 years ago

francisco4challenge commented 2 years ago

I am using amazon aurora RDS in my application, with a cluster with 2 endpoints, read and write. Using Pools, with the host as the cluster endpoint. var pool = mysql.createPool(...); pool.getConnection( connection => connection.query())

When the primary writer endpoint failsover, the driver seems to be using the available reader endpoint, and insert/update fails (makes sense), but it never switches back to the writer, even when it becomes available.

Is there a way to handle these sittuations?

dougwilson commented 2 years ago

Hi @francisco4challenge how does the failover work, exactly? I assume you have a DNS name in this module's configuration, is that right? Does RDS update the DNS at some point to change that DNS name to the new writer? Also, does it terminate the connection this module has to the reader when it fails over?