authelia: mysql: error: storage error loading authelia due to schema collation change

Version

v4.37.0

Deployment Method

Docker

Reverse Proxy

SWAG

Reverse Proxy Version

No response

Description

Trying to start Authelia errors out, and naturally none of the containers I protect with Authelia are usable/accessible.

Reproduction

All I did was pull the latest Authelia image.

Expectations

No response

Logs

From the log:


time="2022-10-23T02:16:06-05:00" level=warning msg="Configuration: configuration key 'server.read_buffer_size' is deprecated in 4.36.0 and has been replaced by 'server.buffers.read': this has been automatically mapped for you but you will need to adjust your configuration to remove this message"
time="2022-10-23T02:16:06-05:00" level=warning msg="Configuration: configuration key 'server.write_buffer_size' is deprecated in 4.36.0 and has been replaced by 'server.buffers.write': this has been automatically mapped for you but you will need to adjust your configuration to remove this message"
time="2022-10-23T02:16:06-05:00" level=warning msg="Configuration: configuration key 'authentication_backend.disable_reset_password' is deprecated in 4.36.0 and has been replaced by 'authentication_backend.password_reset.disable': this has been automatically mapped for you but you will need to adjust your configuration to remove this message"
time="2022-10-23T02:16:06-05:00" level=info msg="Authelia v4.37.0 is starting"
time="2022-10-23T02:16:06-05:00" level=info msg="Log severity set to debug"
{"level":"debug","msg":"Registering client [oc]-portainer with policy two_factor (2)","time":"2022-10-23T02:16:06-05:00"}
{"level":"info","msg":"Storage schema is being checked for updates","time":"2022-10-23T02:16:06-05:00"}
{"level":"info","msg":"Storage schema migration from 5 to 6 is being attempted","time":"2022-10-23T02:16:06-05:00"}
{"level":"error","msg":"Failure running the storage provider startup check: error during schema migrate: error applying migration version 6 to version 5 for rollback: schema migration 6 (ConsentPreConfiguration) failed: Error 1051: Unknown table 'authelia.oauth2_authorization_code_session'. rollback caused by: schema migration 6 (ConsentPreConfiguration) failed: Error 3780: Referencing column 'subject' and referenced column 'identifier' in foreign key constraint 'oauth2_consent_preconfiguration_subjct_fkey' are incompatible.","stack":[{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":277,"Name":"doStartupChecks"},{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":87,"Name":"cmdRootRun"},{"File":"github.com/spf13/cobra@v1.6.0/command.go","Line":920,"Name":"(*Command).execute"},{"File":"github.com/spf13/cobra@v1.6.0/command.go","Line":1040,"Name":"(*Command).ExecuteC"},{"File":"github.com/spf13/cobra@v1.6.0/command.go","Line":968,"Name":"(*Command).Execute"},{"File":"github.com/authelia/authelia/v4/cmd/authelia/main.go","Line":10,"Name":"main"},{"File":"runtime/proc.go","Line":250,"Name":"main"},{"File":"runtime/asm_amd64.s","Line":1594,"Name":"goexit"}],"time":"2022-10-23T02:16:06-05:00"}
{"level":"debug","msg":"Notifier SMTP client attempting connection to smtp.gmail.com:465","time":"2022-10-23T02:16:06-05:00"}
{"level":"debug","msg":"Notifier SMTP client using submissions port 465. Make sure the mail server you are connecting to is configured for submissions and not SMTPS.","time":"2022-10-23T02:16:06-05:00"}
{"level":"debug","msg":"Notifier SMTP client connected successfully","time":"2022-10-23T02:16:06-05:00"}
{"level":"debug","msg":"Notifier SMTP connection is already encrypted, skipping STARTTLS","time":"2022-10-23T02:16:06-05:00"}
{"level":"debug","msg":"Notifier SMTP server supports authentication with the following mechanisms: LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH","time":"2022-10-23T02:16:06-05:00"}
{"level":"debug","msg":"Notifier SMTP client attempting AUTH PLAIN with server","time":"2022-10-23T02:16:06-05:00"}
{"level":"debug","msg":"Notifier SMTP client authenticated successfully with the server","time":"2022-10-23T02:16:06-05:00"}
{"level":"fatal","msg":"The following providers had fatal failures during startup: storage","stack":[{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":305,"Name":"doStartupChecks"},{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":87,"Name":"cmdRootRun"},{"File":"github.com/spf13/cobra@v1.6.0/command.go","Line":920,"Name":"(*Command).execute"},{"File":"github.com/spf13/cobra@v1.6.0/command.go","Line":1040,"Name":"(*Command).ExecuteC"},{"File":"github.com/spf13/cobra@v1.6.0/command.go","Line":968,"Name":"(*Command).Execute"},{"File":"github.com/authelia/authelia/v4/cmd/authelia/main.go","Line":10,"Name":"main"},{"File":"runtime/proc.go","Line":250,"Name":"main"},{"File":"runtime/asm_amd64.s","Line":1594,"Name":"goexit"}],"time":"2022-10-23T02:16:07-05:00"}


### Configuration

_No response_

### Documentation

_No response_

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 23 (15 by maintainers)

Most upvoted comments

This should be solved in #4262, would appreciate some users to test it. Instructions:

  1. Read all instructions in this post before starting anything.
  2. Required: Make a backup of the SQL database including both the schema and the database rows. This will have a high chance of breaking your database.
  3. All data added to the database after the test should be considered lost.
  4. The docker image name is authelia\authelia:fix-sql-inconsistencies.
  5. After you’ve verified it works/doesn’t work:
    1. Required: Stop the container.
    2. Required: Restore your SQL Backup.
    3. Report your findings.

Alternative to the required steps is dropping ALL tables in the database if support is required at any stage in the future.

Important notes:

  1. Going forward Authelia will continue to only provide official support for versions of databases which are currently in either standard or long term support cycles with their respective developers. This means:
    1. Authelia will not officially support MySQL 5.x in October of 2023 so you should upgrade to the 8.x branch before then as Oracle is dropping support then.
    2. Authelia will not officially support deprecated MySQL/MariaDB/PostgreSQL configurations such as having MyISAM as the default engine.
  2. Going forward Authelia will only support the following when using MySQL or MariaDB:
    1. The InnoDB Engine, as it is the only engine available in MySQL/MariaDB that is partially ACID compliant.
    2. The utf8mb4 charset.
    3. The utf8mb4_unicode_520_ci collation.
    4. Minimum index size supported is 2048 bytes for an index of the webauthn_devices tables kid column which is a VARCHAR(512) or 512 chars by 4 bytes.
    5. The explicit_defaults_for_timestamp setting being enabled as when it is not enabled it uses a deprecated time setting that is NOT ANSI standard.

@newkindofworld unrelated. Open a new issue.

Edit: actually your issue is not a bug, it’s a error in your config, open a discussion if you can’t figure it out.