-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
What version of Bun is running?
1.3.3
What platform is your computer?
docker oven/bun:1
What steps can reproduce the bug?
After a long running process continues to hammer the mysql database for over an hour I'm getting this error:
"message":"Max lifetime timeout reached after 1h"
"code":"ERR_MYSQL_LIFETIME_TIMEOUT",
"originalLine":14,"originalColumn":24,"line":14,"column":24,"sourceURL":"internal:sql/mysql"
My db settings are these:
import { SQL } from "bun";
const mysqlOptions = {
adapter: "mysql",
hostname: process.env.MYSQL_HOST || "localhost",
port: Number.parseInt(process.env.MYSQL_PORT || 3307, 10),
username: process.env.MYSQL_USER,
password: process.env.MYSQL_PASSWORD,
database: process.env.MYSQL_DATABASE,
bigint: true,
tls: {
rejectUnauthorized: false, // Set to true if you want to verify certificates
},
// Explicitly set connection limits
max: 10, // allow 10 connections (important when sync is running)
idleTimeout: 60 * 1, // Close after 1min idle
connectionTimeout: 30, // 30s timeout for new connections
maxLifetime: 60 * 60, // 60min lifetime to force periodic reconnection
};
const mysql = new SQL(mysqlOptions);
...
await mysql`SELECT ....`;
...
Individual queries are taking a while.. maybe 2-4min but well below the hour. The idle timout is likely never hit as requests are going in quite rapidly. All queries are readonly I'm not creating a transaction simply triggering mysqlSELECT statements. The process is sequental so no more than one connection is really required so I don't think all 10 connections are in use.
What is the expected behavior?
Once the maxLifeTime is reached the connection will be flagged and no new queries will be started with that connection. A fresh connection will start handling new quries and there wont be a timeout error thrown.
What do you see instead?
Instead at around the 1hour mark I'm getting that exception thrown.
Additional information
No response