indeedeng / iwf

iWF is a WorkflowAsCode microservice orchestration platform offering an orchestration coding framework and service for building resilient, fault-tolerant, scalable long-running processes
MIT License
537 stars 55 forks source link

Fix concurrent write panic for parallel test #472

Open longquanzheng opened 2 weeks ago

longquanzheng commented 2 weeks ago

Maybe using sync.Map: https://medium.com/@luanrubensf/concurrent-map-access-in-go-a6a733c5ffd1 instead here:

https://github.com/indeedeng/iwf/blob/2cc3fbf1f49da9349c04f79f09acf0247a0bf5b9/integ/workflow/parallel/routers.go#L45

fatal error: concurrent map writes

goroutine 7953 [running]:
github.com/indeedeng/iwf/integ/workflow/parallel.(*handler).ApiV1WorkflowStateStart(0xc000fd0138, 0xc00053f600)
    /home/runner/work/iwf/iwf/integ/workflow/parallel/routers.go:45 +0x274
github.com/gin-gonic/gin.(*Context).Next(...)
    /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/gin-gonic/gin.CustomRecoveryWithWriter.func1(0xc00053f600)
    /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/recovery.go:102 +0x6f
github.com/gin-gonic/gin.(*Context).Next(...)
    /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/gin-gonic/gin.LoggerWithConfig.func1(0xc00053f600)
    /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/logger.go:240 +0xdd
github.com/gin-gonic/gin.(*Context).Next(...)
    /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0xc0004f0000, 0xc00053f600)
    /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:620 +0x64e
github.com/gin-gonic/gin.(*Engine).ServeHTTP(0xc0004f0000, {0x199f280, 0xc00035d260}, 0xc000527540)
    /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:576 +0x1b2
net/http.serverHandler.ServeHTTP({0x199adc8?}, {0x199f280?, 0xc00035d260?}, 0x6?)
    /opt/hostedtoolcache/go/1.23.2/x64/src/net/http/server.go:3210 +0x8e
net/http.(*conn).serve(0xc000e730e0, {0x19a6538, 0xc000c22f30})
    /opt/hostedtoolcache/go/1.23.2/x64/src/net/http/server.go:2092 +0x5d0
created by net/http.(*Server).Serve in goroutine 7791
    /opt/hostedtoolcache/go/1.23.2/x64/src/net/http/server.go:3360 +0x485
longquanzheng commented 1 week ago

happening again in https://github.com/indeedeng/iwf/actions/runs/11747452963/job/32729405344?pr=476