File tree 1 file changed +10
-0
lines changed
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -553,6 +553,16 @@ func (mc *mysqlConn) handleErrorPacket(data []byte) error {
553
553
554
554
// 1792: ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION
555
555
if errno == 1792 && mc .cfg .RejectReadOnly {
556
+ // Oops; we are connected to a read-only connection, and won't be able
557
+ // to issue any write statements. Since RejectReadOnly is configured,
558
+ // we throw away this connection hoping this one would have write
559
+ // permission. This is specifically for an AWS Aurora behavior during
560
+ // failover. See README.md for more.
561
+ //
562
+ // We explicitly close the connection before returning
563
+ // driver.ErrBadConn to ensure that `database/sql` purges this
564
+ // connection and initiates a new one for next statement next time.
565
+ mc .Close ()
556
566
return driver .ErrBadConn
557
567
}
558
568
You can’t perform that action at this time.
0 commit comments