GreanTech / AtomEventStore

A server-less .NET Event Store based on the Atom syndication format
MIT License
117 stars 14 forks source link

AtomEventObserver<T> should attempt to repair stale last link #98

Closed ploeh closed 10 years ago

ploeh commented 10 years ago

As described in #48, the update operation that updates the index document's last link may occasionally fail. When that happens, the last link becomes stale; it still points to an existing document, but no longer the last document (meaning: the newest document).

Subsequent write operations should attempt to detect this situation and remedy the situation.

Specifically, when AtomEventObserver<T>.OnNext or AtomEventObserver<T>.AppendAsync is invoked, it should check that the index document's last link points to a document that has no next link. If the document pointed to has a next link, it means that the last link points to a document that's no longer the last document. In this case, the method should recursively follow all next links until it finds a document that has no next link. This is the current last document, and the index document's last link should be updated with the address of that current last document.

Perhaps it may make sense to do this after completing #96. Also, the implementation for finding the true last document may be reused from the implementation of #97.

ploeh commented 10 years ago

Turns out this was already done in c73242aa562bd4b32ff9bedb077869b8fb8e870e.