Last session crashed after Migration

Describe the problem/error/question

Hello, I recently encountered an issue after unintentionally updating my n8n instance from an older version that supported MySQL to a newer version that has dropped support for MySQL. Realizing the issue, I manually downgraded back to the older version and created backups for credentials and workflows.

I then decided to upgrade again, but this time I switched to using Postgres as my database. However, after making this switch and updating, I’m now facing some error messages that I’m unable to resolve.

I have shared my Docker Compose file below for reference. I have commented out the MariaDB settings and updated the settings to use Postgres. However, I’m unsure if I’ve made the correct changes or if there’s something I’ve missed that’s causing these errors.

I would appreciate any guidance or suggestions on how to resolve these errors and successfully run n8n with Postgres. Thank you in advance for your help.

What is the error message (if any)?

2023-07-04T11:37:37.722Z | warn | License manager not initialized “{ file: ‘License.js’, function: ‘isFeatureEnabled’ }”
2023-07-04T11:37:37.727Z | error | Last session crashed “{ file: ‘CrashJournal.js’, function: ‘init’ }”
2023-07-04T11:37:47.940Z | debug | Lazy Loading credentials and nodes from n8n-nodes-base “{\n credentials: 317,\n nodes: 422,\n file: ‘DirectoryLoader.js’,\n function: ‘loadAll’\n}”

Please share your workflow


(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node


Information on your n8n setup

  • **n8n version: 0.234.0- Database (default: mariaDB => Postgres):
  • **n8n EXECUTIONS_PROCESS setting (default: own, main):default
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):docker
  • **Operating system: docker

Docker Compose:
version: ‘3.8’

volumes:
db_storage:
n8n_storage:
redis_storage:
shared-files:

x-shared:
&shared
restart: unless-stopped
environment:
- QUEUE_BULL_REDIS_HOST=redis
- QUEUE_HEALTH_CHECK_ACTIVE=true
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_DATABASE=postgres
- DB_POSTGRESDB_USER=n8n
- DB_POSTGRESDB_PASSWORD=n8npassword
#- DB_TYPE=mariadb
#- DB_MYSQLDB_HOST=db
#- DB_MYSQLDB_PORT=3306
#- DB_MYSQLDB_DATABASE=${MARIADB_DATABASE}
#- DB_MYSQLDB_USER=${MARIADB_USER}
#- DB_MYSQLDB_PASSWORD=${MARIADB_PASSWORD}
- N8N_HOST=crm.tribus-business.at
- N8N_EMAIL_MODE=smtp
- N8N_SMTP_HOST=192.168.1.220
- N8N_SMTP_PORT=25
- [email protected]
- N8N_SMTP_PASS=.connect2023
- N8N_SMTP_SSL=false
- WEBHOOK_URL=http://crm.tribus-business.at/
- NODE_OPTIONS=–max-old-space-size=8192
- N8N_DEFAULT_BINARY_DATA_MODE=filesystem
- EXECUTIONS_MODE=queue
- N8N_LOG_LEVEL=debug
- DB_LOGGING_ENABLED=true
- DB_LOGGING_OPTIONS=all
links:
- db
- redis
volumes:
- n8n_storage:/home/node/.n8n
- shared-files:/home/tribus/n8n/files
depends_on:
redis:
condition: service_healthy
db:
condition: service_healthy

services:
#db:
#image: mariadb:10.7
#restart: unless-stopped
#environment:
#- MARIADB_ROOT_PASSWORD
#- MARIADB_DATABASE
#- MARIADB_USER
#- MARIADB_PASSWORD
#- MARIADB_MYSQL_LOCALHOST_USER=true
#volumes:
#- db_storage:/var/lib/mysql
#healthcheck:
#test: “/usr/bin/mysql --user=${MARIADB_USER} --password=${MARIADB_PASSWORD} --execute ‘SELECT 1;’”
#interval: 10s
#timeout: 5s
#retries: 10

db:
image: postgres:11
restart: unless-stopped
environment:
- POSTGRES_USER
- POSTGRES_PASSWORD
- POSTGRES_DB
- POSTGRES_NON_ROOT_USER
- POSTGRES_NON_ROOT_PASSWORD
volumes:
- db_storage:/var/lib/postgresql/data
- ./init-data.sh:/docker-entrypoint-initdb.d/init-data.sh
healthcheck:
test:
[
‘CMD-SHELL’,
‘pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}’
]
interval: 5s
timeout: 5s
retries: 10

redis:
image: redis:6-alpine
restart: always
volumes:
- redis_storage:/data
healthcheck:
test: [ ‘CMD’, ‘redis-cli’, ‘ping’ ]
interval: 5s
timeout: 5s
retries: 10

n8n:
<<: *shared
image: n8nio/n8n:latest
command: /bin/sh -c “n8n start --tunnel”
ports:
- 5678:5678

n8n-worker:
<<: *shared
image: n8nio/n8n:latest
command: /bin/sh -c “sleep 5; n8n worker”
depends_on:
- n8n

filebrowser:
image: filebrowser/filebrowser
restart: unless-stopped
volumes:
- shared-files:/srv
- /home/tribus/filebrowser/filebrowser.db:/database.db
ports:
- 10000:80

Hi @nuri_yilmaz, I am so sorry for the trouble.

@Karbust encountered this problem over here, so you would want to follow the existing thread for updates. We will prepare a fix for the MySQL migration rolled out with n8n 0.234.

