File tree Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ INADA Naoki <songofacandy at gmail.com>
3434Jacek Szwec <szwec.jacek at gmail.com>
3535James Harr <james.harr at gmail.com>
3636Jeff Hodges <jeff at somethingsimilar.com>
37+ Jeffrey Charles <jeffreycharles at gmail.com>
3738Jian Zhen <zhenjl at gmail.com>
3839Joshua Prunier <joshua.prunier at gmail.com>
3940Julien Lefevre <julien.lefevr at gmail.com>
Original file line number Diff line number Diff line change @@ -279,7 +279,7 @@ Default: false
279279```
280280
281281
282- ` rejectreadOnly =true` causes the driver to reject read-only connections. This
282+ ` rejectReadOnly =true` causes the driver to reject read-only connections. This
283283is for a possible race condition during an automatic failover, where the mysql
284284client gets connected to a read-only replica after the failover.
285285
@@ -294,6 +294,11 @@ If you are not relying on read-only transactions to reject writes that aren't
294294supposed to happen, setting this on some MySQL providers (such as AWS Aurora)
295295is safer for failovers.
296296
297+ Note that ERROR 1290 can be returned for a ` read-only ` server and this option will
298+ cause a retry for that error. However the same error number is used for some
299+ other cases. You should ensure your application will never cause an ERROR 1290
300+ except for ` read-only ` mode when enabling this option.
301+
297302
298303##### ` timeout `
299304
Original file line number Diff line number Diff line change @@ -571,7 +571,8 @@ func (mc *mysqlConn) handleErrorPacket(data []byte) error {
571571 errno := binary .LittleEndian .Uint16 (data [1 :3 ])
572572
573573 // 1792: ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION
574- if errno == 1792 && mc .cfg .RejectReadOnly {
574+ // 1290: ER_OPTION_PREVENTS_STATEMENT (returned by Aurora during failover)
575+ if (errno == 1792 || errno == 1290 ) && mc .cfg .RejectReadOnly {
575576 // Oops; we are connected to a read-only connection, and won't be able
576577 // to issue any write statements. Since RejectReadOnly is configured,
577578 // we throw away this connection hoping this one would have write
You can’t perform that action at this time.
0 commit comments