Bug 440030

Summary: Database migration 7.2 -> 7.3 fails
Product: [Applications] digikam Reporter: Jens Westemeier <Jens_Westemeier>
Component: Database-MigrationAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: caulier.gilles, karsten.defreese, KDE, linux, metzpinguin
Priority: NOR    
Version: 7.3.0   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In: 7.4.0
Sentry Crash Report:

Description Jens Westemeier 2021-07-19 08:04:12 UTC
SUMMARY
After update from 7.2 to 7.3 digikam fails to start.
Error message (in my own words): Database migration from version 12 to 13 fails.
Console output:
digikam.coredb: Core database: cannot process schema initialization
QThreadStorage: Thread 0x7f48800722c0 exited after QThreadStorage 13 destroyed

STEPS TO REPRODUCE
1. start digikam 7.3 with a database from 7.2

OBSERVED RESULT
digikam does not start

EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Maik Qualmann 2021-07-19 08:11:08 UTC
Do you use an internal MySQL or an external MySQL database?
Set the debug variable and post the output in the terminal as described here:

https://www.digikam.org/contribute/

Maik
Comment 2 Maik Qualmann 2021-07-19 08:22:38 UTC
If you are using an internal MySQL database read this thread:

https://mail.kde.org/pipermail/digikam-users/2021-July/032471.html

