I am currently analysing the project ddd-library which is really helping in learning designing a system based on DDD principles. However there is one thing I have a problem with.
In case of placing a book on hold, first the Patron Aggregate is updated (it holds now a book) and then the Book Aggregate is updated. Whether it is an atomic transaction or eventual consistent, in both cases it is kind of problematic.
Atomic Transaction: Obviously we shouldn't modify 2 Aggregates in one transaction so there is that, but I dont think it would come with any other problems here (Maybe one could live with breaking the 'one aggregate modification per transaction' rule?)
Eventual Consistent: When the Patron is updated first and now 'holds' the book but the book Aggregate is not updated yet to become a BookOnHold, there might be a race condition when someone else at the same time tries to put it on hold. That patron aggregate would be updated and maybe its event is propagated first to the Book Aggregate. In this case the system would be in an invalid state, because the first Patron has a book on hold but the actual Book Aggregate is being hold by the second Patron.
Question: How would you solve this? Is there a better way to model the Aggregates? Is a Process Manager or Saga an appropiate Solution here?
Suggestions (Saga/Process Manager): It would start when the patron aggregate was updated. When after some time the referenced Book isn't updated, it could revert the Patron modification and raise some domain events to handle the case. So that way the eventual consistency solution wouldn't run into the problem I stated right? Or am I overthinking here or missing something?