Bug 453570 - activitymanagerd created database which took 80 GB in file system
Summary: activitymanagerd created database which took 80 GB in file system
Status: ASSIGNED
Alias: None
Product: plasma-activities
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.93.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Ivan Čukić
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-09 09:50 UTC by Piotr Mierzwinski
Modified: 2023-10-16 15:29 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
lsof_kactivitymanagerd.txt (20.70 KB, text/plain)
2022-05-11 21:16 UTC, Piotr Mierzwinski
Details
another lsof output for the wal file (69.61 KB, text/plain)
2022-05-12 22:38 UTC, John
Details
Actitivies application crash (11.46 KB, text/vnd.kde.kcrash-report)
2022-05-12 22:39 UTC, John
Details
lsof_kactivitymanagerd_20220516 (102.32 KB, text/plain)
2022-05-16 22:09 UTC, Piotr Mierzwinski
Details
lsof_kactivitymanagerd_20220518 (23.18 KB, text/plain)
2022-05-18 22:16 UTC, Piotr Mierzwinski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Mierzwinski 2022-05-09 09:50:42 UTC
SUMMARY
Seems daemon activitymanagerd doesn't check if there is any free space in file system only creates its files no matter how this space is available.
Yesterday (or today early morning, to be detailed) I experienced no free space on my home directory. 
No any warning was shown, what expected in that case, only I discovered that in folder ~/.local/share/kactivitymanagerd/resources file database-wal got size over 80 GB, and this took whole available space in partition. I found 0 bytes available

$ pwd
~/.local/share/kactivitymanagerd/resources/
$ ls -lh
total 80G
drwxr-xr-x 2 piotra piotra 4.0K 21.04.2022 09:30 test-backup/
drwxr-xr-x 2 piotra piotra 4.0K 21.04.2022 09:30 working-backup/
-rw-r--r-- 1 piotra users   12M 09.05.2022 00:54 database
-rw-r--r-- 1 piotra piotra 158M 09.05.2022 02:30 database-shm
-rw-r--r-- 1 piotra piotra  80G 09.05.2022 02:38 database-wal

To fix this issue I removed all 3 files. And because these files were used by working process, space in file system wasn't released, to do this I just killed plasma session and restored files from directory "working-backup/"

I have 3 activities and additionally 1 as stopped. One is my working activity where I have usually opened several windows, in second I have 1 window opened (Dolphin)  and third I have 3 opened applications (Firefox, KDevelop, and konsole).

I System Settings I have checked following options:
"Activities -> Switching: Current virtual desktop: Remember for each activity (needs restart)"
and
"Activities -> Privacy: Keep history: Forever"
"Activities -> Privacy: Remember opened documents: For all applications"

I suppose that this issue happened just because option:  "keep history: forever"
Only the strange thing is that, database increased so much in couple days. At April 21st file "database-wal" had _only_ 415K (check below). I don't know what data collects this file what caused creating huge file after couple days. Since several year as I use KDE/Plasma this didn't happen me never.

$ pwd
~/.local/share/kactivitymanagerd/resources/working-backup
$ ls -lh
total 12M
-rw-r--r-- 1 piotra piotra  11M 21.04.2022 09:30 database
-rw-r--r-- 1 piotra piotra  32K 21.04.2022 09:30 database-shm
-rw-r--r-- 1 piotra piotra 415K 21.04.2022 09:30 database-wal


Would be nice if any notification would happen, just warning about huge database and suggesting "cleaning history", if the reason is like I supposed.


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.24.5
KDE Frameworks Version: 5.93
Qt Version: 5.15.3
Comment 1 Ivan Čukić 2022-05-09 15:24:46 UTC
The wal file is sqlite's write-ahead log. It should never grow that much. Will see what can be done about it. In the early days, sqlite gave us a few headaches, but nothing recently. Esp nothing of this magnitude... :/

