#6532 Make plugin metric registration thread safe
Pull request opened by
Sovietaced
## Tracking issue
Closes
#4046
## Why are the changes needed?
Propeller workers sometimes panic on startup, thus killing the workers/goroutines for the duration of the process.
Previously this code could panic due to concurrent map access as well as duplicate prometheus metrics being registered. Ultimately the issue occurs when plugins are being exercised for the first time on startup by the Flyte Propeller workers. If these workers are executing the same plugin in parallel they may race and cause issues.
## What changes were proposed in this pull request?
This pull request makes the plugin metric registration thread safe by guarding operations on the map with a read/write mutex. Specifically it guards the read-modify-write operation with a write lock.
## How was this patch tested?
None yet, but will be tested in our production environment in the next few days.
## Check all the applicable boxes
• I updated the documentation accordingly.
• All new and existing tests passed.
• All commits are signed-off.
## Related PRs
## Docs link
https://bito.ai#summarystart|
### Summary by Bito
This pull request resolves a critical issue and enhances thread safety in Flyte Propeller workers by implementing read/write mutex locks for task metrics registration. This prevents race conditions and duplicate metric registrations, improving system reliability and stability in concurrent plugin environments.
flyteorg/flyte