Sublime article.
–––
On that note, I have a question that keeps coming to mind regarding CCC:
While an optimistic context check before appending is usually sufficient for 99% of use cases (either uncritical or not perfectly simultaneous), I'm curious about how you handle the 1% "perfect concurrency" edge cases (Write Skew anomalies).
Get Kevin 心学’s stories in your inbox
Join Medium for free to get updates from this writer.
For example, two parallel transactions check if a specific username is available. Both read the same context simultaneously, find it available, and simultaneously append a UserRegistered event for that username.
In other words, if two concurrent transactions query the same context and simultaneously append events relevant to that context, how do you concretely prevent conflicts at the infrastructure level (e.g., in Postgres)? Do you rely on advisory locks (like pg_advisory_xact_lock), maintain a separate tag-versioning table, or use another mechanism?
As a bonus, if you happen to have a concrete code snippet or example of how you implement this, I would love to see it!
Thanks Rico!


