Cannot launch after power failure (Probable corrupt db)

Hi there!
I was unfortunate enough to experience a power failure, and Grist no longer launches.
Deleting the “grist-sessions.db” and “home.sqlite3” files can launch it again, but of course. All configuration and such is gone. From the “docs” folder I can import my documents painstakingly one by one, but I lose all access rules and any configuration done outside of the actual cell data.

I wouldn’t mind so much if it wasn’t for the fact that I do not wish to setup access rules once more.

Is there any chance for recovery or is the database corrupt and I need to start from scratch?

docker-compose logs:
dockerbox@dockerbox:/docker/grist$ docker-compose logs
Attaching to grist_grist_1
grist_1  | 2023-10-05 20:59:13.507 - debug: 3-pipe Sandbox started sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:13.538 - info: Sandbox stderr: run.py: sandbox/gvisor/run.py -E PYTHONPATH=/grist/sandbox/grist -E PIPE_MODE=minimal -m /grist/sandbox --checkpoint /tmp/engine__grist python3 -- /grist/sandbox/grist/main.py sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:14.533 - info: Sandbox stderr: Ready message: [INFO] [__main__] Ready sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:14.728 - warn: Sandbox unexpectedly exited with code 0 signal null sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | Welcome to Grist.
grist_1  | 2023-10-05 20:59:16.256 - info: == Grist version is 1.1.0 (commit unknown)
grist_1  | 2023-10-05 20:59:16.263 - debug: skipping incomplete language fa (set GRIST_OFFER_ALL_LANGUAGES if you want it)
grist_1  | 2023-10-05 20:59:16.275 - info: Loading empty config because /persist/config.json missing
grist_1  | 2023-10-05 20:59:16.276 - info: SamlConfig set with host https://grist.xxx.xxx, IdP https://xxxx.eu.xxxx.com/samlp/xxx
grist_1  | Error: No example workspace available
grist_1  |     at HomeDBManager.initializeSpecialIds (/grist/_build/app/gen-server/lib/HomeDBManager.js:238:23)
grist_1  |     at async FlexServer.initHomeDBManager (/grist/_build/app/server/lib/FlexServer.js:514:9)
grist_1  |     at async main (/grist/_build/app/server/mergedServerMain.js:69:5)
grist_1  |     at async main (/grist/_build/stubs/app/server/server.js:121:20)
grist_1  | 2023-10-05 20:59:17.115 - debug: 3-pipe Sandbox started sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:17.147 - info: Sandbox stderr: run.py: sandbox/gvisor/run.py -E PYTHONPATH=/grist/sandbox/grist -E PIPE_MODE=minimal -m /grist/sandbox --checkpoint /tmp/engine__grist python3 -- /grist/sandbox/grist/main.py sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:18.189 - info: Sandbox stderr: Ready message: [INFO] [__main__] Ready sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:18.382 - warn: Sandbox unexpectedly exited with code 0 signal null sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | Welcome to Grist.
grist_1  | 2023-10-05 20:59:19.887 - info: == Grist version is 1.1.0 (commit unknown)
grist_1  | 2023-10-05 20:59:19.895 - debug: skipping incomplete language fa (set GRIST_OFFER_ALL_LANGUAGES if you want it)
grist_1  | 2023-10-05 20:59:19.907 - info: Loading empty config because /persist/config.json missing
grist_1  | 2023-10-05 20:59:19.909 - info: SamlConfig set with host https://grist.xxxx.xxx, IdP https://xxxx.eu.xxxx.com/samlp/xxx
grist_1  | Error: No example workspace available
grist_1  |     at HomeDBManager.initializeSpecialIds (/grist/_build/app/gen-server/lib/HomeDBManager.js:238:23)
grist_1  |     at async FlexServer.initHomeDBManager (/grist/_build/app/server/lib/FlexServer.js:514:9)
grist_1  |     at async main (/grist/_build/app/server/mergedServerMain.js:69:5)
grist_1  |     at async main (/grist/_build/stubs/app/server/server.js:121:20)
grist_1  | 2023-10-05 20:59:20.733 - debug: 3-pipe Sandbox started sandboxPid=24, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:20.767 - info: Sandbox stderr: run.py: sandbox/gvisor/run.py -E PYTHONPATH=/grist/sandbox/grist -E PIPE_MODE=minimal -m /grist/sandbox --checkpoint /tmp/engine__grist python3 -- /grist/sandbox/grist/main.py sandboxPid=24, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:21.815 - info: Sandbox stderr: Ready message: [INFO] [__main__] Ready sandboxPid=24, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:22.013 - warn: Sandbox unexpectedly exited with code 0 signal null sandboxPid=24, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | Welcome to Grist.
grist_1  | 2023-10-05 20:59:23.496 - info: == Grist version is 1.1.0 (commit unknown)
grist_1  | 2023-10-05 20:59:23.503 - debug: skipping incomplete language fa (set GRIST_OFFER_ALL_LANGUAGES if you want it)
grist_1  | 2023-10-05 20:59:23.515 - info: Loading empty config because /persist/config.json missing
grist_1  | 2023-10-05 20:59:23.516 - info: SamlConfig set with host https://grist.xxxx.xxx, IdP https://xxxxx.eu.xxx.com/samlp/xxxxxxxxxxx
grist_1  | Error: No example workspace available
grist_1  |     at HomeDBManager.initializeSpecialIds (/grist/_build/app/gen-server/lib/HomeDBManager.js:238:23)
grist_1  |     at async FlexServer.initHomeDBManager (/grist/_build/app/server/lib/FlexServer.js:514:9)
grist_1  |     at async main (/grist/_build/app/server/mergedServerMain.js:69:5)
grist_1  |     at async main (/grist/_build/stubs/app/server/server.js:121:20)
grist_1  | 2023-10-05 20:59:24.569 - debug: 3-pipe Sandbox started sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:24.603 - info: Sandbox stderr: run.py: sandbox/gvisor/run.py -E PYTHONPATH=/grist/sandbox/grist -E PIPE_MODE=minimal -m /grist/sandbox --checkpoint /tmp/engine__grist python3 -- /grist/sandbox/grist/main.py sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:25.578 - info: Sandbox stderr: Ready message: [INFO] [__main__] Ready sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:25.782 - warn: Sandbox unexpectedly exited with code 0 signal null sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | Welcome to Grist.
grist_1  | 2023-10-05 20:59:27.301 - info: == Grist version is 1.1.0 (commit unknown)
grist_1  | 2023-10-05 20:59:27.309 - debug: skipping incomplete language fa (set GRIST_OFFER_ALL_LANGUAGES if you want it)
grist_1  | 2023-10-05 20:59:27.321 - info: Loading empty config because /persist/config.json missing
grist_1  | 2023-10-05 20:59:27.323 - info: SamlConfig set with host https://grist.xxxx.xxx, IdP https://xxxxx.eu.xxx.com/samlp/xxxxxxxxxxx
grist_1  | Error: No example workspace available
grist_1  |     at HomeDBManager.initializeSpecialIds (/grist/_build/app/gen-server/lib/HomeDBManager.js:238:23)
grist_1  |     at async FlexServer.initHomeDBManager (/grist/_build/app/server/lib/FlexServer.js:514:9)
grist_1  |     at async main (/grist/_build/app/server/mergedServerMain.js:69:5)
grist_1  |     at async main (/grist/_build/stubs/app/server/server.js:121:20)
grist_1  | 2023-10-05 20:59:28.779 - debug: 3-pipe Sandbox started sandboxPid=24, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:28.812 - info: Sandbox stderr: run.py: sandbox/gvisor/run.py -E PYTHONPATH=/grist/sandbox/grist -E PIPE_MODE=minimal -m /grist/sandbox --checkpoint /tmp/engine__grist python3 -- /grist/sandbox/grist/main.py sandboxPid=24, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:29.864 - info: Sandbox stderr: Ready message: [INFO] [__main__] Ready sandboxPid=24, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:30.078 - warn: Sandbox unexpectedly exited with code 0 signal null sandboxPid=24, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | Welcome to Grist.
grist_1  | 2023-10-05 20:59:31.578 - info: == Grist version is 1.1.0 (commit unknown)
grist_1  | 2023-10-05 20:59:31.585 - debug: skipping incomplete language fa (set GRIST_OFFER_ALL_LANGUAGES if you want it)
grist_1  | 2023-10-05 20:59:31.597 - info: Loading empty config because /persist/config.json missing
grist_1  | 2023-10-05 20:59:31.598 - info: SamlConfig set with host https://grist.xxxx.xxx, IdP https://xxxxx.eu.xxx.com/samlp/xxxxxxxxxxx
grist_1  | Error: No example workspace available
grist_1  |     at HomeDBManager.initializeSpecialIds (/grist/_build/app/gen-server/lib/HomeDBManager.js:238:23)
grist_1  |     at async FlexServer.initHomeDBManager (/grist/_build/app/server/lib/FlexServer.js:514:9)
grist_1  |     at async main (/grist/_build/app/server/mergedServerMain.js:69:5)
grist_1  |     at async main (/grist/_build/stubs/app/server/server.js:121:20)
grist_1  | 2023-10-05 20:59:33.896 - debug: 3-pipe Sandbox started sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:33.927 - info: Sandbox stderr: run.py: sandbox/gvisor/run.py -E PYTHONPATH=/grist/sandbox/grist -E PIPE_MODE=minimal -m /grist/sandbox --checkpoint /tmp/engine__grist python3 -- /grist/sandbox/grist/main.py sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:34.930 - info: Sandbox stderr: Ready message: [INFO] [__main__] Ready sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:35.112 - warn: Sandbox unexpectedly exited with code 0 signal null sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | Welcome to Grist.
grist_1  | 2023-10-05 20:59:36.592 - info: == Grist version is 1.1.0 (commit unknown)
grist_1  | 2023-10-05 20:59:36.600 - debug: skipping incomplete language fa (set GRIST_OFFER_ALL_LANGUAGES if you want it)
grist_1  | 2023-10-05 20:59:36.611 - info: Loading empty config because /persist/config.json missing
grist_1  | 2023-10-05 20:59:36.613 - info: SamlConfig set with host https://grist.xxxx.xxx, IdP https://xxxxx.eu.xxx.com/samlp/xxxxxxxxxxx
grist_1  | Error: No example workspace available
grist_1  |     at HomeDBManager.initializeSpecialIds (/grist/_build/app/gen-server/lib/HomeDBManager.js:238:23)
grist_1  |     at async FlexServer.initHomeDBManager (/grist/_build/app/server/lib/FlexServer.js:514:9)
grist_1  |     at async main (/grist/_build/app/server/mergedServerMain.js:69:5)
grist_1  |     at async main (/grist/_build/stubs/app/server/server.js:121:20)
grist_1  | 2023-10-05 20:59:40.489 - debug: 3-pipe Sandbox started sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:40.523 - info: Sandbox stderr: run.py: sandbox/gvisor/run.py -E PYTHONPATH=/grist/sandbox/grist -E PIPE_MODE=minimal -m /grist/sandbox --checkpoint /tmp/engine__grist python3 -- /grist/sandbox/grist/main.py sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:41.563 - info: Sandbox stderr: Ready message: [INFO] [__main__] Ready sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:41.770 - warn: Sandbox unexpectedly exited with code 0 signal null sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | Welcome to Grist.
grist_1  | 2023-10-05 20:59:43.276 - info: == Grist version is 1.1.0 (commit unknown)
grist_1  | 2023-10-05 20:59:43.283 - debug: skipping incomplete language fa (set GRIST_OFFER_ALL_LANGUAGES if you want it)
grist_1  | 2023-10-05 20:59:43.295 - info: Loading empty config because /persist/config.json missing
grist_1  | 2023-10-05 20:59:43.296 - info: SamlConfig set with host https://grist.xxxx.xxx, IdP https://xxxxx.eu.xxx.com/samlp/xxxxxxxxxxx
grist_1  | Error: No example workspace available
grist_1  |     at HomeDBManager.initializeSpecialIds (/grist/_build/app/gen-server/lib/HomeDBManager.js:238:23)
grist_1  |     at async FlexServer.initHomeDBManager (/grist/_build/app/server/lib/FlexServer.js:514:9)
grist_1  |     at async main (/grist/_build/app/server/mergedServerMain.js:69:5)
grist_1  |     at async main (/grist/_build/stubs/app/server/server.js:121:20)
grist_1  | 2023-10-05 20:59:50.381 - debug: 3-pipe Sandbox started sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:50.414 - info: Sandbox stderr: run.py: sandbox/gvisor/run.py -E PYTHONPATH=/grist/sandbox/grist -E PIPE_MODE=minimal -m /grist/sandbox --checkpoint /tmp/engine__grist python3 -- /grist/sandbox/grist/main.py sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:51.435 - info: Sandbox stderr: Ready message: [INFO] [__main__] Ready sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)
grist_1  | 2023-10-05 20:59:51.647 - warn: Sandbox unexpectedly exited with code 0 signal null sandboxPid=23, flavor=gvisor, command=undefined, entryPoint=(default)