As for the notification, the default plasma setup notifies on low space on any hard drive.
Comment 2 Piotr Mierzwinski 2022-05-10 22:06:53 UTC
(In reply to Ivan Čukić from comment #1)
> The wal file is sqlite's write-ahead log. It should never grow that much.
> Will see what can be done about it. In the early days, sqlite gave us a few
> headaches, but nothing recently. Esp nothing of this magnitude... :/

Never should grow that much, but in fact I met such huge file, what described.
Maybe there is an option in configuration of sqlite which limits size of log file, if so then would be nice to set it.

> As for the notification, the default plasma setup notifies on low space on
> any hard drive.
Yes, and thanks that I found out about the problem. As I said I got 0 free space on /home. I had to do investigation to find out what took so much space in my home partition.  Very helpful was Filelight.
Saying about notification I meant watching side of mentioned file, but if is possible to limits this file in different way then of course this is not necessary.
Comment 3 Ivan Čukić 2022-05-11 09:13:37 UTC
> Never should grow that much, but in fact I met such huge file, what described.

Yes, I believe you, just meant to say that this is really unexpected. On a properly working sqlite, WAL should not be bigger than the DB itself. :)

Do you use anything out of the ordinary which might keep the database locked so that WAL can not be flushed? Or some uncommon plasma applets, or strange filesystems (NFS being a common problem)?

Does the following return anything other than plasmashell, kactivitymanagerd?

lsof | grep /home/YOUR_USER_NAME/.local/share/kactivitymanagerd/resources/database


> Maybe there is an option in configuration of sqlite which limits size of log file,
> if so then would be nice to set it.

There is, but it doesn't really do anything. There is some work on a new WAL system, but that doesn't help us now.
Comment 4 Piotr Mierzwinski 2022-05-11 21:15:57 UTC
(In reply to Ivan Čukić from comment #3)
> > Never should grow that much, but in fact I met such huge file, what described.
> 
> Yes, I believe you, just meant to say that this is really unexpected. On a
> properly working sqlite, WAL should not be bigger than the DB itself. :)
> 
> Do you use anything out of the ordinary which might keep the database locked
> so that WAL can not be flushed? Or some uncommon plasma applets, or strange
> filesystems (NFS being a common problem)?

Since some time (couple months) I use the same stuff in my system. And for sure nothing not ordinary I didn't use between April 21st (when wal file had normal size) and day when file became huge. If you know some application or plasma applet which could cause the problem tell me please I will verify all I use.
I didn't install nothing new since couple moths. I can provide you the list of applications I usually use and what applets working in my Plasma session everyday since several months.
I use NFS file system since long time. By this filesystem I mount my resources placed in Synology server.
I'm not sure if this will be helpful here, but they are not always mounted correctly when system starts. I mean that one day all is mounted find and another nothing mounted. I don't know what this depend on. I use such command in /etc/fstab
ds214plus:/volume1/my_disk              /home/piotra/My_Disk nfs rsize=8192,wsize=8192,timeo=14,intr,nosuid
BTW. Today nothing was mounted, but I don't see nothing not ordinary in wal file. Its size looks like below:

-rw-r--r-- 1 piotra piotra  11M 11.05.2022 09:37 database
-rw-r--r-- 1 piotra piotra  32K 11.05.2022 09:37 database-shm
-rw-r--r-- 1 piotra piotra 1.5M 11.05.2022 09:37 database-wal

> Does the following return anything other than plasmashell, kactivitymanagerd?
> 
> lsof | grep
> /home/YOUR_USER_NAME/.local/share/kactivitymanagerd/resources/database
I found only "plasmashe" and "kactivity". Detailed result in attached file.
Comment 5 Piotr Mierzwinski 2022-05-11 21:16:37 UTC
Created attachment 148747 [details]
lsof_kactivitymanagerd.txt
Comment 6 John 2022-05-12 22:38:00 UTC
I have been experiencing the same issue. The wal file grows to 200GB+ end doesn't stop until my disk is full. Furthermore, I the settings/activities app is crashing now so I cannot change the history options. I will attach my own `lsof` output as well, plus the crash report for the "Activities" app, in case that helps
Comment 7 John 2022-05-12 22:38:49 UTC
Created attachment 148784 [details]
another lsof output for the wal file
Comment 8 John 2022-05-12 22:39:48 UTC
Created attachment 148785 [details]
Actitivies application crash
Comment 9 Piotr Mierzwinski 2022-05-16 22:08:48 UTC
And today issue happened again.
Again found notification that my home partition has no free space. Opened folder: ~/.local/share/kactivitymanagerd/resources/ and of course found huge database-wal file. Check my result of ls:
$ ls -lh
total 77G
drwxr-xr-x 2 piotra piotra 4.0K 16.05.2022 20:35 test-backup/
drwxr-xr-x 2 piotra piotra 4.0K 09.05.2022 09:24 working-backup/
-rw-r--r-- 1 piotra piotra  12M 16.05.2022 20:36 database
-rw-r--r-- 1 piotra piotra 153M 16.05.2022 23:44 database-shm
-rw-r--r-- 1 piotra piotra  77G 16.05.2022 23:45 database-wal

Below please find version of sqlite I have installed:
$ pacman -Q | grep sqlite
lib32-sqlite 3.37.0-1
mopidy-local-sqlite 1.0.0-1
sqlite 3.38.5-1

@Ivan
Do you think  that downgrade of sqlite could help in this case?

In attachment please find result of lsof command.
Comment 10 Piotr Mierzwinski 2022-05-16 22:09:28 UTC
Created attachment 148900 [details]
lsof_kactivitymanagerd_20220516
Comment 11 John 2022-05-16 22:36:03 UTC
(In reply to Piotr Mierzwinski from comment #9)
> And today issue happened again.
> Again found notification that my home partition has no free space. Opened
> folder: ~/.local/share/kactivitymanagerd/resources/ and of course found huge
> database-wal file. Check my result of ls:
> $ ls -lh
> total 77G
> drwxr-xr-x 2 piotra piotra 4.0K 16.05.2022 20:35 test-backup/
> drwxr-xr-x 2 piotra piotra 4.0K 09.05.2022 09:24 working-backup/
> -rw-r--r-- 1 piotra piotra  12M 16.05.2022 20:36 database
> -rw-r--r-- 1 piotra piotra 153M 16.05.2022 23:44 database-shm
> -rw-r--r-- 1 piotra piotra  77G 16.05.2022 23:45 database-wal
> 
> Below please find version of sqlite I have installed:
> $ pacman -Q | grep sqlite
> lib32-sqlite 3.37.0-1
> mopidy-local-sqlite 1.0.0-1
> sqlite 3.38.5-1
> 
> @Ivan
> Do you think  that downgrade of sqlite could help in this case?
> 
> In attachment please find result of lsof command.

For the last few days I've dodged the problem. What I did was delete/rename the entire `~/.local/share/kactivitymanagerd/resources/` folder instead of just specific files. Ever since none of them has grown like that.

Might wanna give it a try.
Comment 12 Piotr Mierzwinski 2022-05-18 22:16:23 UTC
And today again happened mentioned issue :/-. 
$ ls -lh
total 77G
drwxr-xr-x 2 piotra piotra 4.0K 17.05.2022 00:19 test-backup/
drwxr-xr-x 2 piotra piotra 4.0K 17.05.2022 00:19 working-backup/
-rw-r--r-- 1 piotra piotra  11M 18.05.2022 13:52 database
-rw-r--r-- 1 piotra piotra 152M 19.05.2022 00:02 database-shm
-rw-r--r-- 1 piotra piotra  76G 19.05.2022 00:04 database-wal

This starts to be really annoying.
What is going on with that?

Attached lsof result.
Comment 13 Piotr Mierzwinski 2022-05-18 22:16:51 UTC
Created attachment 148977 [details]
lsof_kactivitymanagerd_20220518
Comment 14 Piotr Mierzwinski 2022-05-18 22:19:20 UTC
(In reply to John from comment #11)
> (In reply to Piotr Mierzwinski from comment #9)
> > And today issue happened again.
> > Again found notification that my home partition has no free space. Opened
> > folder: ~/.local/share/kactivitymanagerd/resources/ and of course found huge
> > database-wal file. Check my result of ls:
> > $ ls -lh
> > total 77G
> > drwxr-xr-x 2 piotra piotra 4.0K 16.05.2022 20:35 test-backup/
> > drwxr-xr-x 2 piotra piotra 4.0K 09.05.2022 09:24 working-backup/
> > -rw-r--r-- 1 piotra piotra  12M 16.05.2022 20:36 database
> > -rw-r--r-- 1 piotra piotra 153M 16.05.2022 23:44 database-shm
> > -rw-r--r-- 1 piotra piotra  77G 16.05.2022 23:45 database-wal
> > 
> > Below please find version of sqlite I have installed:
> > $ pacman -Q | grep sqlite
> > lib32-sqlite 3.37.0-1
> > mopidy-local-sqlite 1.0.0-1
> > sqlite 3.38.5-1
> > 
> > @Ivan
> > Do you think  that downgrade of sqlite could help in this case?
> > 
> > In attachment please find result of lsof command.
> 
> For the last few days I've dodged the problem. What I did was delete/rename
> the entire `~/.local/share/kactivitymanagerd/resources/` folder instead of
> just specific files. Ever since none of them has grown like that.
> 
> Might wanna give it a try.

Thanks for advise. I applied your solution. We will see if issue will happen again for me.
Worth to notice that removed structure of directories have been recreated.
Comment 15 Ivan Čukić 2022-05-21 07:34:55 UTC
Still haven't been able to reproduce the issue.

I'm working on a health checker that will disable adding recent documents to the database if the wal file becomes larger than the database itself. But that is not a proper fix for the issue.

Are you all on Arch?
Comment 16 Ivan Čukić 2022-05-21 07:57:03 UTC
Also, what is the content of
.local/share/kactivitymanagerd/resources/errors.log
?
Comment 17 Piotr Mierzwinski 2022-05-21 10:43:22 UTC
(In reply to Ivan Čukić from comment #15)
> Still haven't been able to reproduce the issue.
> 
> I'm working on a health checker that will disable adding recent documents to
> the database if the wal file becomes larger than the database itself. But
> that is not a proper fix for the issue.
> 
> Are you all on Arch?

Yes.
To be detailed. My previous distribution was Antergos, but after it died has been migrated to Arch, automatically. I think it happened couple years ago.
Comment 18 Ivan Čukić 2022-05-21 10:45:17 UTC
Thanks, will try to set it up in a VM to see whether I can reproduce it on Arch.
Comment 19 Piotr Mierzwinski 2022-05-21 11:27:51 UTC
(In reply to Ivan Čukić from comment #16)
> Also, what is the content of
> .local/share/kactivitymanagerd/resources/errors.log
> ?

"2022-05-19T00:10:28 error: near ".": syntax error Unable to execute statement"

BTW. That day I got huge "database-wal" file. I reported this, also.
Comment 20 Tilman Vogel 2022-05-21 14:15:18 UTC
> Are you all on Arch?

No, I am on openSUSE Tumbleweed and had that problem. Also, kactivitymanagerd ate 100% of one of my cores. I removed database and config files. After that, it did not happen again yet.
Comment 21 Ahmad Samir 2022-07-08 21:33:18 UTC
(In reply to Tilman Vogel from comment #20)
> > Are you all on Arch?
> 
> No, I am on openSUSE Tumbleweed and had that problem. Also,
> kactivitymanagerd ate 100% of one of my cores. I removed database and config
> files. After that, it did not happen again yet.

I had this same issue on Tumbleweed, and deleting the database files fixed the issue, I thought it was a fluke on my system, so never reported it.
Comment 22 Dariusz Nawrocki 2023-10-16 15:29:51 UTC
The same issue here. I upgraded from Ubuntu 20.04 to 22.04 yesterday. Today I noticed that there is no space available to see ~200 GB WAL file:


```
> $ ls -alh ./.local/share/kactivitymanagerd/resources/
> total 197G
> drwxrwxr-x 4 xtb xtb 4,0K paź 15 22:45 .
> drwxrwxr-x 3 xtb xtb 4,0K lis 10  2020 ..
> -rw-r--r-- 1 xtb xtb 844K paź 16 13:08 database
> -rw-r--r-- 1 xtb xtb 390M paź 16 17:07 database-shm
> -rw-r--r-- 1 xtb xtb 196G paź 16 17:08 database-wal
> drwxrwxr-x 2 xtb xtb 4,0K paź 15 22:45 test-backup
> drwxrwxr-x 2 xtb xtb 4,0K paź 15 22:45 working-backup
```