diff --git a/state/applicationoffers.go b/state/applicationoffers.go index 88877bc187a..6a9f3e324c8 100644 --- a/state/applicationoffers.go +++ b/state/applicationoffers.go @@ -272,7 +272,7 @@ func (op *RemoveOfferOperation) Build(attempt int) (ops []txn.Op, err error) { ops = append(ops, proxyOps...) } - sortRemoveOpsLast(ops) + sortRemovalOpsLast(ops) return ops, nil } diff --git a/state/modeloperation.go b/state/modeloperation.go index 4ddd9431a3c..c91a420aa7e 100644 --- a/state/modeloperation.go +++ b/state/modeloperation.go @@ -5,7 +5,7 @@ package state import ( "sort" - + "github.com/juju/errors" "github.com/juju/mgo/v3/txn" jujutxn "github.com/juju/txn/v3" @@ -107,7 +107,7 @@ func (st *State) ApplyOperation(op ModelOperation) error { return op.Done(err) } -// sortRemoveOpsLast re-orders a slice of transaction operations so that any +// sortRemovalOpsLast re-orders a slice of transaction operations so that any // document removals occur at the end of the slice. // This is important for server-side transactions because of two execution // characteristics: @@ -117,7 +117,7 @@ func (st *State) ApplyOperation(op ModelOperation) error { // on the same document to pass the assertions, then fail with "not found" upon // actual processing. // Legacy client-side transactions do not exhibit this behaviour. -func sortRemoveOpsLast(ops []txn.Op) { +func sortRemovalOpsLast(ops []txn.Op) { sort.Slice(ops, func(i, j int) bool { return !ops[i].Remove && ops[j].Remove }) diff --git a/state/relation.go b/state/relation.go index 7d2210e06ab..cdcce2a4d15 100644 --- a/state/relation.go +++ b/state/relation.go @@ -377,7 +377,7 @@ func (op *DestroyRelationOperation) internalDestroy() (ops []txn.Op, err error) } ops = append(ops, destroyOps...) - sortRemoveOpsLast(ops) + sortRemovalOpsLast(ops) return ops, nil }