n8n-io / n8n

Free and source-available fair-code licensed workflow automation tool. Easily automate tasks across different services.
https://n8n.io
Other
42.92k stars 5.61k forks source link

n8n:latest in a crashloop - error running database migrations (features.sourceControl.sshKeys) #9144

Closed accforgithubtest closed 3 months ago

accforgithubtest commented 3 months ago

Bug Description

Upgraded to the latest version of n8n and the container would not come up anymore. Below are the logs I see (via portainer logs).

Typical n8n installation via docker compose, using the n8n:latest. MySql Database as n8n storage. Issue started after upgrading to the latest version.

User settings loaded from: /home/node/.n8n/config
Last session crashed
n8n ready on 0.0.0.0, port 5678
Migrations in progress, please do NOT stop the process.
Migration "MoveSshKeysToDatabase1711390882123" failed, error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key = 'features.sourceControl.sshKeys'' at line 1
Error: There was an error running database migrations
QueryFailedError: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key = 'features.sourceControl.sshKeys'' at line 1
User settings loaded from: /home/node/.n8n/config
Last session crashed
n8n ready on 0.0.0.0, port 5678
Migrations in progress, please do NOT stop the process.
Migration "MoveSshKeysToDatabase1711390882123" failed, error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key = 'features.sourceControl.sshKeys'' at line 1
Error: There was an error running database migrations
QueryFailedError: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key = 'features.sourceControl.sshKeys'' at line 1

To Reproduce

Typical n8n installation via docker compose, using the n8n:latest. MySql Database as n8n storage. Issue started after upgrading to the latest version.

Expected behavior

Dont run into crashloop.

Operating System

Ubuntu 22.04.4 LTS

n8n Version

n8n:latest (via docker compose)

Node.js Version

N/A

Database

MySQL

Execution mode

main (default)

accforgithubtest commented 3 months ago

Downgrading back to 1.36.1 doesnt help either !! I still see the same error.

Does this mean my current n8n db is corrupt ? Do I have any options to recover ?

accforgithubtest commented 3 months ago

logs in debug mode -

2024-04-16T04:34:36.720Z | error    | Last session crashed "{ file: 'CrashJournal.js', function: 'init' }"
2024-04-16T04:34:46.730Z | info     | Initializing n8n process "{ file: 'start.js', function: 'init' }"
2024-04-16T04:34:46.843Z | debug    | Lazy Loading credentials and nodes from n8n-nodes-base "{\n  credentials: 353,\n  nodes: 447,\n  file: 'LoggerProxy.js',\n  function: 'exports.debug'\n}"
2024-04-16T04:34:46.857Z | debug    | Lazy Loading credentials and nodes from @n8n/n8n-nodes-langchain "{\n  credentials: 14,\n  nodes: 70,\n  file: 'LoggerProxy.js',\n  function: 'exports.debug'\n}"
2024-04-16T04:34:46.860Z | debug    | Can't enable lazy-loading "{ file: 'LoggerProxy.js', function: 'exports.debug' }"
2024-04-16T04:34:46.922Z | debug    | Loaded all credentials and nodes from n8n-nodes-browserless "{\n  credentials: 1,\n  nodes: 1,\n  file: 'LoggerProxy.js',\n  function: 'exports.debug'\n}"
n8n ready on 0.0.0.0, port 5678
2024-04-16T04:34:47.053Z | warn     | Migrations in progress, please do NOT stop the process. "{ file: 'migrationHelpers.js', function: 'logMigrationStart' }"
2024-04-16T04:34:47.053Z | info     | Starting migration MoveSshKeysToDatabase1711390882123 "{ file: 'migrationHelpers.js', function: 'logMigrationStart' }"
Migration "MoveSshKeysToDatabase1711390882123" failed, error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key = 'features.sourceControl.sshKeys'' at line 1
2024-04-16T04:34:47.057Z | error    | Error: There was an error running database migrations "{ file: 'LoggerProxy.js', function: 'exports.error' }"
2024-04-16T04:34:47.057Z | error    | QueryFailedError: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key = 'features.sourceControl.sshKeys'' at line 1 "{ file: 'LoggerProxy.js', function: 'exports.error' }"
User settings loaded from: /home/node/.n8n/config
2024-04-16T04:34:51.463Z | error    | Last session crashed "{ file: 'CrashJournal.js', function: 'init' }"
2024-04-16T04:35:01.470Z | info     | Initializing n8n process "{ file: 'start.js', function: 'init' }"
2024-04-16T04:35:01.616Z | debug    | Lazy Loading credentials and nodes from n8n-nodes-base "{\n  credentials: 353,\n  nodes: 447,\n  file: 'LoggerProxy.js',\n  function: 'exports.debug'\n}"
2024-04-16T04:35:01.630Z | debug    | Lazy Loading credentials and nodes from @n8n/n8n-nodes-langchain "{\n  credentials: 14,\n  nodes: 70,\n  file: 'LoggerProxy.js',\n  function: 'exports.debug'\n}"
2024-04-16T04:35:01.633Z | debug    | Can't enable lazy-loading "{ file: 'LoggerProxy.js', function: 'exports.debug' }"
2024-04-16T04:35:01.696Z | debug    | Loaded all credentials and nodes from n8n-nodes-browserless "{\n  credentials: 1,\n  nodes: 1,\n  file: 'LoggerProxy.js',\n  function: 'exports.debug'\n}"
n8n ready on 0.0.0.0, port 5678
2024-04-16T04:35:01.826Z | warn     | Migrations in progress, please do NOT stop the process. "{ file: 'migrationHelpers.js', function: 'logMigrationStart' }"
2024-04-16T04:35:01.826Z | info     | Starting migration MoveSshKeysToDatabase1711390882123 "{ file: 'migrationHelpers.js', function: 'logMigrationStart' }"
Migration "MoveSshKeysToDatabase1711390882123" failed, error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key = 'features.sourceControl.sshKeys'' at line 1
2024-04-16T04:35:01.830Z | error    | Error: There was an error running database migrations "{ file: 'LoggerProxy.js', function: 'exports.error' }"
2024-04-16T04:35:01.830Z | error    | QueryFailedError: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key = 'features.sourceControl.sshKeys'' at line 1 "{ file: 'LoggerProxy.js', function: 'exports.error' }"
User settings loaded from: /home/node/.n8n/config
2024-04-16T04:35:06.115Z | error    | Last session crashed "{ file: 'CrashJournal.js', function: 'init' }"
Joffcom commented 3 months ago

Hey @accforgithubtest,

Which version did you update from? Can you try updating to 1.37 and see if that works, It may also be time to think about moving away from MySQL and over to Postgres as we have started to remove MySQL from the documentation and will eventually remove it fully.

accforgithubtest commented 3 months ago

thanks for the suggestion @Joffcom ! Upgrading to 1.37.1 resolved the issue.

we have started to remove MySQL ... eventually remove it fully.

Are there any timelines for when mysql support will be fully removed ? Thanks for the heads up, will add it to my todo.

Cheers!

Joffcom commented 3 months ago

Hey @accforgithubtest,

No date set yet but I would say probably before the end of the year. As this seems to be all good in a newer I will mark this as closed for now.

accforgithubtest commented 3 months ago

thanks @Joffcom ! Are there any migration scripts for moving the data in mysql to a postgres ? Or is it recommended to go for a fresh install and import the workflows manually ?

I do have a few wotkflows that call other workflows. Given the workflow Id's are auto generated, I wonder if there will be a need for manually updating each workflow with new auto-generated id's ?