Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: Handling Concurrency #56

Open
ylorph opened this issue Apr 20, 2021 · 4 comments
Open

Problem: Handling Concurrency #56

ylorph opened this issue Apr 20, 2021 · 4 comments

Comments

@ylorph
Copy link
Owner

ylorph commented Apr 20, 2021

  • @MerrionComputing concurrency 🐊
  • pessimistic:
    • checkout / checkin
  • optimistic locks
  • no concurrency
  • stream design
  • merge
  • deduplicate
  • Actor Model
@MerrionComputing
Copy link
Contributor

Does the actor model handle concurrency or more prevent it (by being effectively synchronous single threaded inside the actor)?

@ylorph
Copy link
Owner Author

ylorph commented Sep 15, 2021

well it a way to prevent concurrent append to a stream , as well as keeping it's projectected state in memory.
( if only 1 actor has ownership of appending to a stream )

@MerrionComputing
Copy link
Contributor

Added some thoughts in this article: https://github.com/MerrionComputing/Presentations/blob/master/Articles/taming-the-concurrency-crocodile.md

@mattbishop
Copy link

I've been working on this problem in Evently, and came up with a solution I'm calling Atomic Append. Basically one creates a selector to look for events across all streams in the ledger, and then if the read model from that stream is satisfactory, Evently will use that same selector to atomically append the new event. If the selector has new events in the interim, it rejects the append and the client can try again with another hydration or communicate the failure. This is similar to Solution 3 in @MerrionComputing's article, but simpler.

The example I use in Evently is Account Registration where one can only register unique usernames. First a command looks for account registration events where the username in the event matches the command's username. If no events are found, the append request is sent using the selector ID. Evently checks the selector and appends the event if the attached selector selects no new events. This atomicity mirrors the SQL Atomicity and its INSERT / UPDATE ... WHERE statements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants