From 9df3f3f6477253e5b8cf34c9b2ca86b6185c1767 Mon Sep 17 00:00:00 2001 From: GheisMohammadi Date: Wed, 17 Jul 2024 01:37:33 +0330 Subject: [PATCH] fix lock release issue in stream sync --- api/service/stagedstreamsync/staged_stream_sync.go | 3 +++ api/service/stagedstreamsync/state_sync_full.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/api/service/stagedstreamsync/staged_stream_sync.go b/api/service/stagedstreamsync/staged_stream_sync.go index 1782068b29..7aef457ef8 100644 --- a/api/service/stagedstreamsync/staged_stream_sync.go +++ b/api/service/stagedstreamsync/staged_stream_sync.go @@ -248,6 +248,9 @@ func (s *StagedStreamSync) cleanUp(ctx context.Context, fromStage int, db kv.RwD continue } if err := s.pruneStage(ctx, firstCycle, s.pruningOrder[i], db, tx); err != nil { + utils.Logger().Error().Err(err). + Interface("stage id", s.pruningOrder[i].ID). + Msgf(WrapStagedSyncMsg("stage cleanup failed")) panic(err) } } diff --git a/api/service/stagedstreamsync/state_sync_full.go b/api/service/stagedstreamsync/state_sync_full.go index 14cdb1f594..cb7d40d945 100644 --- a/api/service/stagedstreamsync/state_sync_full.go +++ b/api/service/stagedstreamsync/state_sync_full.go @@ -789,7 +789,7 @@ func (s *FullStateDownloadManager) cleanAccountTasks() { return } // Sync wasn't finished previously, check for any task that can be finalized - for taskID, _ := range s.tasks.accountTasks { + for taskID := range s.tasks.accountTasks { if s.tasks.accountTasks[taskID].done { s.tasks.deleteAccountTask(taskID) } @@ -2333,7 +2333,7 @@ func (s *FullStateDownloadManager) onHealByteCodes(task *healTask, Msg("Delivering set of healing bytecodes") s.lock.Lock() - s.lock.Unlock() + defer s.lock.Unlock() // Response is valid, but check if peer is signalling that it does not have // the requested data. For bytecode range queries that means the peer is not