Bug #92222 Corrupt workspace content after forced program exit or hard reboot
Submitted: 29 Aug 2018 10:41 Modified: 15 Jan 2021 14:53
Reporter: Andi Arpo Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Workbench Severity:S2 (Serious)
Version:8.0.21 OS:Windows (Microsoft Windows 10 Pro)
Assigned to: CPU Architecture:x86
Tags: workspace

[29 Aug 2018 10:41] Andi Arpo
Description:
In case of program arrest (PC reboot) the workspace with all the script tabs are lost. 

I happen to hard reboot my PC every other day for OS login problems.
This problem with Workbench happens very often (cannot say if every time).

How to repeat:
1. Have some connections and tabs open (prefferably many tabs with unsaved SQL scripts)
2. Hard reboot the machine
3. Open Workbench and open a saved connection
4. You should be presented with an error pop-up stating 
"Restore Workspace - Could not read contents of c:\Users\<username>\AppData\Roaming\MySQL...\"
[29 Aug 2018 10:42] Andi Arpo
Screenshot of pop-up

Attachment: MySQL Workbench lost workspace.png (image/png, text), 16.66 KiB.

[30 Aug 2018 13:17] MySQL Verification Team
Hello Andi Arpo,

Thank you for the report.
I've tried to reproduce this issue at our end on Win7/Ubuntu(VM) but not able to reproduce. Since user name was obfuscated hence wanted to know if you have any non-latin letters in the user name? If yes then probably you are affected by Bug #87520.  Also, quick search lead me to Bug #85587, please see Bug #85587 which sounds similar case.

thanks,
Umesh
[3 Sep 2018 8:34] Andi Arpo
@Umesh user name is all ASCII, no problem here.

Bug #85587 is similar but assumes some connection to the WiFi network, I didn't see any relation to that. 

It happens very often to me, I'm pretty sure you can duplicate it by 
- opening lots of tabs (possibly on different connections) 
- using the app for a few hours
- do a hard reboot
It is true it doesn't always happen, it's more like 50% probability, but if you repeat the above steps a few times I'm sure you'll get a result. 

It's a bug present since years ago and I've seen it on various machines at work and at home. 
I'd say if you're using Workbench it must have happened to you! :)
[8 Sep 2018 1:41] MySQL Verification Team
I couldn't repeat on Windows 10 Pro and WorkBench 8.0.12 with several kinds of connection (local e remote).
[16 Jan 2019 17:06] Andi Arpo
Workbench 8.0.13 corrupted workspace files after crash

Attachment: Workbench 8.0.13 lost workspaces after crash.png (image/png, text), 83.82 KiB.

[16 Jan 2019 17:10] Andi Arpo
It happened again on version 8.0.13. I've attached a screenshot of the workspace files that I thing are corrupted. Can anybody check this issue?
[12 Apr 2019 22:57] MySQL Verification Team
I couldn't repeat with 8.0.15.
[15 Jan 2021 14:28] Andi Arpo
Apparently hard reboot and possibly stand-by are a factor in this bug. 

My laptop often powers up from stand-by during the night (a "feature" of MS Windows) and the battery empties.
So I might be more exposed to this bug than many because of the high number of hard reboots.

Upon inspection of the "autosave" folder, workspace files (usually not all) are corrupted - contents replaced by about 20-140 NUL characters.

How to recovered some tabs (others are corrupted usually, their content is replaced with null characters):

1. back-up autosave folder contents %APPDATA%\MySQL\Workbench\sql_workspaces\<connection_name>-1.autosave\ 
2. close workbench
3. restore autosave contents
4. delete 'lock' file
5. delete 'tab_order' file

See bug on StackOverflow:
https://stackoverflow.com/questions/51171288/restore-or-access-workspaces-from-mysql-workb...
[15 Jan 2021 14:33] Andi Arpo
Relevant lines in wb.log:

Line 114: 09:44:54 [INF][    WQE backend]: Found auto-save workspace C:\Users\user\AppData\Roaming\MySQL\Workbench\sql_workspaces\SERVER-1.autosave
Line 120: 10:05:40 [ERR][ SqlEditorPanel]: Could not read file C:\Users\user\AppData\Roaming\MySQL\Workbench\sql_workspaces\SERVER-1.autosave\: Failed to open file 'C:\Users\user\AppData\Roaming\MySQL\Workbench\sql_workspaces\SERVER-1.autosave\': No such file or directory
Line 120: 10:05:40 [ERR][ SqlEditorPanel]: Could not read file C:\Users\user\AppData\Roaming\MySQL\Workbench\sql_workspaces\SERVER-1.autosave\: Failed to open file 'C:\Users\user\AppData\Roaming\MySQL\Workbench\sql_workspaces\SERVER-1.autosave\': No such file or directory
[15 Jan 2021 14:53] Andi Arpo
Since this bug will probably never be fixed, can we get an indication of where the autosave feature is handled in the source code at https://github.com/mysql/mysql-workbench ? 

I'm no C programmer, but it's more than nothing. Thanks.