authelia: 4.37.3: MySQL/MariaDB: Storage Error/Corrupt DB error on improperly upgraded engine

Fix

https://github.com/authelia/authelia/issues/4519#issuecomment-1343297516

Cause

https://github.com/authelia/authelia/issues/4519#issuecomment-1343398206

Version

v4.37.3

Deployment Method

Docker

Reverse Proxy

SWAG

Reverse Proxy Version

No response

Description

I get this error upgrading from 4.37.2 to 4.37.3:

{“level”:“info”,“msg”:“Storage schema migration from 6 to 7 is being attempted”,“time”:“2022-12-08T09:23:52-05:00”} {“level”:“error”,“msg”:“Failure running the storage provider startup check: error during schema migrate: error applying migration version 7 to version 6 for rollback: schema migration 7 (ConsistencyFixes) failed: Error 1728 (HY000): Cannot load from mysql.proc. The table is probably corrupted. rollback caused by: schema migration 7 (ConsistencyFixes) failed: Error 1728 (HY000): Cannot load from mysql.proc. The table is probably corrupted”,“stack”:[{“File”:“github.com/authelia/authelia/v4/internal/commands/root.go”,“Line”:281,“Name”:“doStartupChecks”},{“File”:“github.com/authelia/authelia/v4/internal/commands/root.go”,“Line”:87,“Name”:“cmdRootRun”},{“File”:“github.com/spf13/cobra@v1.6.1/command.go”,“Line”:920,“Name”:“(*Command).execute”},{“File”:“github.com/spf13/cobra@v1.6.1/command.go”,“Line”:1044,“Name”:“(*Command).ExecuteC”},{“File”:“github.com/spf13/cobra@v1.6.1/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-12-08T09:23:52-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”:309,“Name”:“doStartupChecks”},{“File”:“github.com/authelia/authelia/v4/internal/commands/root.go”,“Line”:87,“Name”:“cmdRootRun”},{“File”:“github.com/spf13/cobra@v1.6.1/command.go”,“Line”:920,“Name”:“(*Command).execute”},{“File”:“github.com/spf13/cobra@v1.6.1/command.go”,“Line”:1044,“Name”:“(*Command).ExecuteC”},{“File”:“github.com/spf13/cobra@v1.6.1/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-12-08T09:23:52-05:00”}

I thought maybe my DB (MariaDB) was corrupted so I dropped the DB (I have backups) and let authelia re-set it up on the new update, exact same issue, so I know its not a corrupt DB.

Reproduction

Use MariaDB, clean install, set up a DB called “authelia” and assign a user to it. Set up the DB in the authelia config, and start it up using version 4.37.2. Everything works. Upgrade to 4.37.3, it crashes, drop all DB tables, and start authelia with version 4.37.3, still crashes.

Expectations

No response

Configuration (Authelia)

#                   Authelia configuration                    #
###############################################################

jwt_secret: "xxx"
default_redirection_url: https://xxx/

server:
  host: 0.0.0.0
  port: 9091
  buffers.read: 4096
  buffers.write: 4096
  path: "authelia"

log:
  level: info
  format: json
  file_path: /config/log/authelia.log
  keep_stdout: false

totp:
  issuer: xxx
  period: 30
  skew: 1

ntp:
  address: "time.cloudflare.com:123"
  version: 4
  max_desync: 1s
  disable_startup_check: false
  disable_failure: false

authentication_backend:
  password_reset.disable: true
  refresh_interval: 5m
  file:
    path: /config/users_database.yml
    password:
      algorithm: xxx
      iterations: 1
      key_length: 32
      salt_length: 16
      memory: 1024
      parallelism: 8

access_control:
  default_policy: two_factor
  networks:
  - name: xxx
    networks:
      - 'xxx'
  - name: xxx
    networks:
      - 'xxx/xx'
  rules:
  - domain: [xxx]
    policy: bypass
  - domain: 'xxx'
    policy: bypass
    networks:
      - 'xxx'
      - 'xxx'
  - domain: 'xxx'
    policy: two_factor

session:
  name: authelia_session
  secret: "xxx"
  expiration: 1h
  inactivity: 5m
  remember_me_duration: 1M
  domain: xxx
  redis:
    host: xxx
    port: 6379
    password: "xxx"
    database_index: 0
    maximum_active_connections: 8
    minimum_idle_connections: 0

regulation:
  max_retries: 3
  find_time: 2m
  ban_time: 2w

storage:
  encryption_key: "xxx"
  mysql:
    host: xxx
    port: 3306
    database: authelia
    username: authelia
    password: "xxx"
    timeout: 5s

notifier:
  disable_startup_check: true
  smtp:
    username: xxx
    password: "xxx"
    host: xxx
    port: 587
    sender: xxx
    identifier: xxx
    subject: "[xxx] {title}"
    startup_check_address: xxx
    disable_require_tls: false
    disable_html_emails: false
    tls:
      server_name: xxx
      skip_verify: false
      minimum_version: TLS1.2

Logs (Authelia)

{"level":"info","msg":"Shutting down","time":"2022-12-08T09:39:04-05:00"}
{"error":"bad connection","level":"error","msg":"Error occurred closing the database connection","stack":[{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":197,"Name":"runServices"},{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":89,"Name":"cmdRootRun"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":920,"Name":"(*Command).execute"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":1044,"Name":"(*Command).ExecuteC"},{"File":"github.com/spf13/cobra@v1.6.1/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-12-08T09:39:04-05:00"}
{"level":"info","msg":"Storage schema is being checked for updates","time":"2022-12-08T09:39:05-05:00"}
{"level":"info","msg":"Storage schema migration from 6 to 7 is being attempted","time":"2022-12-08T09:39:05-05:00"}
{"level":"error","msg":"Failure running the storage provider startup check: error during schema migrate: error applying migration version 7 to version 6 for rollback: schema migration 7 (ConsistencyFixes) failed: Error 1728 (HY000): Cannot load from mysql.proc. The table is probably corrupted. rollback caused by: schema migration 7 (ConsistencyFixes) failed: Error 1728 (HY000): Cannot load from mysql.proc. The table is probably corrupted","stack":[{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":281,"Name":"doStartupChecks"},{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":87,"Name":"cmdRootRun"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":920,"Name":"(*Command).execute"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":1044,"Name":"(*Command).ExecuteC"},{"File":"github.com/spf13/cobra@v1.6.1/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-12-08T09:39:05-05:00"}
{"level":"debug","msg":"notification provider: startup check skipped as it is disabled","time":"2022-12-08T09:39:05-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":309,"Name":"doStartupChecks"},{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":87,"Name":"cmdRootRun"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":920,"Name":"(*Command).execute"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":1044,"Name":"(*Command).ExecuteC"},{"File":"github.com/spf13/cobra@v1.6.1/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-12-08T09:39:05-05:00"}
{"level":"info","msg":"Storage schema is being checked for updates","time":"2022-12-08T09:39:05-05:00"}
{"level":"info","msg":"Storage schema migration from 6 to 7 is being attempted","time":"2022-12-08T09:39:05-05:00"}
{"level":"error","msg":"Failure running the storage provider startup check: error during schema migrate: error applying migration version 7 to version 6 for rollback: schema migration 7 (ConsistencyFixes) failed: Error 1728 (HY000): Cannot load from mysql.proc. The table is probably corrupted. rollback caused by: schema migration 7 (ConsistencyFixes) failed: Error 1728 (HY000): Cannot load from mysql.proc. The table is probably corrupted","stack":[{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":281,"Name":"doStartupChecks"},{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":87,"Name":"cmdRootRun"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":920,"Name":"(*Command).execute"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":1044,"Name":"(*Command).ExecuteC"},{"File":"github.com/spf13/cobra@v1.6.1/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-12-08T09:39:05-05:00"}
{"level":"debug","msg":"notification provider: startup check skipped as it is disabled","time":"2022-12-08T09:39:05-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":309,"Name":"doStartupChecks"},{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":87,"Name":"cmdRootRun"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":920,"Name":"(*Command).execute"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":1044,"Name":"(*Command).ExecuteC"},{"File":"github.com/spf13/cobra@v1.6.1/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-12-08T09:39:05-05:00"}
{"level":"info","msg":"Storage schema is being checked for updates","time":"2022-12-08T09:39:06-05:00"}
{"level":"info","msg":"Storage schema migration from 6 to 7 is being attempted","time":"2022-12-08T09:39:06-05:00"}
{"level":"error","msg":"Failure running the storage provider startup check: error during schema migrate: error applying migration version 7 to version 6 for rollback: schema migration 7 (ConsistencyFixes) failed: Error 1728 (HY000): Cannot load from mysql.proc. The table is probably corrupted. rollback caused by: schema migration 7 (ConsistencyFixes) failed: Error 1728 (HY000): Cannot load from mysql.proc. The table is probably corrupted","stack":[{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":281,"Name":"doStartupChecks"},{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":87,"Name":"cmdRootRun"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":920,"Name":"(*Command).execute"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":1044,"Name":"(*Command).ExecuteC"},{"File":"github.com/spf13/cobra@v1.6.1/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-12-08T09:39:06-05:00"}
{"level":"debug","msg":"notification provider: startup check skipped as it is disabled","time":"2022-12-08T09:39: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":309,"Name":"doStartupChecks"},{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":87,"Name":"cmdRootRun"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":920,"Name":"(*Command).execute"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":1044,"Name":"(*Command).ExecuteC"},{"File":"github.com/spf13/cobra@v1.6.1/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-12-08T09:39:06-05:00"}
{"level":"info","msg":"Storage schema is being checked for updates","time":"2022-12-08T09:39:07-05:00"}
{"level":"info","msg":"Storage schema migration from 6 to 7 is being attempted","time":"2022-12-08T09:39:07-05:00"}
{"level":"error","msg":"Failure running the storage provider startup check: error during schema migrate: error applying migration version 7 to version 6 for rollback: schema migration 7 (ConsistencyFixes) failed: Error 1728 (HY000): Cannot load from mysql.proc. The table is probably corrupted. rollback caused by: schema migration 7 (ConsistencyFixes) failed: Error 1728 (HY000): Cannot load from mysql.proc. The table is probably corrupted","stack":[{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":281,"Name":"doStartupChecks"},{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":87,"Name":"cmdRootRun"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":920,"Name":"(*Command).execute"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":1044,"Name":"(*Command).ExecuteC"},{"File":"github.com/spf13/cobra@v1.6.1/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-12-08T09:39:07-05:00"}
{"level":"debug","msg":"notification provider: startup check skipped as it is disabled","time":"2022-12-08T09:39:07-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":309,"Name":"doStartupChecks"},{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":87,"Name":"cmdRootRun"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":920,"Name":"(*Command).execute"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":1044,"Name":"(*Command).ExecuteC"},{"File":"github.com/spf13/cobra@v1.6.1/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-12-08T09:39:07-05:00"}
{"level":"info","msg":"Storage schema is being checked for updates","time":"2022-12-08T09:39:08-05:00"}
{"level":"info","msg":"Storage schema migration from 6 to 7 is being attempted","time":"2022-12-08T09:39:08-05:00"}
{"level":"error","msg":"Failure running the storage provider startup check: error during schema migrate: error applying migration version 7 to version 6 for rollback: schema migration 7 (ConsistencyFixes) failed: Error 1728 (HY000): Cannot load from mysql.proc. The table is probably corrupted. rollback caused by: schema migration 7 (ConsistencyFixes) failed: Error 1728 (HY000): Cannot load from mysql.proc. The table is probably corrupted","stack":[{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":281,"Name":"doStartupChecks"},{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":87,"Name":"cmdRootRun"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":920,"Name":"(*Command).execute"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":1044,"Name":"(*Command).ExecuteC"},{"File":"github.com/spf13/cobra@v1.6.1/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-12-08T09:39:08-05:00"}
{"level":"debug","msg":"notification provider: startup check skipped as it is disabled","time":"2022-12-08T09:39:08-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":309,"Name":"doStartupChecks"},{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":87,"Name":"cmdRootRun"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":920,"Name":"(*Command).execute"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":1044,"Name":"(*Command).ExecuteC"},{"File":"github.com/spf13/cobra@v1.6.1/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-12-08T09:39:08-05:00"}
{"level":"info","msg":"Storage schema is being checked for updates","time":"2022-12-08T09:39:10-05:00"}
{"level":"info","msg":"Storage schema migration from 6 to 7 is being attempted","time":"2022-12-08T09:39:10-05:00"}
{"level":"error","msg":"Failure running the storage provider startup check: error during schema migrate: error applying migration version 7 to version 6 for rollback: schema migration 7 (ConsistencyFixes) failed: Error 1728 (HY000): Cannot load from mysql.proc. The table is probably corrupted. rollback caused by: schema migration 7 (ConsistencyFixes) failed: Error 1728 (HY000): Cannot load from mysql.proc. The table is probably corrupted","stack":[{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":281,"Name":"doStartupChecks"},{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":87,"Name":"cmdRootRun"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":920,"Name":"(*Command).execute"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":1044,"Name":"(*Command).ExecuteC"},{"File":"github.com/spf13/cobra@v1.6.1/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-12-08T09:39:10-05:00"}
{"level":"debug","msg":"notification provider: startup check skipped as it is disabled","time":"2022-12-08T09:39:10-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":309,"Name":"doStartupChecks"},{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":87,"Name":"cmdRootRun"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":920,"Name":"(*Command).execute"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":1044,"Name":"(*Command).ExecuteC"},{"File":"github.com/spf13/cobra@v1.6.1/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-12-08T09:39:10-05:00"}
{"level":"info","msg":"Storage schema is being checked for updates","time":"2022-12-08T09:39:13-05:00"}
{"level":"info","msg":"Storage schema migration from 6 to 7 is being attempted","time":"2022-12-08T09:39:13-05:00"}
{"level":"error","msg":"Failure running the storage provider startup check: error during schema migrate: error applying migration version 7 to version 6 for rollback: schema migration 7 (ConsistencyFixes) failed: Error 1728 (HY000): Cannot load from mysql.proc. The table is probably corrupted. rollback caused by: schema migration 7 (ConsistencyFixes) failed: Error 1728 (HY000): Cannot load from mysql.proc. The table is probably corrupted","stack":[{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":281,"Name":"doStartupChecks"},{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":87,"Name":"cmdRootRun"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":920,"Name":"(*Command).execute"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":1044,"Name":"(*Command).ExecuteC"},{"File":"github.com/spf13/cobra@v1.6.1/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-12-08T09:39:13-05:00"}
{"level":"debug","msg":"notification provider: startup check skipped as it is disabled","time":"2022-12-08T09:39:13-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":309,"Name":"doStartupChecks"},{"File":"github.com/authelia/authelia/v4/internal/commands/root.go","Line":87,"Name":"cmdRootRun"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":920,"Name":"(*Command).execute"},{"File":"github.com/spf13/cobra@v1.6.1/command.go","Line":1044,"Name":"(*Command).ExecuteC"},{"File":"github.com/spf13/cobra@v1.6.1/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-12-08T09:39:13-05:00"}

Logs (Proxy / Application)

No response

Documentation

No response

Pre-Submission Checklist

  • I agree to follow the Code of Conduct
  • This is a bug report and not a support request
  • I have read the security policy and this bug report is not a security issue or security related issue
  • I have either included the complete configuration file or I am sure it’s unrelated to the configuration
  • I have provided all of the required information in full with the only alteration being reasonable sanitization in accordance with the Troubleshooting Sanitization reference guide
  • I have checked for related proxy or application logs and included them if available
  • I have checked for related issues and checked the documentation

About this issue

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

Most upvoted comments

I had the same problem. After a short search for “Cannot load from mysql.proc” i tried $ mysql_upgrade -u root -p in the mariadb docker console. After that the error was gone.

Important Additional Notes: Both the MySQL and MariaDB documentation recommend backups BEFORE executing mysql_upgrade or mariadb_upgrade. We recommend the same.

For reference this likely occurs under the following conditions:

  • MySQL/MariaDB (container/package/etc, not the authelia schema) are upgraded from version a to version b without running mysql_upgrade which is required by the MySQL documentation and MariaDB documentation.
  • MySQL/MariaDB seems to allow starting when the data for the inbuilt mysql table is invalid.
  • This unexpectedly under some circumstances prevents the u se of the MySQL/MariaDB CREATE PROCEDURE command without returning an error.

Authelia:

  • Cannot upgrade this for you.
  • Does not cause this issue. It is caused by automatically upgrading your database engine (i.e. your MySQL/MariaDB container) without following the appropriate procedure which should be documented in their release notes or general documentation.

The short of it is that MySQL/MariaDB has a system schema which stores metadata about the other schemas in the database. This schema has a specific engine type, charsets, tables, etc. If they change this schema between versions (usually major versions, I’d guess), then this needs to be upgraded like described in https://github.com/authelia/authelia/issues/4519#issuecomment-1343297516 by running mysql_upgrade with the appropriate MySQL/MariaDB credentials.

Possible fixes to prevent this in the future:

  1. Use a better good database engine like PostgreSQL or decent database engine like SQLite3.
  2. Use MySQL/MariaDB:
    1. Don’t upgrade MySQL/MariaDB automatically.
    2. Don’t upgrade MySQL/MariaDB and ignore the upgrade instructions, i.e. without using the mysql_upgrade command.
    3. Definitely NEVER automatically upgrade MySQL/MariaDB when the upgrade is not a patch release (x.y.z where a changed z, and unchanged x and unchanged y indicates a patch release).

Exactly the same issue for me on Unraid, fixed using https://github.com/authelia/authelia/issues/4519#issuecomment-1343297516 from @uisgebach.

This fixed it for me! Not sure why LSIO MariaDB isn’t doing this on update, I might submit a feature request to them. Thanks again for tracking this down…really helpful.

just confirmed same error, i got that its not authelia but MariaDB issue after updated , strange but its the first time happening in my case …

It is because the changes they make internally that require mysql_upgrade seem to only affect specific features, in this case using the CREATE PROCEDURE or CALL statements as the table mysql.proc was not upgraded/created (and it’s the first time we used these statements).

Edit: It’s our recommendation (and probably the recommendation of most people informed) that users never automatically upgrade the database server, and that if they do so that they only upgrade the patch version. i.e. if they’re on MariaDB 10.10.2 they pin their database to 10.10 or 10.10.2, and when 10.11.0 or 11.0.0 comes out they manually upgrade (regardless if they use MySQL, MariaDB, or PostgreSQL).

We can discuss migration/performance here so users who have this issue are not distracted unnecessarily: https://github.com/authelia/authelia/discussions/4523

I’ve updated the post regarding the cause here (as there was confusion): https://github.com/authelia/authelia/issues/4519#issuecomment-1343398206

I’ve also clearly outlined the fact that running mysql_upgrade after updating your MySQL/MariaDB container/package is REQUIRED by the MySQL/MariaDB developers, users who upgrade automatically will continue to have issues if they neglect this step regardless of what application is using their database (neglecting this step is not supported by MySQL or MariaDB and will not be supported by Authelia). This is here: https://www.authelia.com/reference/integrations/database-integrations/#upgrades