File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -944,6 +944,13 @@ func TestEdgePolicyCRUD(t *testing.T) {
944
944
require .NoError (t , graph .UpdateEdgePolicy (ctx , edge1 ))
945
945
require .NoError (t , graph .UpdateEdgePolicy (ctx , edge2 ))
946
946
947
+ // Even though we assert at the DB level that any newer edge
948
+ // update has a newer timestamp, we need to still gracefully
949
+ // handle the case where the same exact policy is re-added since
950
+ // it could be possible that our batch executor has two of the
951
+ // same policy updates in the same batch.
952
+ require .NoError (t , graph .UpdateEdgePolicy (ctx , edge1 ))
953
+
947
954
// Use the ForEachChannel method to fetch the policies and
948
955
// assert that the deserialized policies match the original
949
956
// ones.
Original file line number Diff line number Diff line change @@ -780,7 +780,15 @@ func (s *SQLStore) UpdateEdgePolicy(ctx context.Context,
780
780
from , to , isUpdate1 , err = updateChanEdgePolicy (
781
781
ctx , tx , edge ,
782
782
)
783
- if err != nil {
783
+ // It is possible that two of the same policy
784
+ // announcements are both being processed in the same
785
+ // batch. This may case the UpsertEdgePolicy conflict to
786
+ // be hit since we require at the db layer that the
787
+ // new last_update is greater than the existing
788
+ // last_update. We need to gracefully handle this here.
789
+ if errors .Is (err , sql .ErrNoRows ) {
790
+ return nil
791
+ } else if err != nil {
784
792
log .Errorf ("UpdateEdgePolicy faild: %v" , err )
785
793
}
786
794
You can’t perform that action at this time.
0 commit comments