Save Settings with full drive corrupts config

Things you’d like to miss in the future...
Post Reply
fishgod
Posts: 227
Joined: 03 Feb 2008 00:40
Location: Sankt Augustin (near Bonn), Germany

Save Settings with full drive corrupts config

Post by fishgod »

Recently I downloaded some files to my system drive up to the point where not a single byte of free space was left...
I tried to delete some files through XYplorer but I also had background-processing of delete operations enabled. So this did not work (I think because the queue-file could not be written).
At this point I did not quite get what the cause was and decided to just restart XYplorer. Now the mess begins.
With save-settings-on-exit enabled I got a bunch of errors which I just clicked away...
After the restart XY looked like factory-resetted. Even the lisence was gone. After that I also got strange behaviour like ENTER and BACKSPACE for basic folder navigation did not work anymore. Long story short, ks.dat seems to be also corrupted. I deleted it and got the default behaviour back.
The files in the "AutoBackup" folder where also corrupted (XYplorer.ini had 0 bytes).

Maybe this can be improved in a way that XYplorer checks for enough free space before writing any config-files to disk.
Not having the settings saved would be way better because the last restart (and due to that also the last config state) was at maximum a few days old.

You may claim, that I should have a backup, you are right about this. I found a old config-backup, but that was about a year old, so not really fresh. Of cause a bunch of settings, keyboard-shortcuts, folder-view settings and so on changed over that last year...

Edit:
Using XYplorer 18.90.0100
The download was still ongoing. Maybe this creates some form of race-condition.
Last edited by fishgod on 29 Apr 2018 14:06, edited 1 time in total.
Operating System: Win10 x64 / Win11 x64 / almost allways newest XY-beta
totally XYscripting-addicted

jupe
Posts: 2795
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Save Settings with full drive corrupts config

Post by jupe »

I am pretty sure this was already implemented, when requested here:

viewtopic.php?f=2&t=18120

Code: Select all

v18.50.0202 - 2017-11-13 18:28
    + App Exit: Now when anything goes wrong on save settings you are prompted 
      whether you want to exit the app (any maybe lose any changes in your 
      configuration) or keep it running (to keep your configuration alive, check 
      what went wrong, and maybe fix it, e.g. by removing a ReadOnly flag or by 
      regaining necessary disk space).
      This is the message:
        Errors on Save Settings!
        Some settings might not have been saved to disk.
        Click OK to exit XYplorer anyway.
        Click Cancel to keep XYplorer running.
Could you have just clicked away the warning without reading it?

fishgod
Posts: 227
Joined: 03 Feb 2008 00:40
Location: Sankt Augustin (near Bonn), Germany

Re: Save Settings with full drive corrupts config

Post by fishgod »

Ok i did't know this feature allready exists.
But than I should be stuck on a old config and not a corrupted one.
I'am pretty sure there were only error-msg with OK-buttons no question-dialog.

I was using 18.90.0100 so this feature should have been in place allready.
Maybe there is a race-condition when the download still happens (I was downloading via Vivaldi browser) in the following form:
XY starts to write the config (at this time there is enough space, maybe just be the fact the config did not changed in size), after the first line is submitted to the file, the config is smaller making some free bytes on the drive. Now the Browser kicks in and also commit it's unsaved bytes. When XYplorer tries to continue writing the config the previous free space is allready gone.
Operating System: Win10 x64 / Win11 x64 / almost allways newest XY-beta
totally XYscripting-addicted

jupe
Posts: 2795
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Save Settings with full drive corrupts config

Post by jupe »

Did the error dialog look anything like this ?

Image

(Annulla is Italian for Cancel)

fishgod
Posts: 227
Joined: 03 Feb 2008 00:40
Location: Sankt Augustin (near Bonn), Germany

Re: Save Settings with full drive corrupts config

Post by fishgod »

No, all error-dialogs had a bug-icon (like this: :bug: ) on it.

edit:
Since now I learned a lesson and created a up-to-date backup I can try to reproduce the situation.
Operating System: Win10 x64 / Win11 x64 / almost allways newest XY-beta
totally XYscripting-addicted

admin
Site Admin
Posts: 60595
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Save Settings with full drive corrupts config