docker-compose.yml
version: '3'

services:
  grist:
    image: gristlabs/grist
    restart: unless-stopped
    environment:
      - DEBUG=1
      - GRIST_SANDBOX_FLAVOR=gvisor
      - GRIST_SESSION_SECRET=xxxxx
      - GRIST_SUPPORT_EMAIL=admin@xxxx.xxx
      - GRIST_DEFAULT_EMAIL=admin@xxxx.xxx
      - APP_HOME_URL=https://grist.xxxx.xxx
      - GRIST_SINGLE_ORG=penguins-anonymous
      - GRIST_TELEMETRY_LEVEL=limited
      #- GRIST_FORCE_LOGIN=true
      - GRIST_SAML_SP_HOST=https://grist.xxxxx.xxx
      - GRIST_SAML_IDP_UNENCRYPTED=1
      - GRIST_SAML_IDP_LOGIN=https://xxxxx.eu.xxxx.com/samlp/xxxxxxxxxxx
      - GRIST_SAML_IDP_LOGOUT=https://xxxxx.eu.xxxx.com/samlp/xxxxxxxxxxx
      - GRIST_SAML_IDP_CERTS=/persist/xxxxx.pem
      - GRIST_SAML_SP_KEY=/persist/xxxx_pkey.pem
      - GRIST_SAML_SP_CERT=/persist/xxxx_certificate.crt
      - GRIST_WIDGET_LIST_URL=https://github.com/gristlabs/grist-widget/releases/download/latest/manifest.json
      - GRIST_HIDE_UI_ELEMENTS=templates,sendToDrive
    ports:
      - 8484:8484
    volumes:
      - ./persist:/persist
    stdin_open: true
    tty: true


I want to note that the sandbox errors do not appear with a clean setup.

Thank you in advance.

EDIT: I want to add that the database itself does look entirely in tact. Not sure if it’s possible to edit something to make it work? Comparing mine to a brand new one and I believe everything is there.

Managed to solve it!
In short it was database corruption. After going through the sqlite file I noticed that a brand new home.sqlite3 file has workspaces filled with id 1, 2. with org_id 1, 2.
image

My home.sqlite3 file was missing line 2…

I added back line 2 with the same id 2, orgid 2 and it magically worked!!

I’ll leave the thread up in case anyone experienced something similar.
SQLlite db browser used: https://sqlitebrowser.org/

Thanks for the write-up @GrittingGrister! I’m kind of at a loss for how that workspace could have disappeared, even with a power failure. I’m glad you were able to figure out a way to recover, and thanks for documenting it in detail.

1 Like