Bug 248287 - 'akonadictl stop' takes very long + doesn't terminate all 'mysqld' processes
Summary: 'akonadictl stop' takes very long + doesn't terminate all 'mysqld' processes
Status: RESOLVED UNMAINTAINED
Alias: None
Product: Akonadi
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 1.4.0
Platform: Gentoo Packages Linux
: NOR major
Target Milestone: ---
Assignee: Volker Krause
URL:
Keywords:
: 302193 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-08-18 20:26 UTC by Elias Probst
Modified: 2018-02-01 09:45 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Output of 'akonadictl stop' (81.16 KB, text/plain)
2010-08-18 21:05 UTC, Elias Probst
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Elias Probst 2010-08-18 20:26:16 UTC
Version:           1.4.0 (using KDE 4.5.0) 
OS:                Linux

When running 'akonadictl stop', it takes around 30 seconds to shutdown Akonadi.
Furthermore, there's always a 'mysqld' process like this left:


 3966 ?        Sl     3:38 /usr/sbin/mysqld --defaults-file=/home/elias/.local/share/akonadi//mysql.conf --datadir /home/elias/.local/share/akonadi/db_data/ --socket=/home/elias/.local/share/akonadi/db_misc/mysql.socket

The strange thing about this is: this process can be easily terminated by sending a SIGTERM (kill $PID).


Reproducible: Always

Steps to Reproduce:
- Remove all Akonadi related configuration from your homedir
- Create a new Akonadi configuration from scratch
- Add some resources (2 IMAP, 1 CalDAV, 1 VCF-File)
- Shutdown Akonadi

Actual Results:  
It takes very long to shutdown Akonadi.
There is nearly no disk activity (HDD LED + iotop) during the shutdown.
Not all mysqld processes are terminated.

Expected Results:  
The shutdown takes only some seconds.
All mysqld processes are terminated correctly.
Comment 1 Elias Probst 2010-08-18 21:05:55 UTC
Created attachment 50707 [details]
Output of 'akonadictl stop'

When running 'akonadictl start' and 'akonadictl stop' afterwards on a terminal, a lot of output is created when running 'akonadictl stop'.
The whole shutdown process ends with a backtrace due to a crash.

There are messages like:
ProcessControl: Application '/usr/bin/akonadi_imap_resource' stopped unexpected (Process crashed)
Application '/usr/bin/akonadi_imap_resource' crashed. No restart!

or:
[akonadiserver] "Cannot connect to agent instance with identifier 'akonadi_imap_resource_1', error message: 'Could not get owner of name 'org.freedesktop.Akonadi.Resource.akonadi_imap_resource_1': no such name'"
[akonadiserver] processing retrieval request for item 50092  parts: ("RFC822")  of resource: "akonadi_imap_resource_1"

The full output is attached.
Comment 2 Elias Probst 2010-08-18 21:07:02 UTC
Changed to 'crash' as the previously attached output looks like, Akonadi is crashing on shutdown.
Comment 3 Sergio Martins 2011-09-13 10:06:49 UTC
Paste a backtrace ( and try new version of akonadi/kdepim )
Comment 4 Sergio Martins 2011-09-13 10:21:51 UTC
Reopened, and removed "CRASH". The crash part is fixed now.
The slowdown is not fixed.
Comment 5 Elias Probst 2011-09-14 06:18:11 UTC
I consider this to be fixed now (KDEPIM 4.7.1).
Shutting down Akonadi even when it is just synching a newly added IMAP account takes around 20 seconds.

The only strange thing: during shutdown, it seems that some of the agents crash, as they appear as '<defunct>' in the process listing:

