Skip to content

Commit 4a66f9e

Browse files
committed
remove redundant race condition handling in initFromP2PWithRetry
1 parent 312c563 commit 4a66f9e

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

pkg/sync/sync_service.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,8 @@ func (syncService *SyncService[H]) initFromP2PWithRetry(ctx context.Context, pee
338338
return false, fmt.Errorf("failed to fetch height %d from peers: %w", heightToQuery, err)
339339
}
340340

341-
// Use CompareAndSwap to atomically check and set initialization flag
342-
// This prevents race condition where concurrent calls could both initialize the store
343341
if syncService.storeInitialized.CompareAndSwap(false, true) {
344342
if _, err := syncService.initStore(ctx, trusted); err != nil {
345-
// Revert the flag on error so initialization can be retried
346343
syncService.storeInitialized.Store(false)
347344
return false, fmt.Errorf("failed to initialize the store: %w", err)
348345
}

0 commit comments

Comments
 (0)