sidorares / sidorares/node-mysql2
Graceful poolcluster management with AWS Aurora
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.4k
- Forks
- 680
- Avg merge
- 9h 7m
- Merged PRs (30d)
- 59
Description
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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the mysql2 pool cluster options and the discussion in issue #1103, then compare the current removeNodeErrorCount behavior with AWS Aurora endpoint changes. Define the graceful retry or pool-management behavior needed to avoid client-visible errors, and verify it with focused pool-cluster coverage before documenting the supported approach.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, mysql, nodejs, typescript
- Domain
- backend, cloud, databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100