no need to handle duplicate evals anymore

This commit is contained in:
Mahmood Ali 2020-07-15 11:14:49 -04:00
parent a314744210
commit f4a921f2be
2 changed files with 1 additions and 21 deletions

View file

@ -686,10 +686,7 @@ func (n *nomadFSM) applyUpdateEval(buf []byte, index uint64) interface{} {
}
func (n *nomadFSM) upsertEvals(index uint64, evals []*structs.Evaluation) error {
if err := n.state.UpsertEvals(index, evals); len(evals) == 1 && err == state.ErrDuplicateEval {
// the request is a duplicate, ignore processing it
return nil
} else if err != nil {
if err := n.state.UpsertEvals(index, evals); err != nil {
n.logger.Error("UpsertEvals failed", "error", err)
return err
}

View file

@ -2540,19 +2540,6 @@ func (s *StateStore) UpsertEvalsTxn(index uint64, evals []*structs.Evaluation, t
return nil
}
// ErrDuplicateEval indicates that the eval is already present in state and ought not
// to be reprocessed again.
//
// Such duplication might occur in the background compatibility path in job registration
// or deregistration
var ErrDuplicateEval = fmt.Errorf("eval already exists")
func isPotentialDuplicateEval(eval *structs.Evaluation) bool {
return eval.Status == structs.EvalStatusPending &&
(eval.TriggeredBy == structs.EvalTriggerJobRegister ||
eval.TriggeredBy == structs.EvalTriggerPeriodicJob)
}
// nestedUpsertEvaluation is used to nest an evaluation upsert within a transaction
func (s *StateStore) nestedUpsertEval(txn *memdb.Txn, index uint64, eval *structs.Evaluation) error {
// Lookup the evaluation
@ -2561,10 +2548,6 @@ func (s *StateStore) nestedUpsertEval(txn *memdb.Txn, index uint64, eval *struct
return fmt.Errorf("eval lookup failed: %v", err)
}
if existing != nil && isPotentialDuplicateEval(eval) {
return ErrDuplicateEval
}
// Update the indexes
if existing != nil {
eval.CreateIndex = existing.(*structs.Evaluation).CreateIndex