internal override async Task HandleLinearizationPoint(IList <TableResult> successfulBatchResult) { PSharpRuntime.Assert(currentReferenceOutcome == null, "{0}: The call already reported a linearization point.", machineId); this.successfulBatchResult = successfulBatchResult; currentReferenceOutcome = await Catching <StorageException> .RunAsync( () => annotationProxy.AnnotateLastBackendCallAsync(currentReferenceCall, null)); }
// This method does not log what the call is, since there's no way to // know what's inside the delegates. Use RunBatchAsync or RunQueryAtomicAsync. async Task RunCallAsync(TableCall originalCall, MirrorTableCall referenceCall) { // TODO: All assertions should show what the call was. // XXX: We currently have no way to detect incorrect interleaving of // backend calls and AnnotateLastOutgoingCall here. Most incorrect // interleavings will cause an error on the TablesMachine, but some // may go undetected. // - FIXME: A missing annotation will cause all machines to become blocked, and // P# considers that a success! To fix that, we need to enable liveness checking. currentReferenceCall = referenceCall; object actualOutcome = await Catching <StorageException> .RunAsync(() => originalCall(migratingTable)); // Verify that successfulBatchResult was correct if specified. // (Ideally, we'd also catch if it isn't specified when it should // be, but that's less of a risk as it will likely cause ETag // mismatches anyway.) if (successfulBatchResult != null) { var successfulBatchOutcome = new Outcome <object, StorageException>(successfulBatchResult); PSharpRuntime.Assert(BetterComparer.Instance.Equals(successfulBatchOutcome, actualOutcome), "{0} incorrect successfulBatchResult:\n{1}\nExpected:\n{2}\n", machineId, BetterComparer.ToString(successfulBatchOutcome), BetterComparer.ToString(actualOutcome)); } PSharpRuntime.Assert(currentReferenceOutcome != null, "{0}: The call completed without reporting a linearization point.", machineId); PSharpRuntime.Assert(BetterComparer.Instance.Equals(actualOutcome, currentReferenceOutcome), "{0} table call outcome is incorrect:\n{1}\nExpected:\n{2}\n", machineId, BetterComparer.ToString(actualOutcome), BetterComparer.ToString(currentReferenceOutcome)); Console.WriteLine("{0} table call outcome is correct:\n{1}", machineId, BetterComparer.ToString(actualOutcome)); // Reset fields currentReferenceCall = null; successfulBatchResult = null; currentReferenceOutcome = null; }