Closed jchris closed 3 months ago
Error: missing block:
at EventFetcher.get
at async findAncestorCandidate
at async findCommonAncestor
discord discussion:
I implemented a default compactor (all blocks to one file): https://github.com/fireproof-storage/fireproof/blob/bdfb742af714df8713fe940ceee34e0a1e8e10cf/packages/encrypted-blockstore/src/transaction.ts#L118
But it's like 300MB of storage where the Fireproof compactor is closer to 3MB. Here is where the Fireproof connector is disabled in favor of the default blockstore compactor: https://github.com/fireproof-storage/fireproof/blob/bdfb742af714df8713fe940ceee34e0a1e8e10cf/packages/fireproof/src/crdt.ts#L51 the default compactor doesn't have the issues described in issue 95 so I've switched to it for now, but it has perf issues when the data set gets big
A mature approach will move to something like multi-level compaction https://www.speedb.io/blog-posts/understanding-leveled-compaction
this was fixed in #98 with a network lookup mode to recover any missing blocks from the network. This makes concurrent merges safe
If I drive a database with heavy automated clicks from 3-4 users for an hour, I'll get this kind of thing which should impossible. It seems to be that merging two compacted datasets can sometimes require a block neither compaction required in order to resolve on it own, but is needed for the merge.
The code is intentionally error-happy at the moment to expose these questions, there's a design pass to make the compactor intentionally prune history, which would require the readers to use the oldest available crdt as the beginning of history. This would allow even flattened databases to serve without error.
Another approach is to move "online" for block search when the block is not found. It might be that servers run in this mode and clients rely on pruned history. This effectively reads through the compaction by chasing the history back before compaction (today we log the compact cids but don't dereference them yet).
Implementing this will simplify the compaction model on the client because we can compact to nearly flat history as long as it is older than the conflict merge window we care about (maybe very flat for some apps).