diff --git a/services/horizon/internal/ingest/main.go b/services/horizon/internal/ingest/main.go index ab4184202f..dc6dc8dd46 100644 --- a/services/horizon/internal/ingest/main.go +++ b/services/horizon/internal/ingest/main.go @@ -230,7 +230,8 @@ type system struct { reapOffsets map[string]int64 - currentState State + currentStateMutex sync.Mutex + currentState State } func NewSystem(config Config) (System, error) { @@ -484,6 +485,8 @@ func (s *system) initMetrics() { } func (s *system) GetCurrentState() State { + s.currentStateMutex.Lock() + defer s.currentStateMutex.Unlock() return s.currentState } @@ -652,7 +655,10 @@ func (s *system) runStateMachine(cur stateMachineNode) error { panic("unexpected transaction") } + s.currentStateMutex.Lock() s.currentState = cur.GetState() + s.currentStateMutex.Unlock() + next, err := cur.run(s) if err != nil { logger := log.WithFields(logpkg.F{