NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.78k stars 13.89k forks source link

Akonadi Does Not Work #160145

Closed MarekPasnikowski closed 2 years ago

MarekPasnikowski commented 2 years ago

Description

I apologize for the dreaded title type, but nothing else describes the problem I have.

I follow the master branch of nixpkgs with my system flake configuration. Yesterday, I decided to install KMail. I entered kmail in my list of system applications and rebuilt the system. The application itself works ... except for the Akonadi program. Which means KMail is useless.

I then proceeded to search the internet for anything that could make Akonadi start properly and nothing worked. Even more suspiciously, there are no recent reports of broken Akonadi on NixOS. The most significant potential problem with my configuration would be its purity as it is built from a flake.

Path Forward

I am not able to think of anything, that I could immediately post as supporting information. How can I even begin to help explore this problem? I am completely in the dark when it comes to KDE troubleshooting.

Maintainers

@ttuegel @vandenoever @nyanloutre

eliasp commented 2 years ago

What's the output of?:

MarekPasnikowski commented 2 years ago
$ akonadictl status
Akonadi Control: stopped
Akonadi Server: stopped
Akonadi Server Search Support: available (Remote Search)
Available Agent Types: akonadi_akonotes_resource, akonadi_archivemail_agent, akonadi_birthdays_resource, akonadi_contacts_resource, akonadi_davgroupware_resource, akonadi_ews_resource, akonadi_ewsmta_resource, akonadi_followupreminder_agent, akonadi_google_resource, akonadi_ical_resource, akonadi_icaldir_resource, akonadi_imap_resource, akonadi_kalarm_dir_resource, akonadi_kalarm_resource, akonadi_knut_resource, akonadi_maildir_resource, akonadi_maildispatcher_agent, akonadi_mailfilter_agent, akonadi_mailmerge_agent, akonadi_mbox_resource, akonadi_migration_agent, akonadi_mixedmaildir_resource, akonadi_newmailnotifier_agent, akonadi_notes_resource, akonadi_openxchange_resource, akonadi_pop3_resource, akonadi_sendlater_agent, akonadi_tomboynotes_resource, akonadi_unifiedmailbox_agent, akonadi_vcard_resource, akonadi_vcarddir_resource
$ akonadictl start --verbose
org.kde.pim.akonadictl: Starting Akonadi Server...
QSocketNotifier: Can only be used with threads started with QThread
org.kde.pim.akonadicontrol: Service org.freedesktop.Akonadi.Control.lock already registered, terminating now.
Error: akonadi_control was started but didn't register at D-Bus session bus.
Make sure your system is set up correctly!
eliasp commented 2 years ago

This feels like a problem with your session's D-Bus instance - something I've seen a few years ago, where legacy startup scripts start a D-Bus instance, then systemd's user-session instance also registers as session D-Bus...

Some services are activated via D-Bus, some via systemd's D-Bus…

Are there existing Akonadi processes around?

pgrep -U ${USER} -ai akonadi

Is there another D-Bus instance around not cooperating with systemd?

pgrep -U ${USER} -ai dbus
MarekPasnikowski commented 2 years ago

I did have KMail open during the previous commands.

$ pgrep -U ${USER} -ai akonadi
31212 /nix/store/0zim6afca3ni22mvliikzpm73kziqyar-akonadi-21.12.2/bin/akonadi_control
31214 /nix/store/0zim6afca3ni22mvliikzpm73kziqyar-akonadi-21.12.2/bin/akonadiserver
$ pgrep -U ${USER} -ai dbus
1674 /nix/store/1bjb1viyvci75xbayy1a56nw0s2n7rzc-dbus-1.12.20/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
1826 /nix/store/47whwsyq8zgfjdfc9w6my5zpy4aijq4w-plasma-workspace-5.23.5/bin/gmenudbusmenuproxy
3370 /run/current-system/sw/bin/dbus-daemon --syslog --fork --print-pid 5 --print-address 7 --session

After that, I closed KMail and forcefully terminated all processes related to Akonadi in System Monitor (including a mysqld process).

