mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Handle logical race condition when caching exporters
- added lock to ensure only one exporter instance is cached. - marked duplicate instances to be closed after export.
This commit is contained in:
committed by
Dan Christian Bogos
parent
02ae2cce79
commit
9c94fbfe58
10
ees/ees.go
10
ees/ees.go
@@ -218,7 +218,15 @@ func (eeS *EventExporterS) V1ProcessEvent(ctx *context.Context, cgrEv *engine.CG
|
||||
return
|
||||
}
|
||||
if hasCache {
|
||||
eeCache.Set(eeCfg.ID, ee, nil)
|
||||
eeS.eesMux.Lock()
|
||||
if _, has := eeCache.Get(eeCfg.ID); !has {
|
||||
eeCache.Set(eeCfg.ID, ee, nil)
|
||||
} else {
|
||||
// Another exporter instance with the same ID has been cached in
|
||||
// the meantime. Mark this instance to be closed after the export.
|
||||
hasCache = false
|
||||
}
|
||||
eeS.eesMux.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user