Skip to content

Commit 1c1fd8e

Browse files
authored
Limit block batches to 10k during checkpoint syncs (#215)
1 parent 6dfa42b commit 1c1fd8e

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

services/legacy/netsync/manager.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,16 @@ func (sm *SyncManager) fetchHeaderBlocks() {
12891289
return
12901290
}
12911291

1292+
// Limit batch size to avoid peer processing timeouts during checkpoint sync.
1293+
// Large checkpoint gaps (e.g., 50k blocks) can cause timeouts when downloading
1294+
// and processing all blocks at once. Chunk requests to manageable sizes.
1295+
maxBlocks := maxRequestedBlocks
1296+
headerListLen := sm.headerList.Len()
1297+
if headerListLen > 10000 {
1298+
maxBlocks = 10000
1299+
sm.logger.Infof("[fetchHeaderBlocks] Header list contains %d blocks, limiting batch to %d blocks to avoid timeout", headerListLen, maxBlocks)
1300+
}
1301+
12921302
// Build up a getdata request for the list of blocks the headers
12931303
// describe. The size hint will be limited to wire.MaxInvPerMsg by
12941304
// the function, so no need to double check it here.
@@ -1326,7 +1336,7 @@ func (sm *SyncManager) fetchHeaderBlocks() {
13261336

13271337
sm.startHeader = e.Next()
13281338

1329-
if numRequested >= maxRequestedBlocks {
1339+
if numRequested >= maxBlocks {
13301340
sm.logger.Debugf("[fetchHeaderBlocks] Limiting to %d block(s) from %s", numRequested, sm.syncPeer)
13311341
break
13321342
}

services/utxopersister/filestorer/FileStorer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func NewFileStorer(ctx context.Context, logger ulogger.Logger, tSettings *settin
8686
bufferSize = 1024 * 128 // default to 128KB
8787
}
8888

89-
logger.Infof("Using %s buffer for file storer", bufferSize)
89+
logger.Debugf("Using %s buffer for file storer", bufferSize)
9090

9191
// Create pipe for streaming data to blob storage
9292
reader, writer := io.Pipe()

settings.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,8 @@ legacy_outpointBatcherConcurrency = 32
711711

712712
legacy_outpointBatcherSize = 1024
713713

714+
legacy_peerProcessingTimeout = 10m
715+
714716
legacy_printInvMessages = false
715717
legacy_printInvMessages.dev = true
716718

0 commit comments

Comments
 (0)