Bug 341297

Summary: Crashes on return from hibernation overnight
Product: [Applications] kmymoney Reporter: Gary <gfkde>
Component: databaseAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: RESOLVED FIXED    
Severity: crash CC: onet.cristian, ralf.habacker
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In: 4.8.1,5.0.0
Sentry Crash Report:

Description Gary 2014-11-26 17:19:36 UTC
Running version 4.6.4 on Windows 7 using the Windows installer, using the mysql database version running apache/php/mysql (xampp) on localhost (rather than a remote server).  My computer (desktop pc) hibernates if unused for 4+ hours using the Windows powersave option.  If I leave KMM open overnight, it always crashes when I try to use it in the morning.  Once the program restarts, it's fine and runs normally.

Reproducible: Always

Steps to Reproduce:
1. Use the program, leave it open overnight
2. When I return in the next morning, click on the program.  Screen is visible and my information is there, but program is unresponsive.
3. After a few minutes, I get an error message saying the program must restart.

Actual Results:  
I get the following error message:

Error in function void __thiscall MyMoneyStorageSql::close(bool) : starting commit unit Driver = QMYSQL, Host = localhost, User = root, Database = KMyMoney Driver Error: QMYSQL: Unable to begin transaction Database Error No 2006: MySQL server has gone away Text: MySQL server has gone away QMYSQL: Unable to begin transaction Error type 2 Executed: Query error No -1: Driver not loaded Driver not loaded Error type 1 void __thiscall MyMoneyStorageSql::close(bool) in file e:\r\build\extragear\kmymoney-4.6.1-20110918\work\kmymoney-4.6.4\kmymoney\mymoney\storage\mymoneystoragesql.cpp line 870

Expected Results:  
Allow me to use the program without crashing.

I run a fairly basic version of apache/mysql/php using the xampp (php vers 5.4.27, mysql 5.0.10.
Comment 1 Cristian OneČ› 2015-04-06 11:07:16 UTC
To the devs, looking at MyMoneyStorageSql::close it seems that the logoff transaction is created only when QSqlDatabase::isOpen() returns true, so it seems that QSqlDatabase::isOpen() might return true even in case the DB went away, should we catch and ignore transactions in this place?
Comment 2 Alvaro Soliverez 2015-04-06 11:48:36 UTC
I'd say it should try to restore the database connection if it finds such a case. If unable to do so, then yes, it should quit without trying to enter any transaction.
Comment 3 Ralf Habacker 2017-06-28 22:56:02 UTC
This can easily be reproduced with the following steps:

1. start kmymoney
2. open a mysql database
3. stop mysql server
Comment 4 Ralf Habacker 2017-06-29 20:24:46 UTC
Git commit a0433f9cb0f4657ff195f3de37a7d4c1f385b444 by Ralf Habacker.
Committed on 29/06/2017 at 19:58.
Pushed by habacker into branch '4.8'.

Fix 'Crashes on return from hibernation overnight (edit)'.

Enabled mysql reconnect option.
FIXED-IN:4.8.1

M  +1    -0    kmymoney/mymoney/storage/mymoneystoragesql.cpp

https://commits.kde.org/kmymoney/a0433f9cb0f4657ff195f3de37a7d4c1f385b444