apache / apache/pouchdb

LevelDB: corrupted database returning an innocuous error

Open
#8,868 1 comment 0 reactions 0 assignees View on GitHub
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

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.