sidorares / node-mysql2

:zap: fast mysqljs/mysql compatible mysql driver for node.js
https://sidorares.github.io/node-mysql2/
MIT License
4.05k stars 612 forks source link

Connection was killed could (should?) be a fatal error #510

Open magnusjt opened 7 years ago

magnusjt commented 7 years ago

This a bit of an obscure one. Using mariadb, I'm able to get the following error if the database is stopped during a query:

Error: Connection was killed
at Packet.asError (/node_modules/mysql2/lib/packets/packet.js:667:13)
at Execute.Command.execute (/node_modules/mysql2/lib/commands/command.js:29:22)
at PoolConnection.Connection.handlePacket (/node_modules/mysql2/lib/connection.js:417:28)
at PacketParser.onPacket (/node_modules/mysql2/lib/connection.js:93:16)
at PacketParser.executeStart (/node_modules/mysql2/lib/packet_parser.js:73:14)
at Socket.<anonymous> (/node_modules/mysql2/lib/connection.js:101:29)
at emitOne (events.js:96:13)
at Socket.emit (events.js:189:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)

errno: 1927 sqlstate: 70100 (query interrupted) fatal: false

I'm wondering if the error should be fatal since the connection is killed.

The error code is specific to mariadb: https://mariadb.com/kb/en/mariadb/mariadb-error-codes/

sidorares commented 7 years ago

if underlying tcp connection is killed it probably does not matter

I think 'is fatal' is important for connection pool, when we know that connection cannot be reused despite stream is still open

magnusjt commented 7 years ago

It's also important when running a query because it can be used to decide to retry the query later.

magnusjt commented 7 years ago

Found a bit more info here: https://github.com/PyMySQL/PyMySQL/issues/526

I can also see the mentioned error in my logs: Warning: got packets out of order. Expected 1 but received 0

sidorares commented 7 years ago

@magnusjt thanks! I'll try to reproduce with maria and have a look