albe / node-event-storage

An optimized event store for node.js
MIT License
34 stars 4 forks source link

Allow reindexing a Storage #24

Open albe opened 7 years ago

albe commented 7 years ago

This is a very expensive operation, as it involves a full database scan, but it can help when indexes get broken and would technically allow for rewriting storage partitions.

Edit: This is not easily possible without completely losing original global document order, since the global version number needs either to be stored in the document record itself (which means writing the index before the document), OR assume that the documents haven't changed in amount and order, so going through the existing index and keeping that order.

An midway alternative would be to just guarantee a chronological order and reindex on commit timestamp (which could still be unrelated to actuall document creation/event occurence order).

albe commented 5 years ago

Alternatives:

albe commented 5 years ago

Depending on the goals, following solutions are viable:

partial global order gives best results vs. implementation cost, but no strong guarantees. The partial global order could be "upgraded" to TrueTime though, by storing two timestamps. As long as a single writer is still used (no replication in place), this would still provide a strong consistency with a monotonic clock in the system and write-timestamp given by the writer.

albe commented 4 years ago

With #80 a global order can be established via the monotonic clock stamp and/or the sequence number in the document header.