Tag

ErrBadConn

1 views collected around this technical thread.

37 Interactive Technology Team
37 Interactive Technology Team
Mar 18, 2024 · Databases

Handling MySQL Read‑Only Errors During Master‑Slave Switch in Go: Extending the Driver and Using rejectReadOnly

When a MySQL master‑slave switch makes the old master read-only, Go connection pools keep reusing stale connections and cause prolonged write errors, but by extending the driver to return driver.ErrBadConn on error 1290 or using the DSN flag rejectReadOnly=true, the bad connections are discarded and the error disappears almost instantly.

ConnectionPoolDatabaseSwitchDriverExtension
0 likes · 14 min read
Handling MySQL Read‑Only Errors During Master‑Slave Switch in Go: Extending the Driver and Using rejectReadOnly