FoldingAtHome / fah-client-bastet

Folding@home client, code named Bastet
GNU General Public License v3.0
61 stars 10 forks source link

Windows 10 and 11 version "forgets" CPU WU after system restart #290

Open muziqaz opened 6 days ago

muziqaz commented 6 days ago

I thought it would be better to create a separate issue regarding the WU stuff. So every time I restart my Windows PCs, both systems FAH client downloads new WU instead of continuing with the old one, which was downloaded and being folded before the restart. On one system I can see 5 WU folders in Work directory, while I am only folding one at the moment. Log is not showing anything suspicious, except some subprocess error 14:20:09:E :Subprocess deallocated while process is still running Here is the log. log.txt

There has been no alterations to both systems in regards to boot/restart sequence. Everything is default as father Microsoft intended.

Linux system seems to work as intended

I mentioned this issue before in this comment and thread: https://github.com/FoldingAtHome/fah-client-bastet/issues/286#issuecomment-2368484970

kbernhagen commented 5 days ago

Does the forgetting not happen if you quit the client via sys tray before restarting the system?

muziqaz commented 5 days ago

Does the forgetting not happen if you quit the client via sys tray before restarting the system?

Quitting and then restarting resumes from where it stopped.

kbernhagen commented 5 days ago

My thought, which has been disputed in the past, is that Windows unceremoniously kills the client when there is a reboot, leaving database locked with unsaved changes.

The client is also running a native Win event loop. Maybe it just needs to catch appropriate messages for logout/shutdown.

muziqaz commented 5 days ago

I have a suspicion, too, that windows shutdown procedures are killing FAH processes, however, these systems had no issues with v7, as well as v7 would survive crashing system most of the time. I think v8 needs a bit more robust progress saving system. I'm not sure how v8 reacts to crahsing systems, since mine have been stable for quite some time now.

muziqaz commented 5 days ago

Also, what is weird, that V8 is downloading new WU, instead of resetting currently running one to zero. V7 sometimes used to lose WU's progress if system crash was severe. It had never lost a WU. Well there were several very rare occasions when another WU would get downloaded while old one was still there, but it would be visible in fahcontrol, and once newly downloaded WU was completed fahclient would pick up the old one and continue from where it left off. It would be great that I could still complete those other 4 WUs sitting on my SSD with v8

jcoffland commented 4 days ago

Could this be the same permissions issue that is causing the client not to restart. If the old WUs file permissions were changed such that it was inaccessible then it would not run after reboot. In this case, I would expect the old WU files to still be on the disk.

jcoffland commented 4 days ago

The permissions problem could be caused by either the client trying to start in the wrong directory, the file permissions on log.txt or it's directory are actually being changed or the client is starting under the wrong user.

muziqaz commented 4 days ago

I will be able to test this in an hour or so. The test PC has ProgramData/FahClient security settings tweaked to allow writing by any Users, which solved the restart issue. Do you have some sort of longer WU for me to download during the test that I do not lose real work? 2 minute long WU would be sufficient. If you don't mind creating something, ping me details in the Slack Thanks

muziqaz commented 4 days ago

Just restarted the PC and it downloaded new WU ignoring the old one. Here is the log. Old one had 2% done. log.txt

Windows Event Viewer does not report any FAH related errors or any other app related errors. ProgramData/FAHClient folder retained write permissions I set up previously

jcoffland commented 4 days ago

It does look like the client was hard killed during shutdown. The log just ends abruptly. Then when it starts again it says: Loaded 0 wus.

muziqaz commented 4 days ago

Not sure if that makes any difference, on my Windows 10 PC, FAHClient process is running under muziqaz2 user name. ProgramData\FAHClient security properties list: CREATOR OWNER (which has no permissions and I am not allowed to change it, it reverts to nothing, when I apply the changes) SYSTEM (which has full control) Administrators (MUZIQAZ2\Administrators) (has full control) Users (MUZIQAZ2\Users) (which has Read & Execute, List contents, Read, Write)

ProgramData\FAHClient\work security properties have the same as above

ProgramData\FAHClient\work\wudirectory (which got forgotten) security properties have as above, PLUS: muziqaz2 (MUZIQAZ2\muziqaz2) (which has nothing but Special Permissions ticked)

muziqaz commented 4 days ago

Just for giggles, I gave full control to muziqaz2 for the WU folder, rebooted, it still downloaded new WU. So doubt this is permission issue

jcoffland commented 4 days ago

Does this build work any better?: https://master.foldingathome.org/builds/fah-client/windows-10-64bit/release/v8.4.6-b135/fah-client_8.4.6_AMD64.exe

I added detection of the Windows shutdown message.

muziqaz commented 4 days ago

It does look like the client was hard killed during shutdown. The log just ends abruptly. Then when it starts again it says: Loaded 0 wus.

I don't believe I am breeding killer OSs :D If it makes any difference they are Win 11 Pro and Win 10 Pro. Both have 22H2 updates, which seem to be the latest for those OS builds. I believe 22H2 is just a name, and it contains all the latest stuff from 24H2

muziqaz commented 4 days ago

New version ignored old WU and downloaded new WU after installation even without the system restart :( Is it possible windows process termination method is broken on my systems, which can't be, since it would be hell of the coincidence to have 2 different Windows versions sledgehammering processes instead of closing them Restarting the system now

muziqaz commented 4 days ago

Restarting still downloaded new WU log.txt

Also, installation did not change ProgramData\FAHClient permissions

kbernhagen commented 4 days ago

Is the Windows logout message also handled by the new code?

jcoffland commented 3 days ago

I added code to shut the client down if it receives a WM_QUERYENDSESSION or WM_ENDSESSION message.