Bug 472125

Summary: Connections to remote mariadb are aborted when digikam is closed
Product: [Applications] digikam Reporter: Paul Worrall <p.r.worrall>
Component: Database-MysqlAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: minor CC: metzpinguin
Priority: NOR    
Version First Reported In: 8.1.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 8.2.0
Sentry Crash Report:

Description Paul Worrall 2023-07-10 11:19:11 UTC
SUMMARY
Using digiKam with a maria database on a remote device, when I close digiKam a set of warning messages appear in the journal of the remote device saying "error reading communication packets".

STEPS TO REPRODUCE
1. Configure digiKam to use a mariadb on a remote device, and monitor the journal on that device (journalctl -f)
2. Launch digiKam (no journal messages)
3. Close digiKam either by closing the window or selecting Browse->Quit
4. Wait a few seconds

OBSERVED RESULT
Example warning messages:
Jul 10 12:06:47 b3 mariadbd[622]: 2023-07-10 12:06:47 4118 [Warning] Aborted connection 4118 to db: 'digikamThumbs' user: 'paul' host: 'fe80::779b:c418:de09:7b29%eth0' (Got an error reading communication packets)
Jul 10 12:06:47 b3 mariadbd[622]: 2023-07-10 12:06:47 4121 [Warning] Aborted connection 4121 to db: 'digikamCore' user: 'paul' host: 'fe80::779b:c418:de09:7b29%eth0' (Got an error reading communication packets)
Jul 10 12:06:47 b3 mariadbd[622]: 2023-07-10 12:06:47 4117 [Warning] Aborted connection 4117 to db: 'digikamCore' user: 'paul' host: 'fe80::779b:c418:de09:7b29%eth0' (Got an error reading communication packets)
Jul 10 12:06:47 b3 mariadbd[622]: 2023-07-10 12:06:47 4119 [Warning] Aborted connection 4119 to db: 'digikamCore' user: 'paul' host: 'fe80::779b:c418:de09:7b29%eth0' (Got an error reading communication packets)
Jul 10 12:06:47 b3 mariadbd[622]: 2023-07-10 12:06:47 4120 [Warning] Aborted connection 4120 to db: 'digikamThumbs' user: 'paul' host: 'fe80::779b:c418:de09:7b29%eth0' (Got an error reading communication packets)
Jul 10 12:06:47 b3 mariadbd[622]: 2023-07-10 12:06:47 4122 [Warning] Aborted connection 4122 to db: 'digikamThumbs' user: 'paul' host: 'fe80::779b:c418:de09:7b29%eth0' (Got an error reading communication packets)

EXPECTED RESULT
No dodgy looking messages

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.27.6
KDE Frameworks Version: 5.108.0
Qt Version: 5.15.10
Graphics Platform: Wayland

ADDITIONAL INFORMATION
Comment 1 Maik Qualmann 2023-07-10 20:11:02 UTC
Git commit bff94845113399790f631f22e5adfce677ca6839 by Maik Qualmann.
Committed on 10/07/2023 at 20:09.
Pushed by mqualmann into branch 'master'.

hold only the connection name in the QThreadStorage
FIXED-IN: 8.2.0

M  +1    -1    NEWS
M  +37   -27   core/libs/database/engine/dbenginebackend.cpp
M  +7    -7    core/libs/database/engine/dbenginebackend_p.h

https://invent.kde.org/graphics/digikam/-/commit/bff94845113399790f631f22e5adfce677ca6839
Comment 2 Maik Qualmann 2023-07-10 20:15:31 UTC
Thanks for reporting this bug. Although we correctly closed all databases and removed connections. When the database was in QThreadStorage, even though we destroyed it with a new QSQLDatabase(), it still kept a connection.

Maik