Using uuid instead time value to make unique matchId. (#1437)

* use uuid for matchId instead time value because matchfunction seems to be called concurrently so I got 'multiple match functions used same match_id:' errors.

* use uuid for matchId instead time value because matchfunction seems to be called concurrently so I got 'multiple match functions used same match_id:' errors.

* Revert "use uuid for matchId instead time value because matchfunction seems to be called concurrently so I got 'multiple match functions used same match_id:' errors."

This reverts commit 99b4e92ab9f1bc44feae3475702e769c83320f5a.

* use uuid for matchId instead time value because matchfunction seems t…
o be called concurrently so I got 'multiple match functions used same match_id:' errors.

Co-authored-by: Mridul Goswami <mridulgoswami@google.com>
Co-authored-by: Jon Foust <38893532+syntxerror@users.noreply.github.com>
This commit is contained in:
Vong Kong
2022-06-21 08:13:30 -07:00
committed by GitHub
parent 7af54ee1bc
commit 120a114647

View File

@ -17,7 +17,8 @@ package mmf
import (
"fmt"
"log"
"time"
"github.com/rs/xid"
"open-match.dev/open-match/pkg/matchfunction"
"open-match.dev/open-match/pkg/pb"
@ -64,7 +65,6 @@ func (s *MatchFunctionService) Run(req *pb.RunRequest, stream pb.MatchFunction_R
func makeMatches(p *pb.MatchProfile, poolTickets map[string][]*pb.Ticket) ([]*pb.Match, error) {
var matches []*pb.Match
count := 0
for {
insufficientTickets := false
matchTickets := []*pb.Ticket{}
@ -85,13 +85,11 @@ func makeMatches(p *pb.MatchProfile, poolTickets map[string][]*pb.Ticket) ([]*pb
}
matches = append(matches, &pb.Match{
MatchId: fmt.Sprintf("profile-%v-time-%v-%v", p.GetName(), time.Now().Format("2006-01-02T15:04:05.00"), count),
MatchId: fmt.Sprintf("profile-%v-%s", p.GetName(), xid.New().String()),
MatchProfile: p.GetName(),
MatchFunction: matchName,
Tickets: matchTickets,
})
count++
}
return matches, nil