For the time being you would want to restore a backup from before the upgrade.

Thank you!
But now I got a new problem after migrating everything back to mysql and to a earlier version. I get 401 Unauthorized and cant do anything anymore. And I suspect that there is an cors error now.
This is my updated docker compose:
version: ‘3.8’

volumes:
db_storage:
n8n_storage:
redis_storage:
shared-files:
backup:

x-shared:
&shared
restart: unless-stopped
environment:
- QUEUE_BULL_REDIS_HOST=redis
- QUEUE_HEALTH_CHECK_ACTIVE=true
- DB_TYPE=mariadb
- DB_MYSQLDB_HOST=db
- DB_MYSQLDB_PORT=3306
- DB_MYSQLDB_DATABASE=${MARIADB_DATABASE}
- DB_MYSQLDB_USER=${MARIADB_USER}
- DB_MYSQLDB_PASSWORD=${MARIADB_PASSWORD}
- N8N_HOST=crm.tribus-business.at
- N8N_PROTOCOL=https
- NODE_ENV=production
- N8N_BASIC_AUTH_ACTIVE=false
- N8N_EMAIL_MODE=smtp
- N8N_SMTP_HOST=mail.martireisen.at
- N8N_SMTP_PORT=587
- [email protected]
- N8N_SMTP_PASS=.connect2023
- N8N_SMTP_SSL=true
- WEBHOOK_URL=http://crm.tribus-business.at/
- NODE_OPTIONS=–max-old-space-size=8192
- N8N_DEFAULT_BINARY_DATA_MODE=filesystem
- EXECUTIONS_MODE=queue
links:
- db
- redis
volumes:
- n8n_storage:/home/node/.n8n
- shared-files:/home/tribus/n8n/files
- backup:/data/backup
depends_on:
redis:
condition: service_healthy
db:
condition: service_healthy

services:
db:
image: mariadb:10.7
restart: unless-stopped
environment:
- MARIADB_ROOT_PASSWORD
- MARIADB_DATABASE
- MARIADB_USER
- MARIADB_PASSWORD
- MARIADB_MYSQL_LOCALHOST_USER=true
volumes:
- db_storage:/var/lib/mysql
healthcheck:
test: “/usr/bin/mysql --user=${MARIADB_USER} --password=${MARIADB_PASSWORD} --execute ‘SELECT 1;’”
interval: 10s
timeout: 5s
retries: 10
redis:
image: redis:6-alpine
restart: always
volumes:
- redis_storage:/data
healthcheck:
test: [ ‘CMD’, ‘redis-cli’, ‘ping’ ]
interval: 5s
timeout: 5s
retries: 10

n8n:
<<: *shared
image: n8nio/n8n:0.227.0
command: /bin/sh -c “n8n start --tunnel”
ports:
- 5678:5678

n8n-worker:
<<: *shared
image: n8nio/n8n:0.227.0
command: /bin/sh -c “sleep 5; n8n worker”
depends_on:
- n8n

filebrowser:
image: filebrowser/filebrowser
restart: unless-stopped
volumes:
- shared-files:/srv
- /home/tribus/filebrowser/filebrowser.db:/database.db
ports:
- 10000:80

Hi @nuri_yilmaz, I am so sorry but I don’t think I can follow what exactly you have done here.

Have you recovered an earlier backup as suggested or have you manually moved data between different databases used by different n8n instances? What are you seeing in your server logs? Are you able to read your existing workflows and credentials through the CLI?

New version [email protected] got released which includes the GitHub PR 6591.

I removed the postgres settings and inserted the MariaDB settings again. And I also set the image version to the old image version. I havent yet added the data to the data base from the backups. I wanted to see if I could start the docker containers again (You know, step by step testing if everything works again :D).
The logs dont mention anything about 401.

Logs:

I dont know if it is any help but I discovered that if I disable user management, I wouldnt recive any 401 error anymore. Maybe my Config is just bad for User management? Can this occure if the smtp server config is incorrect? Thank you all for your time and brain power mine already left trying to figure this out :smiley:

1 Like

I don’t think your config is per se bad for user management, though I wonder if there might be anything specific to keep in mind when using queue mode here. Perhaps @krynble knows more on this topic.

When saying migrating everything back to mysql and to a earlier version. I get 401 Unauthorized can you confirm how exactly you migrated back? Did you simply recover an earlier backup or have you manually moved workflows from one instance to the other, perhaps by injecting them directly into the database?

In this case the user IDs of the respective workflow might not match the user IDs on your new instance and it might be worth checking if you can access them with your n8n owner account rather than the regular user account.

Hi, thank you for your help. I’ve managed to figure it out now. It took a long time to resolve an error that seemed to vanish into thin air after reconfiguring the server on our end.

To explain in more detail: I first reverted the Docker file and tried to restart everything from scratch, as if it were a fresh start, just to see if that alone would work. However, I received a 401 Unauthorized error when trying to access the system from my host URL. Interestingly enough, I was able to access and configure everything when using the internal IP address. A few days later, we discovered an error on our end with the configuration of the host URL and the server. After we fixed this issue, everything started to work as expected. I was then able to reload the database, and subsequently upgrade and migrate the data into the new version. So everything is working now.

2 Likes

Amazing, I’m glad to hear you figured it out! Thanks so much for confirming :slight_smile:

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