WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@scr-oath
Copy link
Contributor

@scr-oath scr-oath commented Dec 9, 2025

Add holdReadLock mechanism to prevent concurrent map access in moduleContexts during parallel bidder hook execution. This fixes panics caused by concurrent reads and writes to the moduleContexts map when multiple bidders execute hooks in parallel.

This is an alternate implementation to PR #4603 (#4603), using a simpler approach with a boolean flag to conditionally hold the read lock for the entire duration of hook execution in bidder stages.

Changes:

  • Add holdReadLock boolean field to executionContext
  • Add getModuleContextLocked() helper that reads without acquiring locks
  • Modify executeGroup() to conditionally hold RLock for entire execution
  • Enable holdReadLock for ExecuteBidderRequestStage and ExecuteRawBidderResponseStage

The RWMutex is now held for the entire duration that hook goroutines are executing in bidder stages, preventing saveModuleContexts() from acquiring write lock while reads are in progress.

🤖 Generated with Claude Code

Add holdReadLock mechanism to prevent concurrent map access in moduleContexts
during parallel bidder hook execution. This fixes panics caused by concurrent
reads and writes to the moduleContexts map when multiple bidders execute hooks
in parallel.

This is an alternate implementation to PR prebid#4603 (prebid#4603),
using a simpler approach with a boolean flag to conditionally hold the read lock
for the entire duration of hook execution in bidder stages.

Changes:
- Add holdReadLock boolean field to executionContext
- Add getModuleContextLocked() helper that reads without acquiring locks
- Modify executeGroup() to conditionally hold RLock for entire execution
- Enable holdReadLock for ExecuteBidderRequestStage and ExecuteRawBidderResponseStage

The RWMutex is now held for the entire duration that hook goroutines are
executing in bidder stages, preventing saveModuleContexts() from acquiring
write lock while reads are in progress.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <[email protected]>
Remove extra whitespace alignment on holdReadLock field to pass gofmt validation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <[email protected]>
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.

3 participants