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

Improved Saga Support for 3.0 #988

Closed
jeremydmiller opened this issue Aug 5, 2024 · 3 comments
Closed

Improved Saga Support for 3.0 #988

jeremydmiller opened this issue Aug 5, 2024 · 3 comments
Milestone

Comments

@jeremydmiller
Copy link
Member

While the 3.0 work is happening, now is a good time to talk about possible improvements to the Saga support. I've got a couple things in mind:

Concurrency Protection

You could fake the concurrency a little bit with Marten, but it would be nice to have first class concurrency protection with sagas so that parallel work doesn't necessarily overwrite Saga state. My only ideas so far are based on Marten's FetchForWriting() implementation:

  1. An optimistic approach whereas we add versioning to the stateful Saga, which is easy enough. In this case we will "know" the current revision of the saga because we're loading it to begin with. On committing the saga state we'll have the database reject the changes if the saga has been changed since the transaction started
  2. Little bit harder, and probably only useful for Marten for now and even then with Marten development, use an exclusive lock on the saga in the database. That'll force the single file through that saga

In all cases, throw a distinct exception so that it's easy to apply retry rules on any operations against the saga

Lightweight database storage

Especially when using SQL Server or Postgresql w/o Marten, use a crude table storage and JSON serialization. Quicker and easier the messing around with EF Core mapping IMO

@jeremydmiller jeremydmiller added this to the 3.0 milestone Aug 5, 2024
@elexisvenator
Copy link
Contributor

I have only just started experimenting with sagas myself, does [SagaIdentity] work with the aspnetcore endpoint integration? I haven't tested nor really thought through how rational of an idea that is yet though.

Is saga state documents (in marten integration)? Asking because that would lead to some useful functionality around being able to query saga state for inspection/monitoring purposes.

Other than that, optimistic concurrency sounds like a great idea 👍

@jeremydmiller
Copy link
Member Author

@elexisvenator So:

does [SagaIdentity] work with the aspnetcore endpoint integration?

Yes, exact same mechanics and underlying code

Is saga state documents (in marten integration)?

If using Marten, yes

@jeremydmiller
Copy link
Member Author

For the Marten saga persistence, then ended up using IRevisioned for optimistic concurrency. I'm voting to punt exclusive concurrency for now

jeremydmiller added a commit that referenced this issue Aug 19, 2024
wip: using IRevisioned with Saga

First bit of working code for lightweight Sql Server based sagas

End to end functionality with the lightweight Sql Server saga persistence

Mild refactoring of the saga code

Full end to end Sql Server lightweight sagas

Fixed after applying the lightweight Sql Server sagas

Lightweight saga persistence for Postgresql

Updated docs for sagas
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

2 participants