Bug 181059 - Wallet lost when disk full
Summary: Wallet lost when disk full
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: kwallet (show other bugs)
Version: 4.1
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: Michael Leupold
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-17 10:11 UTC by Wouter Coekaerts
Modified: 2009-01-19 17:52 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wouter Coekaerts 2009-01-17 10:11:26 UTC
Version:            (using KDE 4.1.3)
OS:                Linux
Installed from:    Debian testing/unstable Packages

When the disk becomes full, the wallet can get lost.

I was downloading something during the night (so I was not actively using my wallet), and in the morning I had a full disk, and a 0 size kdewallet.kwl.

This is related to bug #76581, but that talks about system crash, not disk full, so I assume it's not exactly the same issue. Note the comment on 2008-02-13 on that ticket from Blindauer Emmanuel who had the same problem.
Comment 1 Michael Leupold 2009-01-17 19:27:41 UTC
Usually kwalletd saves the wallet to disk on closing it or on changes. Do you know which of those two conditions lead to the empty wallet? Could you please also tell me which filesystem your HOME is using?

I'm trying hard to reproduce this condition on an ext2 loop partition (since I don't plan to fill my whole harddrive) but unfortunately haven't managed to make it empty the file.
Comment 2 Wouter Coekaerts 2009-01-17 20:31:50 UTC
The wallet closes automatically after some time of not being used, right? In that case it's probably because it got closed. (I wasn't there when the disk got full, so it wasn't on changes.)
The filesystem is ext3.

Testing this on a filesystem you really use would indeed be a very bad idea. Kwallet wasn't the only KDE program to lose data or settings.

Btw, not only was the file system full, there was also a process (lftp) waiting for space to become available and immediately fill it again (continue downloading). So (depending on timing) if a file would be deleted, even writing a file of the same size right after that might fail.
Comment 3 Michael Leupold 2009-01-17 21:17:06 UTC
Thanks for the feedback. KWallet closes wallets automatically if you configured it to do so. Else wallets might stay open (or close immediately). Now, let me try to get this right. You assume:
1) The disk got full (while the wallet was closed)
2) You opened the wallet
3) The wallet closed again at some point (disk still full)

Is that right? Or rather 2), 1), 3) ?
Comment 4 Wouter Coekaerts 2009-01-17 21:29:05 UTC
I was thinking more 2,1,3. The wallet was open when the disk got full.
Looking at its settings, it's configured to close the wallet after being unused for 180min.
Comment 5 Michael Leupold 2009-01-18 02:25:02 UTC
Alright, with some additional pointers I found the cause for this. kwalletd indeed never catered for full disks and I guess it's a miracle noone stumbled onto this before. As this is important I'll try to squeeze the fix into 4.2.
Comment 6 Michael Leupold 2009-01-18 02:52:07 UTC
SVN commit 912695 by mleupold:

On saving the wallet, open the file unbuffered and check every single write operation for success. This seems to be the sanest way to avoid wallet corruption in extreme
conditions (eg. full disk).

BUG:181059

 M  +19 -6     kwalletbackend.cc  


WebSVN link: http://websvn.kde.org/?view=rev&revision=912695
Comment 7 Wouter Coekaerts 2009-01-18 10:48:49 UTC
Looks good. Thanks!
Comment 8 Michael Leupold 2009-01-19 17:52:35 UTC
SVN commit 913650 by mleupold:

Backport of r912695 to 4.2:
On saving the wallet, open the file unbuffered and check every single write operation for success. This seems to be the sanest way to avoid wallet corruption in extreme 
conditions (eg. full disk).

CCBUG:181059


 M  +19 -6     kwalletbackend.cc  


WebSVN link: http://websvn.kde.org/?view=rev&revision=913650