jet / equinox

.NET event sourcing library with CosmosDB, DynamoDB, EventStoreDB, message-db, SqlStreamStore and integration test backends. Focused at stream level; see https://github.com/jet/propulsion for cross-stream projections/subscriptions/reactions

Home Page:https://github.com/jet/dotnet-templates

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: Cosmos Db Consistency

mpaul31 opened this issue · comments

Hello,

I am reading through the documentation and trying to understand how this are setup and work with Cosmos Db. First, which consistency model must be used? Is multi readers / writers supported? I'm reading through the section Reading from the Storage Model and trying to work out in my head how we can be sure we are reading the latest state when IfNoneMatch is Found in the presence of multiple writers or not currently in cache. Isn't it possible we could be returned a document that is not the most recent and our command processing logic may in turn not emit emits thus leaving the system in an inconsistent state?

Thank you and any information you could provide would be great!

TL;DR Ultimately every write is subject to an etag or expectedVersion matching in the write (in the sync stored proc)

The writing loop / consistency check scheme means it doesnt matter if the initial sync of the Stream.Transact fails to get the latest version, it will all get reconciled (even if it guaranteed latest, it can still be superseded). Any starting point will do (see xmldoc re AllowStale)

related: Equinox uses session consistency - there's some missing wiring wrt that :- #195 - this would provide am full read-your-writes guarantee (but would be similarly not critical from the point of view of guaranteeing writes are consistent and non-corrupting)

I'm working on diagrams atm that'll likely be relevant for you: https://github.com/jet/equinox/blob/diag/DOCUMENTATION.md#code-diagrams-for-equinoxcosmos