Mysql ER_PARSE_ERROR until flow is redeployed or restarted


var dataIn = msg.payload;
var price = dataIn.bpi.USD.rate_float;
if (price != null){
    var dataForInsertQuery = [];
    var ts = dataIn.time.updatedISO.slice(0, 19).replace('T', ' ');
    var SQLcmd = "INSERT INTO crypto.btc_tbl (ts,price) VALUES (?,?);";
    var SQLval = [dataForInsertQuery[0],parseFloat(dataForInsertQuery[1])];
    msg.topic = SQLcmd;
    msg.payload = SQLval;
    return msg;
return null;


I receive this error about 15-20 minutes of same code working. Once it happens then on every transaction I get this error. Redploying the node without any changes in config or code starts working with following message output:


Node: node-red-node-mysql
Node Red Version v1.3.4
Node.js version v10.24
mysql Ver15.1 Distrib 10.3.27-MariaDB

I've seen this some time ago but failed to capture it in an issue (I thought I was doing something wrong). However it was very similar & certainly smells like a bug. I would suggest raising an issue on GitHub

Ps, I believe I worked around it by avoiding prepared statements & reverted to building a string query (not ideal but I needed a quick solution)

How frequent are the inserts?

Can you explain it a bit more.... I'm a noob at this....

regarding raising issue on GitHub, should it be on node-red-node-mysql ?

every 2-minute interval

ok, I just wanted to check if it was being flooded but every two minutes shouldn't be and issue.

How are ts and price defined in your database schema ?

If you do raise an issue we are going to need a means of recreating the problem reliably - sorry to say but we can't sit around waiting for random failures for hours on end. Which version of the node-red-node-mysql are you using ? as there was a recent update to improve the pooling of connections.


node-red-node-mysql v0.1.9

And yes you are right about the testing part. Sometimes the failure is not as mentioned in OP, it is random, can happen in 5-minutes, and sometimes works for hours before going into this problem.

Is the mariaDB server on the same machine as node-red?

Yes, node-red and mariadb are both running on a headless raspberry pi

If you stop the db server and restart it does it trigger the error?

used following commands to stop and start
sudo mysqladmin shutdown
sudo service mysql start

And without redeploying flows it started working again.

if you deliberately send a bad INSERT (e.g. send a string of "hello" for the decimal price field) followed by a good INSERT - does that cause the issue?

if you deliberately send a bad INSERT (e.g. send no parameters in payload or payload an empty array) followed by a good INSERT - does that cause the issue?




what if you do 20 (or more) of those bad ones in a row (then try a good insert) - perhaps it will exhaust the pool?

Will try tomorrow and report.

I have observed that the insert query isn't the problem. Alone it keeps working, however this error occurs after data is pulled from the DB via another MySQL node (same version). Data comes out fine and is displayed on dashboard, and this nodes stays green displays OK status. But after that all insert queries keep failing until the flow is redeplyed/restarted.
Following is code of Read function:

var formData=msg.payload;
var startDate = formData.startDate.slice(0, 19).replace('T', ' ');
var endDate = formData.endDate.slice(0, 19).replace('T', ' ');
var dataForRetrieveQuery = [];
var SQLcmd = "";
var timeMA = formData.timeMA;
if (formData.enableMA == true) {
    if (timeMA<2){
    SQLcmd = "SELECT ts,price, AVG(price) OVER (ORDER BY id ROWS BETWEEN " + timeMA + " PRECEDING AND CURRENT ROW) AS average FROM crypto.btc_tbl WHERE ts between " + "'" + startDate + "'" + " AND " + "'" + endDate + "'" + " LIMIT 1000;";
} else {
    SQLcmd = "SELECT ts, price FROM crypto.btc_tbl WHERE ts between " + "'" + startDate + "'" + " AND " + "'" + endDate + "'" + " LIMIT 1000;";

return msg;

Good find.

In the interest of getting this resolved, would it be possible for you to build a demo flow that does the following...

  1. Inject that does a CREATE TABLE → MYSQL node
  2. inject that does INSERT → MYSQL node
  3. inject that does a SELECT --> MYSQL node (a separate one)
  4. inject that does DROP TABLE → MYSQL node (for clean up)

If you can, I will also test it & if it fails for me too, then we can raise an issue on the repo with a repeatable flow that demonstrates the issue.

Are you using the same MySQL database config node in the two mysql nodes?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.