From 3d3540b486655e0c10afceda1cc6704d12ac8638 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 20 May 2021 13:24:41 +0300 Subject: [PATCH] Updated threshold processing for resources --- engine/resources.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/engine/resources.go b/engine/resources.go index 6a535f0c4..0f825a363 100644 --- a/engine/resources.go +++ b/engine/resources.go @@ -701,19 +701,18 @@ func (rS *ResourceService) V1AllocateResources(args utils.ArgRSv1ResourceUsage, // index it for storing for _, r := range mtcRLs { - if rS.cgrcfg.ResourceSCfg().StoreInterval == 0 || r.dirty == nil { - continue - } - if rS.cgrcfg.ResourceSCfg().StoreInterval == -1 { - *r.dirty = true - if err = rS.StoreResource(r); err != nil { - return + if rS.cgrcfg.ResourceSCfg().StoreInterval != 0 && r.dirty != nil { + if rS.cgrcfg.ResourceSCfg().StoreInterval == -1 { + *r.dirty = true + if err = rS.StoreResource(r); err != nil { + return + } + } else { + *r.dirty = true // mark it to be saved + rS.srMux.Lock() + rS.storedResources.Add(r.TenantID()) + rS.srMux.Unlock() } - } else { - *r.dirty = true // mark it to be saved - rS.srMux.Lock() - rS.storedResources.Add(r.TenantID()) - rS.srMux.Unlock() } if err = rS.processThresholds(r, args.APIOpts); err != nil { return