Skip to content

Commit

Permalink
Add mutex to avoid concurrent gc during hot reload
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonip committed Oct 11, 2024
1 parent 5a82ecc commit eb9f610
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions x-pack/apm-server/sampling/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const (
shutdownGracePeriod = 5 * time.Second
)

var gcMutex sync.Mutex // global mutex to protect gc from running concurrently in a hot reload

// Processor is a tail-sampling event processor.
type Processor struct {
config Config
Expand Down Expand Up @@ -386,6 +388,8 @@ func (p *Processor) Run() error {
}
})
g.Go(func() error {
gcMutex.Lock()
defer gcMutex.Unlock()
// This goroutine is responsible for periodically garbage
// collecting the Badger value log, using the recommended
// discard ratio of 0.5.
Expand Down

0 comments on commit eb9f610

Please sign in to comment.