cli/internal/analytics/client.go: data races on global client and cachedSyncEventDetails — no mutex protection
Author: praneshnikharCreated Jul 27, 2026Updated Jul 27, 2026
CLI: Data races in cli/internal/analytics/client.go
File: cli/internal/analytics/client.go
Problem: Two global variables are accessed from multiple goroutines without synchronization:
client(rudderstack.Client) — read/written inInitClient,TrackLoginSuccess,TrackSyncStarted,TrackSyncCompleted,TrackInitStarted,TrackInitCompleted,Close, and all other tracking functions.cachedSyncEventDetails(*eventDetails) — read ingetSyncEventDetails, written inrefreshSyncEventDetails.
Both are accessed across goroutines (sync runs spawn goroutines that call tracking functions), but neither is protected by a mutex. The Go race detector reliably flags this.
Fix: Add sync.RWMutex for each variable. clientMu protects client, eventMu protects cachedSyncEventDetails. Introduce a getClient() helper that acquires a read lock.
Reproduction
Run cloudquery sync with the Go race detector enabled:
go run -race ./cli/main.go sync <config>Or in tests:
go test -race ./cli/internal/analytics/...The race detector will report concurrent read/write accesses to both client and cachedSyncEventDetails.
Source: cloudquery/cloudquery