jupyter / jupyter/nbformat

Try to recover/fallback to an in-memory database if nbsignatures fails

Open
#428 12 comments 0 reactions 1 assignee Claimed by @Carreau View on GitHub
Dominant language
Python
Stars
313
Forks
176
PR merge metrics
No merged PRs in 30d

Description

As seen across multiple threads (https://github.com/jupyter/nbformat/issues/52, https://github.com/voila-dashboards/voila/issues/356, https://github.com/jupyter/help/issues/150, https://discourse.jupyter.org/t/how-to-change-default-db-from-sqlite-to-postgresql-mysql-in-jupyter-notebook/7052) the SQLite databases can be finicky, especially on NFS.

Because signing is performed by jupyter-server before saving, this is on critical path for user data safety - when the database fails, users cannot save their notebooks.

### Expected behaviour

IPython works this around by falling back to in-memory database for its history database (c-f recent https://github.com/ipython/ipython/pull/15204).

I would propose we should:
1. Copy existing file to a new location as a backup
2. Recover if possible
3. If not, recreate a new database
4. If recreation is not possible, maybe use in-memory database (which could be behind a traitlet?); maybe because this means signatures won't be persisted

### Reproduce

In JupyterLab or Notebook:
1. Confirm location of the database, `!ls ~/.local/share/jupyter/nbsignatures.db`
2. Corrupt the database with `!echo '' > ~/.local/share/jupyter/nbsignatures.db`
3. See that saving does not work anymore
4. See error `Unexpected error while saving file: Untitled.ipynb no such table: nbsignatures`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.