@@ -62,47 +62,27 @@ type Config struct {
6262 ExpectRevisionUnique bool
6363}
6464
65- func prepareAndCategorizeOperations (reports []report.ClientReport ) ([]porcupine.Operation , []porcupine.Operation ) {
66- patchedOperations := patchFailedRequestWithInfiniteReturnTime (reports )
67- return relevantOperations (patchedOperations ), filterSerializableOperations (patchedOperations )
68- }
69-
70- func relevantOperations (operations []porcupine.Operation ) []porcupine.Operation {
71- var ops []porcupine.Operation
72- for _ , op := range operations {
73- request := op .Input .(model.EtcdRequest )
74- resp := op .Output .(model.MaybeEtcdResponse )
75- // Remove failed read requests as they are not relevant for linearization.
76- if resp .Error == "" || ! request .IsRead () {
77- ops = append (ops , op )
78- }
79- }
80- return ops
81- }
82-
83- func filterSerializableOperations (operations []porcupine.Operation ) []porcupine.Operation {
84- resp := []porcupine.Operation {}
85- for _ , op := range operations {
86- request := op .Input .(model.EtcdRequest )
87- if request .Type == model .Range && request .Range .Revision != 0 {
88- resp = append (resp , op )
89- }
90- }
91- return resp
92- }
93-
94- func patchFailedRequestWithInfiniteReturnTime (reports []report.ClientReport ) []porcupine.Operation {
95- operations := make ([]porcupine.Operation , 0 )
65+ func prepareAndCategorizeOperations (reports []report.ClientReport ) (linearizable []porcupine.Operation , serializable []porcupine.Operation ) {
9666 for _ , report := range reports {
97- for _ , operation := range report .KeyValue {
98- // Failed writes can still be persisted, setting to infinite for now as we don't know when request has taken effect.
99- if operation .Output .(model.MaybeEtcdResponse ).Error != "" {
100- operation .Return = math .MaxInt64
67+ for _ , op := range report .KeyValue {
68+ request := op .Input .(model.EtcdRequest )
69+ response := op .Output .(model.MaybeEtcdResponse )
70+ // serializable operations include only Range requests on non-zero revision
71+ if request .Type == model .Range && request .Range .Revision != 0 {
72+ serializable = append (serializable , op )
73+ }
74+ // Remove failed read requests as they are not relevant for linearization.
75+ if response .Error == "" || ! request .IsRead () {
76+ // For linearization, we set the return time of failed requests to MaxInt64.
77+ // Failed requests can still be persisted, however we don't know when request has taken effect.
78+ if response .Error != "" {
79+ op .Return = math .MaxInt64
80+ }
81+ linearizable = append (linearizable , op )
10182 }
102- operations = append (operations , operation )
10383 }
10484 }
105- return operations
85+ return linearizable , serializable
10686}
10787
10888func checkValidationAssumptions (reports []report.ClientReport , persistedRequests []model.EtcdRequest ) error {
0 commit comments