Skip to content

Commit a25e3c2

Browse files
committed
go/worker/storage/statesync: Add timeout to checkpoint restoration
1 parent 9ad2b8b commit a25e3c2

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

go/worker/storage/statesync/checkpoint_sync.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,15 @@ import (
2121
const (
2222
// cpListsTimeout is the timeout for fetching checkpoints from all nodes.
2323
cpListsTimeout = 30 * time.Second
24-
// cpRestoreTimeout is the timeout for restoring a checkpoint chunk from the remote peer.
25-
cpRestoreTimeout = 60 * time.Second
24+
25+
// cpRestoreChunkTimeout is the timeout for restoring a checkpoint chunk from the remote peer.
26+
cpRestoreChunkTimeout = 60 * time.Second
27+
28+
// cpRestoreTimeout is the timeout for restoring the whole checkpoint from the remote peers.
29+
//
30+
// As of now it takes ~10-30 min to restore the state from the checkpoint, however the timeout
31+
// should be significantly higher to account for the growing state.
32+
cpRestoreTimeout = 12 * time.Hour
2633

2734
checkpointStatusDone = 0
2835
checkpointStatusNext = 1
@@ -99,7 +106,7 @@ func (w *Worker) checkpointChunkFetcher(
99106
}
100107
}
101108

102-
chunkCtx, cancel := context.WithTimeout(ctx, cpRestoreTimeout)
109+
chunkCtx, cancel := context.WithTimeout(ctx, cpRestoreChunkTimeout)
103110
defer cancel()
104111

105112
// Fetch chunk from peers.
@@ -195,6 +202,7 @@ func (w *Worker) fetchChunk(ctx context.Context, chunk *chunk) ([]byte, rpc.Peer
195202
}
196203

197204
func (w *Worker) handleCheckpoint(ctx context.Context, check *checkpointsync.Checkpoint, maxParallelRequests uint) (cpStatus int, rerr error) {
205+
ctx, _ = context.WithTimeout(ctx, cpRestoreTimeout)
198206
if err := w.localStorage.Checkpointer().StartRestore(ctx, check.Metadata); err != nil {
199207
// Any previous restores were already aborted by the driver up the call stack, so
200208
// things should have been going smoothly here; bail.

0 commit comments

Comments
 (0)