[MXS-4652] strange connection issues with nodejs connector and maxscale Created: 2023-06-19  Updated: 2023-06-22  Resolved: 2023-06-22

Status: Closed
Project: MariaDB MaxScale
Component/s: N/A
Affects Version/s: 2.5.26
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Felix Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: Connector, maxscale
Environment:

nodejs 16, mariadb connector 3.1.2 and maxscale 2.5.26


Attachments: File maxscale.cnf    

 Description   

Part of our setup is a nodejs socket component running on nodejs 16 and using mariadb connector 3.1.2. It should connect to mascale, running version 2.5.26, routing to 3 mariadb servers.
The maxscale + database setups works without any issues with our PHP backend, but not with the nodejs + mariadb connector part.

We see strange errors as this:

sqlMessage: 'The MariaDB server is running with the --read-only option so it cannot execute this statement',
sql: 'SELECT user_companies.company_id\n' +
' FROM user_companies\n' +
' WHERE user_companies.user_id = 2001766 - parameters:[]',
fatal: false,
errno: 1290,
sqlState: 'HY000',
code: 'ER_OPTION_PREVENTS_STATEMENT'

SqlError: (conn=2345476, no: 1927, SQLState: HY000) Authentication to 'db02' failed: 1047, #08S01: Unknown command (db02)
sql: SELECT user_devices.user_id, user_devices.ip_address, users.online_status FROM user_devices JOIN users ON (users.id = user_devices.user_id) WHERE users.deleted IS NULL AND user_devices.device_id = 'xxx' AND user_devices.app_secret = 'xxx' AND user_devices.lease > 1687208453 - parameters:[]
at Object.module.exports.createError (/nodejs/node_modules/mariadb/lib/misc/errors.js:61:10)
at PacketNodeEncoded.readError (/nodejs/node_modules/mariadb/lib/io/packet.js:572:19)
at Query.readResponsePacket (/nodejs/node_modules/mariadb/lib/cmd/parser.js:55:28)
at PacketInputStream.receivePacketBasic (/nodejs/node_modules/mariadb/lib/io/packet-input-stream.js:82:9)
at PacketInputStream.onData (/nodejs/node_modules/mariadb/lib/io/packet-input-stream.js:132:20)
at Socket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)

{ sqlMessage: "Authentication to 'db02' failed: 1047, #08S01: Unknown command (db02)", sql: "SELECT user_devices.user_id, user_devices.ip_address, users.online_status FROM user_devices JOIN users ON (users.id = user_devices.user_id) WHERE users.deleted IS NULL AND user_devices.device_id = 'xxx' AND user_devices.app_secret = 'xxx' AND user_devices.lease > 1687208453 - parameters:[]", fatal: false, errno: 1927, sqlState: 'HY000', code: 'ER_CONNECTION_KILLED' }

If the connection is established without maxscale, directly to a db, there are no errors.
We already tried different versions of the nodejs connector, but no luck.



 Comments   
Comment by Diego Dupin [ 2023-06-21 ]

There is no obvious reason to here, but if direct connection to DB works ok, this clearly indicate that this is a maxscale issue.
changing to maxscale issue

Comment by Felix [ 2023-06-21 ]

deploying the same in a nodejs 12 enviroment works fine

Comment by Diego Dupin [ 2023-06-21 ]

I think that using node.js 12 successful use has nothing to do there:

  • for the first error, example is a SELECT but the error indicate that this is not permit because of "--read-only" option on server. markus makela, can that be a maxscale error, or does that comes from server ?
  • second error seems to be that connector is connected to maxscale, but maxscale doesn't success to connect to server, right markus makela ?
Comment by markus makela [ 2023-06-22 ]

Ferchland please include your MaxScale configuration. It's possible that this is expected behavior if you are using master_failure_mode=error_on_write.

Comment by Felix [ 2023-06-22 ]

maxscale.cnf has been added
thx

Comment by markus makela [ 2023-06-22 ]

You indeed do seem to have master_failure_mode=error_on_write in your configuration. I think this is an expected outcome since you also have master_accept_reads=true.

You also have disable_sescmd_history=true as well as prune_sescmd_history=true defined at the same time. The former makes the latter not work at all: I'd recommend removing disable_sescmd_history=true.

You might also benefit from enabling master_reconnection in your current setup. This way if the server comes back up, a new connection to it can be created. Right now if the connection is lost and read-only errors end up being generated, they'll never go away since you don't have master_reconnection enabled. If enabled, the read-only errors would go away when the server comes back.

Generated at Thu Feb 08 04:30:11 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.