question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when using MariaDB as backend database

See original GitHub issue

I was experimenting with sqlpad lately and everything was working fine up until the point when I decided to have standalone backend database for query history persistence. First DBMS I tried was MariaDB (simply because I had a spare one) and after I created separate schema for sqlpad there and pointed SQLPAD_BACKEND_DB_URI variable to it I was left with only auth working. Both schema browser and queries stopped working. In the logs of sqlpad I see that it’s trying to read something from batches table and failing:

{"level":20,"time":"2021-06-17T11:05:48.431Z","pid":1,"hostname":"51b5bfe1a4ad","name":"sqlpad-app","msg":"Executing (default): SELECT `id`, `query_id` AS `queryId`, `name`, `connection_id` AS `connectionId`, `connection_client_id` AS `connectionClientId`, `status`, `start_time` AS `startTime`, `stop_time` AS `stopTime`, `duration_ms` AS `durationMs`, `batch_text` AS `batchText`, `selected_text` AS `selectedText`, `chart`, `user_id` AS `userId`, `created_at` AS `createdAt`, `updated_at` AS `updatedAt` FROM `batches` AS `Batches` WHERE `Batches`.`id` = 'b762439e-0674-4325-8d69-1136b6376322';"}
{"level":50,"time":"2021-06-17T11:05:48.435Z","pid":1,"hostname":"51b5bfe1a4ad","name":"sqlpad-app","stack":"SyntaxError: Unexpected token o in JSON at position 1
  at JSON.parse (<anonymous>)
  at /usr/app/node_modules/sequelize/lib/dialects/mariadb/query.js:186:72
  at Array.map (<anonymous>)
  at Query.handleJsonSelectQuery (/usr/app/node_modules/sequelize/lib/dialects/mariadb/query.js:185:21)
  at Query.formatResults (/usr/app/node_modules/sequelize/lib/dialects/mariadb/query.js:130:12)
  at Query.run (/usr/app/node_modules/sequelize/lib/dialects/mariadb/query.js:74:17)
  at processTicksAndRejections (internal/process/task_queues.js:97:5)
  at async /usr/app/node_modules/sequelize/lib/sequelize.js:619:16
  at async MySQLQueryInterface.select (/usr/app/node_modules/sequelize/lib/dialects/abstract/query-interface.js:953:12)
  at async Function.findAll (/usr/app/node_modules/sequelize/lib/model.js:1753:21)
  at async Function.findOne (/usr/app/node_modules/sequelize/lib/model.js:1917:12)
  at async Batches.findOneById (/usr/app/models/batches.js:16:17)
  at async create (/usr/app/routes/batches.js:38:20)","type":"Error","msg":"Unexpected token o in JSON at position 1"}

Then I tried to use postgres as backend db and it worked perfectly fine! I see the same query from batches table except now it’s not failing:

{"level":20,"time":"2021-06-17T11:49:13.826Z","pid":1,"hostname":"49cf75db16ed","name":"sqlpad-app","msg":"Executing (default): SELECT \"id\", \"query_id\" AS \"queryId\", \"name\", \"connection_id\" AS \"connectionId\", \"connection_client_id\" AS \"connectionClientId\", \"status\", \"start_time\" AS \"startTime\", \"stop_time\" AS \"stopTime\", \"duration_ms\" AS \"durationMs\", \"batch_text\" AS \"batchText\", \"selected_text\" AS \"selectedText\", \"chart\", \"user_id\" AS \"userId\", \"created_at\" AS \"createdAt\", \"updated_at\" AS \"updatedAt\" FROM \"batches\" AS \"Batches\" WHERE \"Batches\".\"id\" = '6e2b517a-e508-4064-9bca-bb63dff94b87';"}
{"level":20,"time":"2021-06-17T11:49:13.832Z","pid":1,"hostname":"49cf75db16ed","name":"sqlpad-app","msg":"Executing (default): SELECT \"id\", \"query_id\" AS \"queryId\", \"name\", \"connection_id\" AS \"connectionId\", \"connection_client_id\" AS \"connectionClientId\", \"status\", \"start_time\" AS \"startTime\", \"stop_time\" AS \"stopTime\", \"duration_ms\" AS \"durationMs\", \"batch_text\" AS \"batchText\", \"selected_text\" AS \"selectedText\", \"chart\", \"user_id\" AS \"userId\", \"created_at\" AS \"createdAt\", \"updated_at\" AS \"updatedAt\" FROM \"batches\" AS \"Batches\" WHERE \"Batches\".\"id\" = '6e2b517a-e508-4064-9bca-bb63dff94b87';"}

I thought may be I misconfigured something in the first place so I decided to reproduce everything from scratch and… Managed to do that: combo of latest sqlpad docker image + latest mariadb docker image + SQLPAD_BACKEND_DB_URI pointing to that mariadb is definitely not working as it should.

Any ideas what could cause this behavior?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
eladeyal-intelcommented, Jun 17, 2021

Wow that escalated quickly

image

0reactions
rickbergfalkcommented, Nov 10, 2021

Sequelize seems to be maintained again 🙌 Was able to get the changes in the fork back upstream https://github.com/sequelize/sequelize/pull/13633

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error establishing a database connection - MariaDB
I modify the code of my base sql and since more way to go neither on the front nor on the backend. The...
Read more >
got "ERROR 2003 (HY000): Authentication with backend ...
I have 2 MySQL servers named esDB1 esDB2 and an isolative MaxScale server. · There are 2 users for MaxScale in DB: ·...
Read more >
Troubleshooting Connection Issues - MariaDB Knowledge Base
If you can connect to the server, but not to a database, for example: USE test; ERROR 1044 (42000): Access denied for user...
Read more >
How errors are handled in MariaDB MaxScale
An "error" can be due to failed authentication, routing error (unsupported query type etc.), or backend failure. Authentication error. Authentication is ...
Read more >
Support mariadb as a database backend [GOT CREATED]
Currently, if I use the mysqldb settings with a mariadb server, I get the following error. It seems like n8n was not able...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found