Skip to content

Commit ea19b7d

Browse files
committed
refactor(exporter): return early if already running in slot exporter
1 parent cd57216 commit ea19b7d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

backend/pkg/exporter/modules/slot_exporter.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ var latestEpoch, latestSlot, finalizedEpoch, latestProposed uint64
4949

5050
var processSlotMutex = &sync.Mutex{}
5151

52-
func (d *slotExporterData) OnHead(event *constypes.StandardEventHeadResponse) (err error) {
53-
processSlotMutex.Lock() // only process one slot at a time
52+
func (d *slotExporterData) OnHead(_ *constypes.StandardEventHeadResponse) (err error) {
53+
if !processSlotMutex.TryLock() {
54+
log.Infof("slotExporter is still running, skipping this run")
55+
return nil
56+
}
5457
defer processSlotMutex.Unlock()
5558

5659
latestEpoch, latestSlot, finalizedEpoch, latestProposed = 0, 0, 0, 0

0 commit comments

Comments
 (0)