Maik
Comment 3 Jens Westemeier 2021-07-19 09:20:45 UTC
(In reply to Jens Westemeier from comment #0)
> SUMMARY
> After update from 7.2 to 7.3 digikam fails to start.
> Error message (in my own words): Database migration from version 12 to 13
> fails.
> Console output:
> digikam.coredb: Core database: cannot process schema initialization
> QThreadStorage: Thread 0x7f48800722c0 exited after QThreadStorage 13
> destroyed
> 
> STEPS TO REPRODUCE
> 1. start digikam 7.3 with a database from 7.2
> 
> OBSERVED RESULT
> digikam does not start
> 
> EXPECTED RESULT
> 
> 
> SOFTWARE/OS VERSIONS
> Windows: 
> macOS: 
> Linux/KDE Plasma: 
> (available in About System)
> KDE Plasma Version: 
> KDE Frameworks Version: 
> Qt Version: 
> 
> ADDITIONAL INFORMATION
digikam.widgets: Use installed icons
digikam.general: Switch to application font:  QFont(Noto Sans,10,-1,5,50,0,0,0,0,0)
digikam.general: AlbumWatch is disabled
digikam.general: Database Parameters:
   Type:                      "QMYSQL"
   DB Core Name:              "digikam"
   DB Thumbs Name:            "digikam"
   DB Face Name:              "digikam"
   DB Similarity Name:        "digikam"
   Connect Options:           "UNIX_SOCKET=/home/jens/.local/share/digikam/db_misc/mysql.socket"
   Host Name:                 ""
   Host port:                 -1
   Internal Server:           true
   Internal Server Path:      "/home/jens"
   Internal Server Admin Cmd: "mysqladmin"
   Internal Server Serv Cmd:  "/usr/sbin/mysqld"
   Internal Server Init Cmd:  "mysql_install_db"
   Username:                  "root"
   Password:                  ""

digikam.databaseserver: Database Parameters:
   Type:                      "QMYSQL"
   DB Core Name:              "digikam"
   DB Thumbs Name:            "digikam"
   DB Face Name:              "digikam"
   DB Similarity Name:        "digikam"
   Connect Options:           "UNIX_SOCKET=/home/jens/.local/share/digikam/db_misc/mysql.socket"
   Host Name:                 ""
   Host port:                 -1
   Internal Server:           true
   Internal Server Path:      "/home/jens"
   Internal Server Admin Cmd: "mysqladmin"
   Internal Server Serv Cmd:  "/usr/sbin/mysqld"
   Internal Server Init Cmd:  "mysql_install_db"
   Username:                  "root"
   Password:                  ""

digikam.databaseserver: Internal Server data path: "/home/jens/.mysql.digikam/db_data"
digikam.databaseserver: The mysql configuration was already up-to-date: "/home/jens/.local/share/digikam/mysql.conf"
digikam.databaseserver: Database server: "/usr/sbin/mysqld" ("--defaults-file=/home/jens/.local/share/digikam/mysql.conf", "--datadir=/home/jens/.mysql.digikam/db_data", "--socket=/home/jens/.local/share/digikam/db_misc/mysql.socket")
digikam.databaseserver: Internal database server started
digikam.databaseserver: Running 0 seconds...
digikam.dbengine: Loading SQL code from config file "/usr/share/digikam/database/dbconfig.xml"
digikam.dbengine: Checking XML version ID => expected:  3  found:  3
digikam.coredb: Core database: running schema update
digikam.coredb: Core database: have a structure version  12
digikam.coredb: Core database: makeUpdates  12  to  13
digikam.dbengine: Failure executing query:
 "" 
Error messages: "QMYSQL: Die Abfrage konnte nicht ausgeführt werden" "Column count of mysql.proc is wrong. Expected 21, found 20. Created with MariaDB 100229, now running 100510. Please use mariadb-upgrade to fix this error" "1558" 2 
Bound values:  ()
digikam.dbengine: Error while executing DBAction [ "UpdateSchemaFromV12ToV13" ] Statement [ "\n                    DROP PROCEDURE IF EXISTS create_index_if_not_exists;\n                " ]
digikam.coredb: Core database: schema update to V 13 failed!
digikam.coredb: Core database: cannot process schema initialization
digikam.general: KMemoryInfo: Platform identified :  "LINUX"
digikam.general: KMemoryInfo: TotalRam:  16628625408
digikam.general: Allowing a cache size of 400 MB
digikam.databaseserver: Shutting down database server
digikam.databaseserver: Internal database server stopped
QThreadStorage: Thread 0x7f151c77a2c0 exited after QThreadStorage 13 destroyed
Comment 4 Jens Westemeier 2021-07-19 09:28:28 UTC
(In reply to Maik Qualmann from comment #2)
> If you are using an internal MySQL database read this thread:
> 
> https://mail.kde.org/pipermail/digikam-users/2021-July/032471.html
> 
> Maik

mariadb-upgrade --socket=/home/jens/.local/share/digikam/db_misc/
Version check failed. Got the following error when calling the 'mysql' command line client
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/home/jens/.local/share/digikam/db_misc/' (111)
FATAL ERROR: Upgrade failed
Comment 5 Jens Westemeier 2021-07-19 09:30:35 UTC
rpm -qa | grep mariadb
mariadb-10.5.10-1.1.x86_64
mariadb-client-10.5.10-1.1.x86_64
libmariadb3-3.1.13-2.1.x86_64
mariadb-errormessages-10.5.10-1.1.noarch
Comment 6 Jens Westemeier 2021-07-19 09:51:11 UTC
Started old version digikam 7.2. With that the database server existed.
Run 
mariadb-upgrade --socket=/home/jens/.local/share/digikam/db_misc/mysql.socket
After that digikam 7.3 worked. Problem solved
Comment 7 Jens Westemeier 2021-07-19 09:52:31 UTC
Thanks!
Comment 8 Maik Qualmann 2021-07-25 13:46:03 UTC
Git commit 49ee18fbf2220baedbc015f51b74f67930115287 by Maik Qualmann.
Committed on 25/07/2021 at 13:44.
Pushed by mqualmann into branch 'master'.

perform a database upgrade if the server / database version is different
Related: bug 440212
FIXED-IN: 7.4.0

M  +2    -0    NEWS
M  +126  -3    core/libs/database/server/databaseserver.cpp
M  +5    -0    core/libs/database/server/databaseserver.h

https://invent.kde.org/graphics/digikam/commit/49ee18fbf2220baedbc015f51b74f67930115287
Comment 9 Maik Qualmann 2021-08-04 15:51:08 UTC
*** Bug 440590 has been marked as a duplicate of this bug. ***
Comment 10 Maik Qualmann 2021-08-05 06:42:33 UTC
We do not yet receive the correct database version in the current patch ...

Maik
Comment 11 Maik Qualmann 2021-08-06 21:10:15 UTC
Git commit fb89a81a60da6a37ddb23ddcd316b9525452b3e9 by Maik Qualmann.
Committed on 06/08/2021 at 21:08.
Pushed by mqualmann into branch 'master'.

check mysql.err file for a database upgrade
FIXED-IN: 7.4.0

M  +18   -5    core/libs/database/coredb/coredbschemaupdater.cpp
M  +31   -69   core/libs/database/server/databaseserver.cpp
M  +8    -3    core/libs/database/server/databaseserver.h

https://invent.kde.org/graphics/digikam/commit/fb89a81a60da6a37ddb23ddcd316b9525452b3e9
Comment 12 Maik Qualmann 2021-10-27 16:58:11 UTC
*** Bug 444479 has been marked as a duplicate of this bug. ***