LevelDB: corrupted database returning an innocuous error
- Dominant language
- JavaScript
- Stars
- 17.6k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
I've run into an issue where our upsert implementation loops forever, because `db.get` always returns a 404, and `db.put` always returns a 409. After debugging, I've determined that the metadata for the document returns a `rev` and a `winningRev`, `deleted: false`, a large `rev_tree` an an **empty** `rev_map`. so the following line assigns `undefined` to `seq`:
https://github.com/pouchdb/pouchdb/blob/e14c547471df732d06568775317678a9fa41a8f4/packages/node_modules/pouchdb-adapter-leveldb-core/src/index.js#L388
it then tries to get a doc with key `0000000undefined`, which is, of course, not found, and just returns a 404 not found error.
I'm not sure how the data got corrupted, and not sure how I'm going to work around it yet, but it seems that the code should be returning a different error if the revision is missing from the `rev_map`, which appears to be an unexpected state.
Contributor guide
Assessment
This issue has not been assessed yet.