Skip to content

Commit 8f2aa4b

Browse files
committed
coa-updater: Increase timeouts
1 parent 2567fcd commit 8f2aa4b

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

apps/coa-updater/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,16 @@ set global max_allowed_packet=1000000000; `,
174174

175175
const tables = (
176176
await newDbConnection.query(
177-
`SELECT table_name FROM information_schema.tables WHERE table_schema = ?`,
177+
`SELECT table_name FROM information_schema.tables WHERE table_schema = ? ORDER BY table_name`,
178178
[process.env.MYSQL_DATABASE_NEW],
179179
)
180180
).map((row: { table_name: string }) => row.table_name);
181-
newDbConnection.release();
181+
await newDbConnection.release();
182182

183-
// Get a fresh connection for the rename loop - the original connection was idle
184-
// during the long SQL phase and may have been closed by the server (wait_timeout)
185-
connection.release();
183+
// Get a fresh connection BEFORE releasing the original - otherwise the pool may
184+
// return the same stale connection that was idle for 30+ min during the SQL phase
186185
const renameConnection = await pool.getConnection();
186+
await connection.release();
187187
await renameConnection.query(
188188
"SET SESSION net_read_timeout = 7200; SET SESSION net_write_timeout = 7200; SET SESSION wait_timeout = 28800",
189189
);
@@ -200,7 +200,7 @@ set global max_allowed_packet=1000000000; `,
200200
}
201201

202202
await renameConnection.query(`drop database ${process.env.MYSQL_DATABASE_NEW}`);
203-
renameConnection.release();
203+
await renameConnection.release();
204204

205205
console.log("mariadb-check...");
206206
await $`mariadb-check -h ${process.env.MYSQL_HOST} -uroot -p${process.env.MYSQL_ROOT_PASSWORD} -v ${process.env.MYSQL_DATABASE}`;

0 commit comments

Comments
 (0)