0

I am reading Microservices Patterns by Chris. In his book, he gave some example, which I could not able to understand section 5.2.1. The problem with fuzzy boundaries

Here is the link to read online. Can you someone please look into section 5.2.1 and help me understand what exactly the issue with fuzzy boundaries?

I didn't get clearly especially below statement:

In this scenario, Sam reduces the order total by $X and Mary reduces it by $Y. As a result, the Order is no longer valid, even though the application verified that the order still satisfied the order minimum after each consumer’s update

In above statement, can someone please explain me, why Order is no longer valid?

moonwave99
  • 21,957
  • 3
  • 43
  • 64
john
  • 925
  • 1
  • 12
  • 20

1 Answers1

0

In above statement, can someone please explain me, why Order is no longer valid?

The business problem that Chris Richardson is using in this example assumes that (a) the system should ensure that orders are always valid, and (b) that valid orders exceed some minimum amount.

Minimum amount is determined by a sum of the order_items associated with a specific order.

The "fuzzy boundary" issue comes about because the code in question allows Sam and Mary to manipulate order_items directly; in other words, writing changes to order items does not lock the other items of the order.

If Sam and Mary were forced to acquire a lock on the entire order before validating their changes, then you wouldn't have a problem; the second person would see the changes made by the first.

Alternatively, locking at the level of the order_item would be fine if you weren't trying to ensure that the set of order items satisfy some property. Take away the constraint on the total order cost, and Sam and Mary only need to get locks on their specific item.

VoiceOfUnreason
  • 52,766
  • 5
  • 49
  • 91