Skip to content

fix: introduce mutex to avoid nil deferences for reloads while scraping#972

Merged
burningalchemist merged 1 commit intomasterfrom
fix/reload-racing
Apr 10, 2026
Merged

fix: introduce mutex to avoid nil deferences for reloads while scraping#972
burningalchemist merged 1 commit intomasterfrom
fix/reload-racing

Conversation

@burningalchemist
Copy link
Copy Markdown
Owner

@burningalchemist burningalchemist commented Apr 10, 2026

Fixes #970

This pull request introduces thread-safety improvements to the exporter and target types by adding mutex locks to protect shared resources. These changes ensure that concurrent access to critical sections, such as target and connection management, is properly synchronized, preventing race conditions and potential data corruption.

Thread-safety improvements:

  • Added a sync.RWMutex (mu) to the exporter struct and wrapped accesses to the targets slice in read/write locks to prevent concurrent read/write issues. (exporter.go, [1] [2] [3]
  • Added a sync.RWMutex (mu) to the target struct and used locks in Close and ping methods to ensure only one goroutine can modify or close the database connection at a time. (target.go, [1] [2] [3]

@burningalchemist burningalchemist merged commit e78a4e4 into master Apr 10, 2026
4 checks passed
@burningalchemist burningalchemist deleted the fix/reload-racing branch April 10, 2026 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/Reload causes sql_export to crash

1 participant