Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS Code does not warn about or try to recover a corrupt state.vscdb #93428

Closed
J-M0 opened this issue Mar 25, 2020 · 2 comments
Closed

VS Code does not warn about or try to recover a corrupt state.vscdb #93428

J-M0 opened this issue Mar 25, 2020 · 2 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded workbench-state UI state across restarts
Milestone

Comments

@J-M0
Copy link

J-M0 commented Mar 25, 2020

For some time now, I've had one workspace that refused to remember what tabs I had open when I closed VS Code and would not reopen them. Today I learned about the --verbose option when launching code and decided to investigate. It appears that the state.vscdb for the workspace became corrupted at some point and VS Code is not restoring the backup. The error message is below. I have also attatched the full output of code --verbose to this issue.

  • VSCode Version: 1.43.2
  • OS Version: Red Hat Enterprise Linux 7

Steps to Reproduce:

  1. Somehow have state.vscdb get corrupted
  2. Open the workspace the corrupted state is associated with

Does this issue occur when all extensions are disabled?: Yes

vs.log

[21522:0325/143948.959903:INFO:CONSOLE(1647)] "%cTRACE color: #888 [storage state.vscdb] Trace (event): PRAGMA user_version = 1;", source: file:///usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js (1647)
[21522:0325/143948.978568:INFO:CONSOLE(1647)] "%cTRACE color: #888 [storage state.vscdb] Trace (event): CREATE TABLE IF NOT EXISTS ItemTable (key TEXT UNIQUE ON CONFLICT REPLACE, value BLOB)", source: file:///usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js (1647)
[21522:0325/143948.981257:INFO:CONSOLE(1647)] "%c  ERR color: #f33 [storage state.vscdb] all(): Error: SQLITE_CORRUPT: database disk image is malformed", source: file:///usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js (1647)
[21522:0325/143948.981289:INFO:CONSOLE(1647)] "%cTRACE color: #888 [storage :memory:] open(:memory:, retryOnBusy: true)", source: file:///usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js (1647)
[21522:0325/143948.981314:INFO:CONSOLE(1647)] "%cTRACE color: #888 [storage state.vscdb] Trace (event): SELECT * FROM ItemTable", source: file:///usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js (1647)
[21522:0325/143948.983692:INFO:CONSOLE(5)] "[uncaught exception]: Error: SQLITE_CORRUPT: database disk image is malformed

Error: SQLITE_CORRUPT: database disk image is malformed", source: /usr/share/code/resources/app/out/bootstrap-window.js (5)
[21522:0325/143948.983720:INFO:CONSOLE(6)] "Error: SQLITE_CORRUPT: database disk image is malformed

Error: SQLITE_CORRUPT: database disk image is malformed
    at file:///usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:46:106", source: /usr/share/code/resources/app/out/bootstrap-window.js (6)
[21522:0325/143948.985192:INFO:CONSOLE(1647)] "%cTRACE color: #888 [storage :memory:] Trace (event): PRAGMA user_version = 1;", source: file:///usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js (1647)
[21522:0325/143948.985223:INFO:CONSOLE(1647)] "%cTRACE color: #888 [storage :memory:] Trace (event): CREATE TABLE IF NOT EXISTS ItemTable (key TEXT UNIQUE ON CONFLICT REPLACE, value BLOB)", source: file:///usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js (1647)
@vscodebot
Copy link

vscodebot bot commented Mar 25, 2020

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@bpasero bpasero added bug Issue identified by VS Code Team member as probable bug workbench-state UI state across restarts labels Mar 26, 2020
@bpasero bpasero added this to the March 2020 milestone Mar 26, 2020
@bpasero
Copy link
Member

bpasero commented Mar 26, 2020

@J-M0 good catch, I was able to reproduce. What happens is this:

  • we detect that the DB is corrupt
  • now things behave differently: for our global DB we simply continue to use the DB and get errors everytime we read or write, however for workspace DB, we switch to an in-memory DB
  • upon shutdown we only recover from a broken DB if we are still using it, so global storage was always able to fix itself, while workspace storage was not

My fix is to never fallback to in-memory storage now for workspace storage. That means, a broken DB will fix itself upon shutdown and be persisted with all the state that was accumulated from the session 👍

Verification:

  • download this corrupt DB state.vscdb.zip
  • remember the path for your workspace state DB (F1 > Log storage database > Dev tools)
  • close code
  • replace the DB in that folder with the corrupt one
  • startup
  • you should see all workspace state wiped out but things are still functional
  • produce some workspace state (e.g. opened editors)
  • close code
  • startup
  • now you should see your workspace state restored

@JacksonKearl JacksonKearl added the verified Verification succeeded label Apr 3, 2020
@github-actions github-actions bot locked and limited conversation to collaborators May 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded workbench-state UI state across restarts
Projects
None yet
Development

No branches or pull requests

3 participants