node-mysql2
node-mysql2 copied to clipboard
Graceful poolcluster management with AWS Aurora
I'm using mysql2 with typeorm and nestjs to connect to an AWS Aurora Serverless v2 MySQL database.
The connection is configured through a cluster FQDN and there's a dedicated FQDN for the read/write and read only endpoints, e.g. foo-cluster.cluster-foo333barzzz.us-west-2.rds.amazonaws.com. For this setup to work with high availability it's important if the actual IP behind the cluster changes the application retries and uses the new IP.
Right now, I'm using the following pool cluster options
{
`removeNodeErrorCount`: 500
}
which I think has the desired effect because it takes less than 500 retries for the FQDN to resolve to the new IP. Unfortunately, that means the client (a web app) may get a few errors and have to hit F5 a few times during this situation.
Is my understanding correct? Is there a better mechanism for handling this gracefully for the client?
For example, with python sqlachemy I have pool_pre_ping and pool_recycle
(This is similar to the discussion in https://github.com/sidorares/node-mysql2/issues/1103 but hopefully more specific)