This is an automated email from the ASF dual-hosted git repository.

pbacsko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 90147d72 [YUNIKORN-2058] fix data race EventSystemImpl.reloadConfig 
(#684)
90147d72 is described below

commit 90147d721e065c2f96a86470b08486e13b1012dc
Author: PoAn Yang <[email protected]>
AuthorDate: Tue Oct 24 14:42:26 2023 +0200

    [YUNIKORN-2058] fix data race EventSystemImpl.reloadConfig (#684)
    
    Signed-off-by: PoAn Yang <[email protected]>
    
    Closes: #684
    
    Signed-off-by: Peter Bacsko <[email protected]>
---
 pkg/events/event_system.go | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/pkg/events/event_system.go b/pkg/events/event_system.go
index cc19e14d..5bb57e57 100644
--- a/pkg/events/event_system.go
+++ b/pkg/events/event_system.go
@@ -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
 }
 
@@ -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()
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to