Skip to content

Commit

Permalink
fix potential coroutine race
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-goodisman committed Apr 26, 2024
1 parent 6c1ac80 commit 1f772fc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ func main() {
if err != nil {
panic(fmt.Sprintf("[%d] Error initializing Redis client: %s", i, err.Error()))
}
defer func() {
defer func(ordinal int) {
for _, redisClient := range redisClients {
redisCloseErr := redisClient.Close()
if redisCloseErr != nil {
log.Log.Errorw("Error closing Redis client",
"error", redisCloseErr,
"i", i)
"i", ordinal)
}
}
}()
}(i)
log.Log.Infow("Initialized connection to Redis", "i", i)

aggregatedRedisClients[i] = redisClients
Expand All @@ -104,7 +104,7 @@ func main() {
DedupeExpiration: config.RedisDedupeExpiration(),
MetadataPrefix: config.RedisMetadataPrefix(),
}, stopRedisPub, ordinal)
log.Log.Infow("Redis publisher completed", "i", i)
log.Log.Infow("Redis publisher completed", "i", ordinal)
waitGroup.Done()
}(i)
log.Log.Info("Started up processing goroutines")
Expand Down

0 comments on commit 1f772fc

Please sign in to comment.