Bug 412777

Summary: DigiKam+MySQL: Failed to create database tables.
Product: [Applications] digikam Reporter: alexander
Component: Database-MysqlAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED NOT A BUG    
Severity: normal CC: caulier.gilles, metzpinguin
Priority: NOR    
Version First Reported In: 6.3.0   
Target Milestone: ---   
Platform: Appimage   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 6.4.0
Sentry Crash Report:
Attachments: stdout-Output from digiKam AppImage

Description alexander 2019-10-09 17:32:15 UTC
Created attachment 123107 [details]
stdout-Output from digiKam AppImage

SUMMARY
I have a Synology NAS with a MariaDB-Server running MariaDB:latest (currently 10.4.8-MariaDB-1:10.4.8+maria~bionic) from DockerHub (https://hub.docker.com/_/mariadb/) on it.. I have full access from the network. I am using openSUSE Leap 15.1 and tried it with digiKam 6.3.0 (AppImage) as well as 6.0 (from openSUSE's own Leap repositories).

What I do is a fresh install of digiKam, fresh user settings (removed ~/.config/digikamrc/) then start digiKam and fill out the first-run wizard: Add my NAS photos-folder (smb mount via /etc/fstab) and enter the database settings for my MariaDB-Server. 
I created the user and database as is suggested by the First-Run-Wizard of digiKam. Database connection check returns an "OK".
After finishing the wizard, digiKam starts creating tables and then after a few seconds fails with a "table error".

STEPS TO REPRODUCE
1. Start a fresh digikam installation
2. Point Digikam to a directory containing photos
3. Set MySQL as database
4. Enter credentials.
5. Finish Wizard.


OBSERVED RESULT
DigiKam displays an error message and does not correctly initialize the database.

EXPECTED RESULT
MySQL tables get properly initialized and I can start using digiKam.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: openSUSE Leap 15.1
KDE Plasma Version: 5.12.8
KDE Frameworks Version: 5.55.0
Qt Version:  5.9.7

ADDITIONAL INFORMATION

1. max_allowed_packet is configured to 256M.

2. I've attached the stdout-Output from the 6.0.3-AppImage-Version. tail -10 yields:
Digikam::DbEngineConfigSettingsLoader::readConfig: Loading SQL code from config file "/tmp/.mount_digikaJpjI5X/usr/share/digikam/database/dbconfig.xml"
Digikam::DbEngineConfigSettingsLoader::readConfig: Checking XML version ID => expected:  3  found:  3
Digikam::CoreDbSchemaUpdater::update: Core database: running schema update
Digikam::CoreDbSchemaUpdater::startUpdates: Core database: no database file available
Digikam::BdEngineBackendPrivate::debugOutputFailedQuery: Failure executing query:
 ""
Error messages: "QMYSQL: Unable to execute query" "Cannot load from mysql.proc. The table is probably corrupted" "1728" 2
Bound values:  ()
Digikam::BdEngineBackend::execDBAction: Error while executing DBAction [ "CreateIndices" ] Statement [ "\n                    DROP PROCEDURE IF EXISTS create_index_if_not_exists;\n                " ]
Digikam::CoreDbAccess::checkReadyForUse: Core database: cannot process schema initialization

------

3. digiKam apparently managed to create the following tables without errors:

MariaDB [digikam]> show tables;
+--------------------+
| Tables_in_digikam  |
+--------------------+
| AlbumRoots         |
| Albums             |
| DownloadHistory    |
| ImageComments      |
| ImageCopyright     |
| ImageHistory       |
| ImageInformation   |
| ImageMetadata      |
| ImagePositions     |
| ImageProperties    |
| ImageRelations     |
| ImageTagProperties |
| ImageTags          |
| Images             |
| Searches           |
| Settings           |
| TagProperties      |
| Tags               |
| TagsTree           |
| VideoMetadata      |
+--------------------+
20 rows in set (0,00 sec)
Comment 1 caulier.gilles 2019-10-09 17:43:51 UTC
Try again using 6.4.0 pre-release bundle :

https://files.kde.org/digikam/

Gilles Caulier
Comment 2 Maik Qualmann 2019-10-09 17:50:44 UTC
> Error messages: "QMYSQL: Unable to execute query" "Cannot load from mysql.proc. > The table is probably corrupted" "1728" 2

Try:

mysql> REPAIR TABLE mysql.proc;

Maik
Comment 3 Maik Qualmann 2019-10-09 18:12:03 UTC
There is also the possibility that your MariaDB version is too current and a change is not compatible with our function "CreateIndices". I am here even under openSUSE Thumbleweed only at MariaDB-10.3.18.

Maik
Comment 4 alexander 2019-10-10 05:25:38 UTC
(In reply to caulier.gilles from comment #1)
> Try again using 6.4.0 pre-release bundle :
> 
> https://files.kde.org/digikam/
> 
> Gilles Caulier

Still getting this error:
igikam::CoreDbSchemaUpdater::update: Core database: running schema update
Digikam::CoreDbSchemaUpdater::startUpdates: Core database: no database file available
Digikam::BdEngineBackendPrivate::debugOutputFailedQuery: Failure executing query:
 "" 
Error messages: "QMYSQL: Unable to execute query" "Cannot load from mysql.proc. The table is probably corrupted" "1728" 2 
Bound values:  ()
Digikam::BdEngineBackend::execDBAction: Error while executing DBAction [ "CreateIndices" ] Statement [ "\n                    DROP PROCEDURE IF EXISTS create_index_if_not_exists;\n                " ]
Digikam::CoreDbAccess::checkReadyForUse: Core database: cannot process schema initialization
Digikam::KMemoryInfo::update: KMemoryInfo: Platform identified :  "LINUX"
Digikam::KMemoryInfo::bytes: KMemoryInfo: TotalRam:  33650221056
Digikam::LoadingCache::setCacheSize: Allowing a cache size of 200 MB
unknown: QThreadStorage: Thread 0x7f766afee840 exited after QThreadStorage 15 destroyed

and after a restart with
> REPAIR TABLE mysql.proc;

/Apps> ./digikam-6.4.0-git-20191005T120037-x86-64.appimage 
-- digiKam Linux AppImage Bundle
-- Use 'help' as CLI argument to know all available options for digiKam application.
-- Note: to integrate this bundle to your desktop, use AppImageLauncher.
libudev.so.0 
-- Preloading shared libs: 
Digikam::DXmlGuiWindow::setupIconTheme: Breeze icons resource file found
Digikam::DXmlGuiWindow::setupIconTheme: Breeze-dark icons resource file found
Digikam::AlbumWatch::AlbumWatch: AlbumWatch is disabled
Digikam::AlbumManager::setDatabase: Database Parameters:
   Type:                     "QMYSQL"
   DB Core Name:             "digikam"
   DB Thumbs Name:           "digikam"
   DB Face Name:             "digikam"
   DB Similarity Name:       "digikam"
   Connect Options:          ""
   Host Name:                "io"
   Host port:                3306
   Internal Server:          false
   Internal Server Path:     ""
   Internal Server Serv Cmd: ""
   Internal Server Init Cmd: ""
   Username:                 "digikam"
   Password:                 "XXXXXXXXXXXXXXXX"

Digikam::DbEngineConfigSettingsLoader::readConfig: Loading SQL code from config file "/tmp/.mount_digika0blJK9/usr/share/digikam/database/dbconfig.xml"
Digikam::DbEngineConfigSettingsLoader::readConfig: Checking XML version ID => expected:  3  found:  3
Digikam::CoreDbSchemaUpdater::update: Core database: running schema update
Digikam::CoreDbSchemaUpdater::startUpdates: Core database: have a structure version  0
Digikam::CoreDbSchemaUpdater::startUpdates: Core database: version not available! Giving up schema upgrading.
Digikam::CoreDbAccess::checkReadyForUse: Core database: cannot process schema initialization
Digikam::KMemoryInfo::update: KMemoryInfo: Platform identified :  "LINUX"
Digikam::KMemoryInfo::bytes: KMemoryInfo: TotalRam:  33650221056
Digikam::LoadingCache::setCacheSize: Allowing a cache size of 200 MB
unknown: QThreadStorage: Thread 0x7f67332b8840 exited after QThreadStorage 11 destroyed

> There is also the possibility that your MariaDB version is too current and a change is not compatible with our function "CreateIndices". I am here even under openSUSE Thumbleweed only at MariaDB-10.3.18.

Maybe true. digiKam is the only software running on this instance that is experiencing hickups though.
Comment 5 alexander 2019-10-10 05:53:15 UTC
Searching for "corrupted mysql.proc table" told me that I had to run  mysql_upgrade on my database.

That fixed everything. Now digiKam 6.0.0 initialized all tables and runs perfectly :)

Thank your very much for your help and sorry for any inconvenience.