diff --git a/apier/v1/thresholds_it_test.go b/apier/v1/thresholds_it_test.go index 0c38401bc..2ec13f067 100644 --- a/apier/v1/thresholds_it_test.go +++ b/apier/v1/thresholds_it_test.go @@ -153,7 +153,7 @@ var sTestsThresholdSV1 = []func(t *testing.T){ testV1TSLoadConfig, testV1TSInitDataDb, testV1TSResetStorDb, - testV1TSStartEngine, + // testV1TSStartEngine, testV1TSRpcConn, testV1TSFromFolder, testV1TSGetThresholds, diff --git a/engine/attributes.go b/engine/attributes.go index 5d343ff0c..8bc8b0baa 100644 --- a/engine/attributes.go +++ b/engine/attributes.go @@ -21,8 +21,6 @@ package engine import ( "fmt" - "github.com/cgrates/cgrates/config" - "github.com/cgrates/cgrates/guardian" "github.com/cgrates/cgrates/utils" ) @@ -76,9 +74,6 @@ func (alS *AttributeService) matchingAttributeProfilesForEvent(ev *utils.CGREven return nil, err } } - lockIDs := utils.PrefixSliceItems(aPrflIDs.Slice(), utils.AttributeFilterIndexes) - guardian.Guardian.GuardIDs(config.CgrConfig().LockingTimeout, lockIDs...) - defer guardian.Guardian.UnguardIDs(lockIDs...) for apID := range aPrflIDs { aPrfl, err := alS.dm.GetAttributeProfile(ev.Tenant, apID, false, utils.NonTransactional) if err != nil { diff --git a/engine/filterhelpers.go b/engine/filterhelpers.go index ccfff2eae..8207f758f 100644 --- a/engine/filterhelpers.go +++ b/engine/filterhelpers.go @@ -21,6 +21,8 @@ package engine import ( "fmt" + "github.com/cgrates/cgrates/config" + "github.com/cgrates/cgrates/guardian" "github.com/cgrates/cgrates/utils" ) @@ -29,6 +31,9 @@ import ( // helper on top of dataDB.MatchFilterIndex, adding utils.ANY to list of fields queried func matchingItemIDsForEvent(ev map[string]interface{}, stringFldIDs, prefixFldIDs *[]string, dm *DataManager, cacheID, itemIDPrefix string, indexedSelects bool) (itemIDs utils.StringMap, err error) { + lockID := utils.CacheInstanceToPrefix[cacheID] + itemIDPrefix + guardian.Guardian.GuardIDs(config.CgrConfig().LockingTimeout, lockID) + defer guardian.Guardian.UnguardIDs(lockID) itemIDs = make(utils.StringMap) if !indexedSelects { sliceIDs, err := dm.DataDB().GetKeysForPrefix(itemIDPrefix) diff --git a/engine/filterindexer.go b/engine/filterindexer.go index 37ec4c0e1..7f29c2169 100644 --- a/engine/filterindexer.go +++ b/engine/filterindexer.go @@ -22,6 +22,8 @@ import ( "fmt" "strings" + "github.com/cgrates/cgrates/config" + "github.com/cgrates/cgrates/guardian" "github.com/cgrates/cgrates/utils" ) @@ -124,6 +126,9 @@ func (rfi *FilterIndexer) cacheRemItemType() { // ToDo: tune here by removing pe // StoreIndexes handles storing the indexes to dataDB func (rfi *FilterIndexer) StoreIndexes(commit bool, transactionID string) (err error) { + lockID := utils.CacheInstanceToPrefix[utils.PrefixToIndexCache[rfi.itemType]] + rfi.dbKeySuffix + guardian.Guardian.GuardIDs(config.CgrConfig().LockingTimeout, lockID) + defer guardian.Guardian.UnguardIDs(lockID) if err = rfi.dm.SetFilterIndexes( utils.PrefixToIndexCache[rfi.itemType], rfi.dbKeySuffix, rfi.indexes, commit, transactionID); err != nil { diff --git a/engine/resources.go b/engine/resources.go index bdead8df6..ce5e1cd1f 100644 --- a/engine/resources.go +++ b/engine/resources.go @@ -448,9 +448,6 @@ func (rS *ResourceService) matchingResourcesForEvent(ev *utils.CGREvent, usageTT if err != nil { return nil, err } - lockIDs := utils.PrefixSliceItems(rIDs.Slice(), utils.ResourceFilterIndexes) - guardian.Guardian.GuardIDs(config.CgrConfig().LockingTimeout, lockIDs...) - defer guardian.Guardian.UnguardIDs(lockIDs...) for resName := range rIDs { rPrf, err := rS.dm.GetResourceProfile(ev.Tenant, resName, false, utils.NonTransactional) if err != nil { diff --git a/engine/stats.go b/engine/stats.go index 7d948fe4b..91bdf65e6 100644 --- a/engine/stats.go +++ b/engine/stats.go @@ -152,10 +152,6 @@ func (sS *StatService) matchingStatQueuesForEvent(ev *utils.CGREvent) (sqs StatQ if err != nil { return nil, err } - lockIDs := utils.PrefixSliceItems(sqIDs.Slice(), utils.StatFilterIndexes) - lockIDs = append(lockIDs, utils.PrefixSliceItems(sqIDs.Slice(), utils.StatQueuePrefix)...) // add also lock for statQueue instances - guardian.Guardian.GuardIDs(config.CgrConfig().LockingTimeout, lockIDs...) - defer guardian.Guardian.UnguardIDs(lockIDs...) for sqID := range sqIDs { sqPrfl, err := sS.dm.GetStatQueueProfile(ev.Tenant, sqID, false, utils.NonTransactional) if err != nil { diff --git a/engine/suppliers.go b/engine/suppliers.go index d40798978..6b94910a6 100644 --- a/engine/suppliers.go +++ b/engine/suppliers.go @@ -25,7 +25,6 @@ import ( "time" "github.com/cgrates/cgrates/config" - "github.com/cgrates/cgrates/guardian" "github.com/cgrates/cgrates/utils" "github.com/cgrates/rpcclient" ) @@ -121,9 +120,6 @@ func (spS *SupplierService) matchingSupplierProfilesForEvent(ev *utils.CGREvent) if err != nil { return nil, err } - lockIDs := utils.PrefixSliceItems(sPrflIDs.Slice(), utils.SupplierFilterIndexes) - guardian.Guardian.GuardIDs(config.CgrConfig().LockingTimeout, lockIDs...) - defer guardian.Guardian.UnguardIDs(lockIDs...) for lpID := range sPrflIDs { splPrfl, err := spS.dm.GetSupplierProfile(ev.Tenant, lpID, false, utils.NonTransactional) if err != nil { diff --git a/engine/thresholds.go b/engine/thresholds.go index b1fa66a4a..fb7602f8b 100644 --- a/engine/thresholds.go +++ b/engine/thresholds.go @@ -25,8 +25,6 @@ import ( "sync" "time" - "github.com/cgrates/cgrates/config" - "github.com/cgrates/cgrates/guardian" "github.com/cgrates/cgrates/utils" ) @@ -231,9 +229,6 @@ func (tS *ThresholdService) matchingThresholdsForEvent(args *ArgsProcessEvent) ( } tIDs = tIDsMap.Slice() } - lockIDs := utils.PrefixSliceItems(tIDs, utils.ThresholdFilterIndexes) - guardian.Guardian.GuardIDs(config.CgrConfig().LockingTimeout, lockIDs...) - defer guardian.Guardian.UnguardIDs(lockIDs...) for _, tID := range tIDs { tPrfl, err := tS.dm.GetThresholdProfile(args.Tenant, tID, false, utils.NonTransactional) if err != nil {