elias@moria ~ % ps aux | grep akon
elias     5714  0.0  0.0 138868  5356 ?        Sl   08:11   0:00 /usr/bin/akonadi_control
elias     5718  0.6  0.1 325220  9948 ?        Sl   08:11   0:01 akonadiserver
elias     5720  0.9  0.7 357324 42672 ?        Sl   08:11   0:02 /usr/sbin/mysqld --defaults-file=/home/elias/.local/share/akonadi//mysql.conf --datadir=/home/elias/.local/share/akonadi/db_data/ --socket=/home/elias/.local/share/akonadi/socket-moria/mysql.socket
elias     5753  0.1  0.0      0     0 ?        Z    08:11   0:00 [akonadi_gcal_re] <defunct>
elias     5754  0.1  0.0      0     0 ?        Z    08:11   0:00 [akonadi_googled] <defunct>
elias     5760  0.0  0.0      0     0 ?        Z    08:11   0:00 [akonadi_nepomuk] <defunct>
elias     5766  0.0  0.0      0     0 ?        Z    08:11   0:00 [akonadi_agent_l] <defunct>
elias     5844  1.2  0.6 474944 39176 ?        Sl   08:12   0:03 /usr/bin/akonadi_imap_resource --identifier akonadi_imap_resource_3
Comment 6 Elias Probst 2011-09-14 06:22:41 UTC
(In reply to comment #5)
> The only strange thing: during shutdown, it seems that some of the agents
> crash, as they appear as '<defunct>' in the process listing:
There are also messages indicating a crash in the akonadiserver output:
void Akonadi::NotificationSource::unsubscribe() "akonadi_davgroupware_resource_0" 
ProcessControl: Application '/usr/bin/akonadi_agent_launcher' stopped unexpected (Process crashed)
Application '/usr/bin/akonadi_agent_launcher' crashed. No restart!
Lost connection to resource "org.freedesktop.Akonadi.Resource.akonadi_maildir_resource_0" , discarding cached interface 
void Akonadi::NotificationSource::serviceUnregistered(const QString&) Notification source "AkonadiAgentServer" now serving: () 
void Akonadi::NotificationSource::unsubscribe() "AkonadiAgentServer" 
Lost connection to resource "org.freedesktop.Akonadi.Resource.akonadi_googledata_resource_0" , discarding cached interface 
void Akonadi::NotificationSource::serviceUnregistered(const QString&) Notification source "akonadi_googledata_resource_0" now serving: ()

What's the easiest way to get a backtrace of these processes?
Comment 7 Christophe Marin 2011-09-14 08:49:34 UTC
One day we'll fix this report title (there's only one mysqld process), anyway:

