File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,12 @@ type Aggregator struct {
7474 // Note: In case of a reboot it can start from 0 again
7575 nextBatchIndex uint32
7676
77- // Mutex to protect batchesIdentifierHashByIdx, batchesIdxByIdentifierHash and nextBatchIndex
77+ // Mutex to protect:
78+ // - batchesIdentifierHashByIdx
79+ // - batchesIdxByIdentifierHash
80+ // - batchCreatedBlockByIdx
81+ // - batchDataByIdentifierHash
82+ // - nextBatchIndex
7883 taskMutex * sync.Mutex
7984
8085 // Mutex to protect ethereum wallet
@@ -443,6 +448,8 @@ func (agg *Aggregator) ClearTasksFromMaps() {
443448 agg .logger .Warn ("No old tasks found" )
444449 continue // Retry in the next iteration
445450 }
451+ agg .taskMutex .Lock ()
452+ agg .AggregatorConfig .BaseConfig .Logger .Info ("- Locked Resources: Cleaning finalized tasks" )
446453
447454 taskIdxToDelete := agg .batchesIdxByIdentifierHash [* oldTaskIdHash ]
448455 agg .logger .Info ("Old task found" , "taskIndex" , taskIdxToDelete )
@@ -460,6 +467,8 @@ func (agg *Aggregator) ClearTasksFromMaps() {
460467 }
461468 }
462469 lastIdxDeleted = taskIdxToDelete
470+ agg .taskMutex .Unlock ()
471+ agg .AggregatorConfig .BaseConfig .Logger .Info ("- Unlocked Resources: Cleaning finalized tasks" )
463472 agg .AggregatorConfig .BaseConfig .Logger .Info ("Done cleaning finalized tasks from maps" )
464473 }
465474}
You can’t perform that action at this time.
0 commit comments