Support Happens-Before Constraints in Spec.AllowsConcurrent #28
Replies: 3 comments
|
This is what I learned implementing this -> #31 Accordant explores orderings by building a state graph. At each state, any remaining step function can be picked and applied. So to implement this we can add a gate: a step function with predecessors refuses to run until all its predecessors have appeared earlier. What this enables: Before this PR, Accordant linearizability checking was limited to fully concurrent groups (all operations overlap) or fully sequential ones. Now dependencies can be expressed |
|
Thank you for contributing Tomás Pérez Álvarez (@Tomperez98) - genuinely appreciated. |
|
With this feature checked-in, now we'll have to see how to either update the existing doc pages, or add a new one that talks about this. A sample that's given a set of request response pairs along with wall-clock time, and then analyzes it, and then automatically either calls spec.Allows (if no overlap) or spec.AllowsConcurrent with happens-before (if overlap) can be useful. And if we did that, we would have to build some safeguards around number of concurrent calls as too many at the same time can take a long time to validate. The redeeming factor here is that most bugs can be found with just a few concurrent races (particularly when paired with deterministic simulation testing techniques, or even randomly injected delays/sleeps) in the backend so this isn't a big limitation in practice. Thank you for the work here! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Accordant currently provides two related ways to validate observed operation results against a specification:
Spec.Allowsvalidates an operation sequentially from the current state.Spec.AllowsConcurrentvalidates a group of operation calls by checking whether their observed results can be explained by some valid sequential ordering.The second capability supports linearizability checking.
Linearizability and sequential consistency are closely related, but they differ in one important respect:
When every operation in a group is mutually concurrent—meaning that all their execution intervals overlap—there is no real-time ordering to preserve between them. In that case, linearizability and sequential consistency impose the same requirement: any sequential ordering that explains the results is acceptable.
Spec.AllowsConcurrenthandles this case well. For example, suppose two clients concurrently attempt to reserve the same available resource. One client will succeed and the other will fail. Accordant considers both possible sequential orderings and determines whether one of them explains the observed responses.A fully sequential history can also be represented today by validating one operation at a time with
Spec.Allows, or by usingSpec.AllowsConcurrentwith a single operation.The limitation arises when a history contains both overlapping operations and known real-time ordering constraints.
Consider this execution:
In this history:
The operations therefore form a partial order rather than either a simple sequence or a set of fully mutually concurrent calls.
Today, placing A, B, and C in the same
Spec.AllowsConcurrentcall does not preserve the constraint that A happened before C. The checker can consider an ordering in which C appears before A. Such an ordering can satisfy sequential consistency, but it is not a valid linearization of the observed history because it violates wall-clock precedence.Proposed change
Extend
Spec.AllowsConcurrentso that callers can specify that one operation call happened before another.For the example above, the caller will provide the relationship:
Accordant will then consider only sequential orderings that preserve this dependency. Operations without a happens-before relationship will still be reordered freely.
This will allow
Spec.AllowsConcurrentto represent a general concurrent history as a DAG:The same capability will allow Accordant to validate recorded request-and-response traces together with their wall-clock timing. Accordant can already validate the observed operations and responses; the additional timing information will let it preserve real-time ordering by deriving a happens-before dependency whenever one operation completes before another begins. Operations whose execution intervals overlap will remain unordered.
This will be an additive, backward-compatible change. Existing uses of
Spec.AllowsConcurrentwithout dependencies will continue to behave as they do today, treating all supplied operations as mutually concurrent.Most of the primitive building blocks for this feature already exist: Accordant can already validate sequential operations and search for a valid ordering of concurrent operations. The requested extension is to constrain that search using caller-provided happens-before relationships.
With this addition, Accordant will support full linearizability checking for general, partially ordered operation histories.
All reactions