Post by admin »

I would also recommend to tick this: Configuration | General | Startup & Exit | Save Settings | Backup settings on save

Then mishap will through you back only 24 hours.

fishgod
Posts: 227
Joined: 03 Feb 2008 00:40
Location: Sankt Augustin (near Bonn), Germany

Re: Save Settings with full drive corrupts config

Post by fishgod »

I did some tests to reproduce the observed behaviour.
After the tests I have to admit that I think I overlooked the "Errors on Save Settings!"-dialog in the first place.

In case you might ask how I filled the disk for testing: I prefilled the disk up to a few hundred MB free space and filled the rest on demand with a small PHP-script from the command line (could be easly done in any scripting-language, this was just the quickest that came into my mind):

Code: Select all

$f = fopen(__DIR__.DIRECTORY_SEPARATOR.'fill.disk.tmp', 'a');
$block = str_repeat(' ', 4096);
while(true) {
  fwrite($f, $block);
  fflush($f);
}
All tests are done with XYplorer 18.90.0100
"Save settings on exit" with "Include most-recently-used lists on save" enabled
"Backup Settings on save" enabled
Most likely when I close XYplorer the last AutoBackup is older than 24h because we are talking about a PC, that is allways kept in standby and never shut down, so XYplorer might by open for days or weeks. That makes it also really likly that the config has grown (e.g. bunch of tags added, or grown mruLists for XYplorer.ini)

Of cause AutoBackup can only work if there is enough free space, which is obviously not the case here.
If the files have not reasonably changed in size (fitting in the same sectors), it works, but if not, AutoBackup failes completely silent!

Let's create a risky situation:
- Disk is full
- Config has grown
:arrow: Close XY.
We get errors like this:
Bild1.png
Bild1.png (9.76 KiB) Viewed 1545 times
for udc.dat, and fvs.dat.
After this, we get the the "Errors on Save Settings!"-dialog (where we press cancel!):
Bild3.png
Bild3.png (5.78 KiB) Viewed 1545 times
Because AutoBackup failed completely silet, the grown files have not been updated in the AutoBackup-folder.
Allthough there where error-msgs for udc.dat and fvs.dat (which is also reflected in the "Errors on Save Settings!"-dialog), these files look normal, but ks.dat, tag.dat and XYplorer.ini have zero bytes now.

If we try to close XY again, we get the same series of error-msgs but this time AutoBackup is able to backup the currently zero-byte sized XYplorer.ini from data-folder to the AutoBackup-folder. Effectively erasing the last backup, leaving you with no config and no backup if you continue closing XY.

To me it looks like that these error-messages (like the ones shown in Bild1.png) are only for certain dat-files, but not for all, and also not for the XYplorer.ini.

Let's assume another situation:
- Disk is full
- Config has grown
:arrow: File > Save Settings
No Error at all!
The Status bar announces that XYplorer.ini and a bunch of other .dat-files have been successfully saved.
Bild4.png
Bild4.png (1.64 KiB) Viewed 1545 times
Which is not: XYplorer.ini and tag.dat have zero bytes on disk now.
The dangerous thing now is that we can close XY and get no error and no warning because it assumes all settings have just been saved, and the internal state did not changed since then!

Conclusion:
I must admit, that these might be rare edge-cases that do not happen often.
But having settings "might not beeing saved" (as advertised by the warning-dialog) and having settings completly erased, are two totally different things.

All the config files should be saved with some "safe overwrite" mechanism (allready known from XYcopy) so that the new config is written to a temporary file, and only if this succeed the config-file gets exchanged by tmp-file.
This way the worst that could happen, is that the config is not saved, leaving you with your last state, instead of your config beeign wiped or corrupted.
Operating System: Win10 x64 / Win11 x64 / almost allways newest XY-beta
totally XYscripting-addicted

admin
Site Admin
Posts: 60595
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Save Settings with full drive corrupts config

Post by admin »

1) Well, if the disk is full there is no place for a temp file.
2) If you cancel that "Errors on Save Settings!" dialog XY stays in memory and you can make space on the disk.
3) Disk Full is a physical problem that's a challenge for all software. Not much room there for graceful moves.

Post Reply