(In reply to comment #5)
> I consider this to be fixed now (KDEPIM 4.7.1).
> Shutting down Akonadi even when it is just synching a newly added IMAP account
> takes around 20 seconds.

I cannot agree. That highly depends on the resources activity when akonadictl stop is executed. Reproducing is easy: run "check mail" with several imap accounts configured and run akonadictl stop and look at the akonadiserver activity:

With a few imap resources :

[cut]
akonadi_imap_resource_6(28179)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
akonadi_imap_resource_6(28179)/libakonadi Akonadi::CollectionSync::Private::execute: void Akonadi::CollectionSync::Private::execute() localListDone:  false  deliveryDone:  true

(repeated for each imap resource)

QProcess: Destroyed while process is still running.
Lost connection to resource "org.freedesktop.Akonadi.Resource.akonadi_imap_resource_7" , discarding cached interface 
void Akonadi::NotificationSource::serviceUnregistered(const QString&) Notification source "akonadi_imap_resource_7" now serving: () 
void Akonadi::NotificationSource::unsubscribe() "akonadi_imap_resource_7" 
ProcessControl: Application '/kde/inst/kdepim-runtime/bin/akonadi_imap_resource' stopped unexpectedly (Process crashed)
Application '/kde/inst/kdepim-runtime/bin/akonadi_imap_resource' crashed. No restart!
Application '/kde/inst/kdepim-runtime/bin/akonadi_imap_resource' exited normally...
Application '/kde/inst/akonadi/bin/akonadi_agent_launcher' exited normally...
Application '/kde/inst/akonadi/bin/akonadi_agent_launcher' exited normally...
Application '/kde/inst/akonadi/bin/akonadi_agent_launcher' exited normally...
Application '/kde/inst/akonadi/bin/akonadi_agent_launcher' exited normally...
Application '/kde/inst/akonadi/bin/akonadi_agent_launcher' exited normally...
Application '/kde/inst/kdepim-runtime/bin/akonadi_nepomuk_calendar_feeder' exited normally...
Application '/kde/inst/kdepim/bin/akonadi_nepomuk_email_feeder' exited normally...
Application '/kde/inst/kdepim-runtime/bin/akonadi_davgroupware_resource' exited normally...
Application '/kde/inst/kdepim-runtime/bin/akonadi_nepomuk_contact_feeder' exited normally...
Application '/kde/inst/kdepim-runtime/bin/akonadi_maildispatcher_agent' exited normally...

but the mail check goes on..

[cut]
akonadi_imap_resource_2(28175)/kdepimlibs (kimap) RetrieveCollectionMetadataTask::doStart: Not refreshing because of timestamp
akonadi_imap_resource_2(28175)/kdepimlibs (kimap) RetrieveCollectionMetadataTask::doStart: "/INBOX"
akonadi_imap_resource_2(28175)/kdepimlibs (kimap) RetrieveCollectionMetadataTask::doStart: Not refreshing because of timestamp
akonadi_imap_resource_2(28175)/kdepimlibs (kimap) RetrieveCollectionMetadataTask::doStart: "/Drafts"
akonadi_imap_resource_2(28175)/kdepimlibs (kimap) RetrieveCollectionMetadataTask::doStart: Not refreshing because of timestamp
akonadi_imap_resource_2(28175)/kdepimlibs (kimap) RetrieveCollectionMetadataTask::doStart: "/kde-commits"
[cut]

and at some point, the Akonadi server is fed up and starts killing the processes that didn't stop in a reasonable time

QProcess: Destroyed while process is still running.
Lost connection to resource "org.freedesktop.Akonadi.Resource.akonadi_imap_resource_0" , discarding cached interface 
void Akonadi::NotificationSource::serviceUnregistered(const QString&) Notification source "akonadi_imap_resource_0" now serving: () 
void Akonadi::NotificationSource::unsubscribe() "akonadi_imap_resource_0" 
ProcessControl: Application '/kde/inst/kdepim-runtime/bin/akonadi_imap_resource' stopped unexpectedly (Process crashed)
Application '/kde/inst/kdepim-runtime/bin/akonadi_imap_resource' crashed. No restart!

etc..
Comment 8 Daniel Vrátil 2013-03-02 21:03:17 UTC
*** Bug 302193 has been marked as a duplicate of this bug. ***
Comment 9 Martin Steigerwald 2015-01-28 08:57:01 UTC
Except the mysqld process (this is with Akonadi 1.13 master git branch with database optimizations and KDEPIM + Runtime 4.14.2 as packages in Debian unstable):

ms@merkaba:~> akonadictl stop                  
Akonadi is not running. 
ms@merkaba:~#4> akonadictl status                
Akonadi Control: stopped
Akonadi Server: stopped
search paths:  ("/usr/local/lib/kde4", "/home/ms/.kde/lib/kde4/plugins/", "/usr/lib/kde4/plugins/", "/usr/local/lib/plugins/", "/usr/lib/x86_64-linux-gnu/qt4/plugins", "/usr/local/bin", "/usr/lib/kde4/plugins", "/usr/local/lib/plugins", "/home/ms/.kde/lib/kde4/", "/usr/lib/kde4/") 
Akonadi Server Search Support: available (Remote Search, Akonadi Baloo Search Plugin)
Available Agent Types: akonadi_akonotes_resource, akonadi_archivemail_agent, akonadi_baloo_indexer, akonadi_birthdays_resource, akonadi_contacts_resource, akonadi_davgroupware_resource, akonadi_folderarchive_agent, akonadi_followupreminder_agent, akonadi_googlecalendar_resource, akonadi_googlecontacts_resource, akonadi_ical_resource, akonadi_icaldir_resource, akonadi_imap_resource, akonadi_invitations_agent, akonadi_kabc_resource, akonadi_kalarm_dir_resource, akonadi_kalarm_resource, akonadi_kcal_resource, akonadi_kdeaccounts_resource, akonadi_knut_resource, akonadi_kolab_resource, akonadi_kolabproxy_resource, akonadi_localbookmarks_resource, akonadi_maildir_resource, akonadi_maildispatcher_agent, akonadi_mailfilter_agent, akonadi_mailtransport_dummy_resource, akonadi_mbox_resource, akonadi_migration_agent, akonadi_mixedmaildir_resource, akonadi_nepomuk_feeder, akonadi_newmailnotifier_agent, akonadi_nntp_resource, akonadi_notes_agent, akonadi_notes_resource, akonadi_openxchange_resource, akonadi_pop3_resource, akonadi_sendlater_agent, akonadi_vcard_resource, akonadi_vcarddir_resource
ms@merkaba:~> ps aux | grep "[m]ysql" | grep ms
ms        4006  0.4  3.8 2809592 631456 ?      Sl   Jan27   6:26 /usr/sbin/mysqld --defaults-file=/home/ms/.local/share/akonadi/mysql.conf --datadir=/home/ms/.local/share/akonadi/db_data/ --socket=/tmp/akonadi-ms.QEKpW0/mysql.socket

After minutes after issuing akonadictl stop:

ms@merkaba:~> ps aux | grep "[m]ysql" | grep ms
ms        4006  0.4  3.8 2809592 631456 ?      Sl   Jan27   6:27 /usr/sbin/mysqld --defaults-file=/home/ms/.local/share/akonadi/mysql.conf --datadir=/home/ms/.local/share/akonadi/db_data/ --socket=/tmp/akonadi-ms.QEKpW0/mysql.socket

And look when I start it again:

ms@merkaba:~> ps aux | grep "[m]ysql" | grep ms
ms        4006  0.4  3.8 2809592 632112 ?      Sl   Jan27   6:40 /usr/sbin/mysqld --defaults-file=/home/ms/.local/share/akonadi/mysql.conf --datadir=/home/ms/.local/share/akonadi/db_data/ --socket=/tmp/akonadi-ms.QEKpW0/mysql.socket
ms       29368  1.0  0.5 787196 85964 ?        Sl   09:54   0:00 /usr/sbin/mysqld --defaults-file=/home/ms/.local/share/akonadi/mysql.conf --datadir=/home/ms/.local/share/akonadi/db_data/ --socket=/tmp/akonadi-ms.QEKpW0/mysql.socket


This is a *huge*, *big* *no-go*. At no point of time Akonadi should there *ever* be *two* instances of MySQL running for the same user and the *same* database.

As this bug is about the stopping of Akonadi I will file a new bug about having two instances of MySQL running. From all I know this just is a very, very bad idea.
Comment 10 Martin Steigerwald 2015-01-28 08:58:18 UTC
Ah, I reported this already:

Bug 340813 - sometimes two copies of mysqld are running with Akonadi (edit)

adding to it.
Comment 11 Denis Kurz 2017-06-23 20:00:09 UTC
This bug has never been confirmed for a KDE PIM version that is based on KDE Frameworks (5.x). Those versions differ significantly from the old 4.x series. Therefore, I plan to close it in around two or three months. In the meantime, it is set to WAITINGFORINFO to give reporters the oportunity to check if it is still valid. As soon as someone confirms it for a recent version (at least 5.1, ideally even more recent), I'll gladly reopen it.

Please understand that we lack the manpower to triage bugs reported for versions almost two years beyond their end of life.
Comment 12 Denis Kurz 2018-02-01 09:45:53 UTC
Just as announced in my last comment, I close this bug. If you encounter it again in a recent version (at least 5.1 aka 15.12; preferably much more recent), please open a new one unless it already exists. Thank you for all your input.