$ pgrep -U ${USER} -ai akonadi
$ pgrep -U ${USER} -ai dbus
1674 /nix/store/1bjb1viyvci75xbayy1a56nw0s2n7rzc-dbus-1.12.20/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
1826 /nix/store/47whwsyq8zgfjdfc9w6my5zpy4aijq4w-plasma-workspace-5.23.5/bin/gmenudbusmenuproxy
3370 /run/current-system/sw/bin/dbus-daemon --syslog --fork --print-pid 5 --print-address 7 --session
eliasp commented 2 years ago
$ pgrep -U ${USER} -ai dbus
1674 /nix/store/1bjb1viyvci75xbayy1a56nw0s2n7rzc-dbus-1.12.20/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
1826 /nix/store/47whwsyq8zgfjdfc9w6my5zpy4aijq4w-plasma-workspace-5.23.5/bin/gmenudbusmenuproxy
3370 /run/current-system/sw/bin/dbus-daemon --syslog --fork --print-pid 5

Just as I suspected, there are 2 competing D-Bus instances around. The one with --address=systemd:, which is started by and cooperates with systemd - and the one with --syslog --fork --print-pid 5.

MarekPasnikowski commented 2 years ago
  • How do you start your X session?

services . xserver . displayManager . defaultSession = "plasmawayland"

  • Do you use services.xserver.desktopManager.plasma5.runUsingSystemd = true; in your NixOS configuration?

During my blind attempts to find a solution I did enable the option and left it enabled, because it changed nothing.

  • Do you have any custom application starts in your ~/.{profile,bashrc,zshrc,...}?

KDE System Settings Autorun lists "PulseEffects" and "EasyEffects".

I never edit the *rc and profile files.

eliasp commented 2 years ago

Then it'd be interesting to know, what's the parent process of the "lone D-Bus instance": ps -f -p $(ps -o ppid= -p 3370) (where 3370 is the PID of said D-Bus instance)

MarekPasnikowski commented 2 years ago
$ ps -f -p $(ps -o ppid= -p 3370)
UID          PID    PPID  C STIME TTY          TIME CMD
marek       1638       1  0 lut15 ?        00:00:00 /nix/store/24ljibki63lxk0m11qnw8fh9smh64g3x-systemd-249.7/lib/systemd/systemd --user
eliasp commented 2 years ago

Now this is really weird… What does systemctl --user status 3370 say? Do you have custom old units present in ~/.config/systemd/user?

MarekPasnikowski commented 2 years ago
$ systemctl --user status 3370
● app-org.kde.konsole-18bf8b4358014e47bb34c9f29fafe9da.scope - Konsola - Terminal
     Loaded: loaded (/run/current-system/sw/share/applications/org.kde.konsole.desktop; transient)
  Transient: yes
     Active: active (running) since Tue 2022-02-15 11:38:34 CET; 12h ago
      Tasks: 18 (limit: 36007)
     Memory: 2.0G
        CPU: 1min 667ms
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/app-org.kde.konsole-18bf8b4358014e47bb34c9f29fafe9da.scope
             ├─ 3167 /run/current-system/sw/bin/konsole
             ├─ 3370 /run/current-system/sw/bin/dbus-daemon --syslog --fork --print-pid 5 --print-address 7 --session
             ├─ 3638 /run/current-system/sw/bin/bash
             ├─74895 systemctl --user status 3370
             └─74896 less

lut 15 12:09:39 obikawa-acer sudo[6916]:    marek : TTY=pts/1 ; PWD=/home/marek/Git/system ; USER=root ; COMMAND=/run/current-system/sw/bin/nice -n 19 nixos-rebu>
lut 15 12:09:39 obikawa-acer sudo[6916]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)
lut 15 12:09:42 obikawa-acer sudo[6916]: pam_unix(sudo:session): session closed for user root
lut 15 12:11:17 obikawa-acer sudo[7128]:    marek : TTY=pts/1 ; PWD=/home/marek/Git/system ; USER=root ; COMMAND=/run/current-system/sw/bin/nice -n 19 nixos-rebu>
lut 15 12:11:17 obikawa-acer sudo[7128]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)
lut 15 12:11:50 obikawa-acer sudo[7128]: pam_unix(sudo:session): session closed for user root
lut 15 23:41:38 obikawa-acer sudo[70345]: pam_unix(sudo:auth): authentication failure; logname= uid=1000 euid=0 tty=/dev/pts/1 ruser=marek rhost=  user=marek
lut 15 23:41:42 obikawa-acer sudo[70345]:    marek : TTY=pts/1 ; PWD=/home/marek/Git/system ; USER=root ; COMMAND=/run/current-system/sw/bin/cpupower frequency-s>
lut 15 23:41:42 obikawa-acer sudo[70345]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)
lut 15 23:41:42 obikawa-acer sudo[70345]: pam_unix(sudo:session): session closed for user root

