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) {
944944 require .NoError (t , graph .UpdateEdgePolicy (ctx , edge1 ))
945945 require .NoError (t , graph .UpdateEdgePolicy (ctx , edge2 ))
946946
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+
947954 // Use the ForEachChannel method to fetch the policies and
948955 // assert that the deserialized policies match the original
949956 // ones.
Original file line number Diff line number Diff line change @@ -780,7 +780,15 @@ func (s *SQLStore) UpdateEdgePolicy(ctx context.Context,
780780 from , to , isUpdate1 , err = updateChanEdgePolicy (
781781 ctx , tx , edge ,
782782 )
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 {
784792 log .Errorf ("UpdateEdgePolicy faild: %v" , err )
785793 }
786794
You can’t perform that action at this time.
0 commit comments