Question Details

No question body available.

Tags

uml diagrams parallelism sequence-diagram

Answers (3)

March 13, 2025 Score: 5 Rep: 79,237 Quality: Medium Completeness: 30%

If your intention is to have a picture for conversation, my preference for such a scenario is a sequence diagram.

My first thought was to use a sequence diagram but it doesn't allow tracking state. For instance, what is the value in the DB and Cache at any given point?

You can show the state of an object with a box with angled sides over the lifeline. That allows you to track the value in the DB and Cache. At any point, that value will be whatever was mentioned in the most recent angled box.

Also, PlantUML and Mermaid implementations allow overlapping activations, but only if one activation is completed contained by another. They can't have partial overlap which the timing I'm seeing has.

With a diagram that is primarily used for communication, if the tools get into your way for a specific use case, just switch to another tool for that one case. Even if that other tool doesn't know about UML and is primarily intended for general diagrams/drawings.

March 13, 2025 Score: 3 Rep: 17,180 Quality: Medium Completeness: 80%

https://plantuml.com/sequence-diagram

Firstly, according to PlantUML's documentation, Sequence Diagrams can be used with or without activations. (Activation refers to the colored vertical bar placed over an object or agent's lifeline.)

Using an activation implies a nested relationship. Not using an activation means that the arrow would shoot out directly from the lifeline, and this is totally okay in PlantUML's Sequence Diagrams, according to their examples.

The values being transmitted can be put on the arrows themselves as text label.

The values as known by each object/agent can be added as a note next to their lifeline. Such notes are listed altogether with the arrows, so they will be rendered correctly as vertically sorted.

note  of 
... 
end note

Regarding the deeper question of explaining various race conditions, remember that each sequence diagram is used to explain one particular scenario. Typically it only takes one scenario to show that a race condition exists in a certain design; but it usually takes multiple scenarios to enumerate the various race conditions that could possibly be triggered. That means creating multiple sequence diagrams - one for each of them.

March 13, 2025 Score: 0 Rep: 1,980 Quality: Low Completeness: 40%

How about this:

@startuml actor A actor B actor C collections cache database db db -> A : reads old value db -> db : changes value db -> B : reads new value B -> cache : writes new value A -> cache : writes old value cache -> C : reads old value @enduml