Merge pull request #17966 from serathius/robustness-relax

Relax assumptions about all client request persisted in WAL to only require first and last request to be persisted
This commit is contained in:
Marek Siarkowicz 2024-05-09 17:51:27 +02:00 committed by GitHub
commit dc35b6493f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -156,17 +156,38 @@ func validatePersistedRequestMatchClientRequests(reports []report.ClientReport,
}
}
for requestDump, op := range clientRequests {
request := op.Input.(model.EtcdRequest)
response := op.Output.(model.MaybeEtcdResponse)
if response.Error != "" || request.IsRead() {
continue
}
_, found := persistedRequestSet[requestDump]
if !found {
return fmt.Errorf("succesful client write %+v was not persisted, required to validate", requestDump)
var firstOp, lastOp porcupine.Operation
for _, r := range reports {
for _, op := range r.KeyValue {
request := op.Input.(model.EtcdRequest)
response := op.Output.(model.MaybeEtcdResponse)
if response.Error != "" || request.IsRead() {
continue
}
if firstOp.Call == 0 || op.Call < firstOp.Call {
firstOp = op
}
if lastOp.Call == 0 || op.Call > lastOp.Call {
lastOp = op
}
}
}
firstOpData, err := json.Marshal(firstOp.Input.(model.EtcdRequest))
if err != nil {
return err
}
_, found := persistedRequestSet[string(firstOpData)]
if !found {
return fmt.Errorf("first succesful client write %s was not persisted, required to validate", firstOpData)
}
lastOpData, err := json.Marshal(lastOp.Input.(model.EtcdRequest))
if err != nil {
return err
}
_, found = persistedRequestSet[string(lastOpData)]
if !found {
return fmt.Errorf("last succesful client write %s was not persisted, required to validate", lastOpData)
}
return nil
}