File tree 3 files changed +9
-2
lines changed
3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ INADA Naoki <songofacandy at gmail.com>
35
35
Jacek Szwec <szwec.jacek at gmail.com>
36
36
James Harr <james.harr at gmail.com>
37
37
Jeff Hodges <jeff at somethingsimilar.com>
38
+ Jeffrey Charles <jeffreycharles at gmail.com>
38
39
Jian Zhen <zhenjl at gmail.com>
39
40
Joshua Prunier <joshua.prunier at gmail.com>
40
41
Julien Lefevre <julien.lefevr at gmail.com>
Original file line number Diff line number Diff line change @@ -279,7 +279,7 @@ Default: false
279
279
```
280
280
281
281
282
- ` rejectreadOnly =true` causes the driver to reject read-only connections. This
282
+ ` rejectReadOnly =true` causes the driver to reject read-only connections. This
283
283
is for a possible race condition during an automatic failover, where the mysql
284
284
client gets connected to a read-only replica after the failover.
285
285
@@ -294,6 +294,11 @@ If you are not relying on read-only transactions to reject writes that aren't
294
294
supposed to happen, setting this on some MySQL providers (such as AWS Aurora)
295
295
is safer for failovers.
296
296
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
+
297
302
298
303
##### ` timeout `
299
304
Original file line number Diff line number Diff line change @@ -580,7 +580,8 @@ func (mc *mysqlConn) handleErrorPacket(data []byte) error {
580
580
errno := binary .LittleEndian .Uint16 (data [1 :3 ])
581
581
582
582
// 1792: ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION
583
- if errno == 1792 && mc .cfg .RejectReadOnly {
583
+ // 1290: ER_OPTION_PREVENTS_STATEMENT (returned by Aurora during failover)
584
+ if (errno == 1792 || errno == 1290 ) && mc .cfg .RejectReadOnly {
584
585
// Oops; we are connected to a read-only connection, and won't be able
585
586
// to issue any write statements. Since RejectReadOnly is configured,
586
587
// we throw away this connection hoping this one would have write
You can’t perform that action at this time.
0 commit comments