Skip to content

Commit

Permalink
[YUNIKORN-2058] fix data race EventSystemImpl.reloadConfig (apache#684)
Browse files Browse the repository at this point in the history
Signed-off-by: PoAn Yang <[email protected]>

Closes: apache#684

Signed-off-by: Peter Bacsko <[email protected]>
  • Loading branch information
FrankYang0529 authored and pbacsko committed Oct 24, 2023
1 parent 03c3ccc commit 90147d7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/events/event_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ func (ec *EventSystemImpl) readRingBufferCapacity() uint64 {
}

func (ec *EventSystemImpl) isRestartNeeded() bool {
ec.Lock()
defer ec.Unlock()
ec.RLock()
defer ec.RUnlock()
return ec.readIsTrackingEnabled() != ec.trackingEnabled
}

Expand All @@ -197,13 +197,18 @@ func (ec *EventSystemImpl) Restart() {
}

func (ec *EventSystemImpl) reloadConfig() {
ec.requestCapacity = ec.readRequestCapacity()
newRingBufferCapacity := ec.readRingBufferCapacity()
ec.updateRequestCapacity()

// resize the ring buffer with new capacity
ec.eventBuffer.Resize(newRingBufferCapacity)
ec.eventBuffer.Resize(ec.readRingBufferCapacity())

if ec.isRestartNeeded() {
ec.Restart()
}
}

func (ec *EventSystemImpl) updateRequestCapacity() {
ec.Lock()
defer ec.Unlock()
ec.requestCapacity = ec.readRequestCapacity()
}

0 comments on commit 90147d7

Please sign in to comment.