Fix concurrent map/struct races in sshCache and lazyManifest#6243
Conversation
sshCache.endpoints is accessed from multiple goroutines when parallel batch API workers resolve SSH credentials simultaneously. Replace the plain map with sync.Map to prevent the "concurrent map writes" panic. lazyManifest.Upgrade() can be called concurrently, causing multiple concreteManifest instances to be created. Add a mutex to ensure only one is created.
|
Side note: one of these race condition tests only reproduces when run with |
chrisd8088
left a comment
There was a problem hiding this comment.
Hey, thanks for this PR, it looks great!
IIUC, the changes in the two packages (lfshttp and tq) are unrelated to each other, so they could be separate commits. But that's merely a procedural detail, and the added thread safety is a clear improvement.
Thanks for the note! I actually found both tests would report an issue when |
In #6234
sshCache.endpointsis accessed from multiple goroutines when parallel batch API workers resolve SSH credentials simultaneously. Replace the plain map withsync.Mapto prevent the "concurrent map writes" panic.lazyManifest.Upgrade()can be called concurrently, causing multiple concreteManifest instances to be created. Add a mutex to ensure only one is created.