No ~/.config/systemd/ directory.

eliasp commented 2 years ago

This is really weird.... I expected some legacy script/application to be responsible to spawning the rogue dbus-daemon, but I can't really make sense of this - as if there's something in your ~/.bashrc/~/.bash_profile which causes dbus-daemon to start even though there's already the other (properly started) instance.

Does akonadictl start work properly, if you kill all Akonadi-related processes and this conflicting dbus-daemon? (Keep in mind, that this is only temporary for better understanding the situation, you might be back to square one after restarting your session).

MarekPasnikowski commented 2 years ago

Two observations:

  1. I first started KMail and it spawned a new dbus process after I had killed the previous extra. Akonadi failed like always.
  2. There is progress when I cleaned the processes and started just akonadi.
[marek@obikawa-acer:~]$ akonadictl start --verbose
org.kde.pim.akonadictl: Starting Akonadi Server...
QSocketNotifier: Can only be used with threads started with QThread
org.kde.pim.akonadictl:    done.
Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)

[marek@obikawa-acer:~]$ org.kde.pim.akonadiserver: Starting up the Akonadi Server...
org.kde.pim.akonadiserver: Found mysql_install_db:  "/nix/store/8sw0fqxh0968ndarm2dlpv4pzasxlv8f-mariadb-server-10.6.5/bin/mysql_install_db"
org.kde.pim.akonadiserver: Found mysqlcheck:  "/nix/store/8sw0fqxh0968ndarm2dlpv4pzasxlv8f-mariadb-server-10.6.5/bin/mysqlcheck"
org.kde.pim.akonadiserver: Using mysqld: "/nix/store/8sw0fqxh0968ndarm2dlpv4pzasxlv8f-mariadb-server-10.6.5/bin/mysqld"
org.kde.pim.akonadiserver: mysqld reports version 10.6.5 (MariaDB)
org.kde.pim.akonadiserver: Found a mysqld pid file, checking whether the server is still running...
org.kde.pim.akonadiserver: No mysqld process with specified PID is running. Removing the pidfile and starting a new instance...
org.kde.pim.akonadiserver: Executing: "/nix/store/8sw0fqxh0968ndarm2dlpv4pzasxlv8f-mariadb-server-10.6.5/bin/mysqld" "--defaults-file=/home/marek/.local/share/akonadi/mysql.conf --datadir=/home/marek/.local/share/akonadi/db_data/ --socket=/run/user/1000/akonadi/mysql.socket --pid-file=/run/user/1000/akonadi/mysql.pid"
org.kde.pim.akonadiserver: Executing:  "/nix/store/8sw0fqxh0968ndarm2dlpv4pzasxlv8f-mariadb-server-10.6.5/bin/mysqlcheck" "--defaults-file=/home/marek/.local/share/akonadi/mysql.conf --check-upgrade --auto-repair --socket=/run/user/1000/akonadi/mysql.socket akonadi"
org.kde.pim.akonadicontrol: Service "org.kde.systemmonitor" owner changed from ":1.164" to ""
org.kde.pim.akonadicontrol: Service "org.kde.systemmonitor" owner changed from "" to ":1.169"
org.kde.pim.akonadicontrol: Service "org.kde.systemmonitor" owner changed from ":1.169" to ""

EDIT:

Afterwards, I tried KMail again. And again, it led to creation of a new dbus process ( I just realized, that it was reported as zombie, and its parent was 1674; and finally, after looking again it disappeared. ) KMail is still dysfunctional regardless of anything.

MarekPasnikowski commented 2 years ago

160516 is the real issue here. I downgraded my kernel to the default version and now KMail works as expected.

I will leave the decision to close the issue to maintainers.

ajs124 commented 2 years ago

@Obikawa are you also running btrfs? Because I cannot seem to reproduce this with the nixos tests.

MarekPasnikowski commented 2 years ago

@ajs124 Yes, I do run BTRFS.

ajs124 commented 2 years ago

Ok, then let's close this in favor of #160516