Skip to content

Commit ffbd285

Browse files
committed
reorg lag env
1 parent c3c0665 commit ffbd285

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

configs/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ type Config struct {
9191
RedisDB int `env:"REDIS_DB" envDefault:"0"`
9292
ValidationMode string `env:"VALIDATION_MODE" envDefault:"minimal"`
9393
EnableReorgValidation bool `env:"ENABLE_REORG_VALIDATION" envDefault:"true"`
94+
// ReorgLagByBlocks keeps reorg validation this many ClickHouse blocks behind the latest committed block.
95+
ReorgLagByBlocks uint64 `env:"REORG_LAG_BY_BLOCKS" envDefault:"500"`
9496
// ReorgAPIListenAddr is the bind address for the manual reorg publish HTTP server (reorg-api command).
9597
ReorgAPIListenAddr string `env:"REORG_API_LISTEN_ADDR" envDefault:":8080"`
9698
// ReorgAPIKey, when non-empty, requires requests to send Authorization: Bearer <ReorgAPIKey>.

internal/committer/reorg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func getReorgRange() (int64, int64, error) {
6262
return 0, 0, fmt.Errorf("failed to get max block number: %w", err)
6363
}
6464

65-
endBlock = min(endBlock-500, startBlock+100) // lag by some blocks for safety
65+
endBlock = min(endBlock-int64(config.Cfg.ReorgLagByBlocks), startBlock+100)
6666

6767
if startBlock >= endBlock {
6868
return 0, 0, fmt.Errorf("start block is greater than end block (%d >= %d)", startBlock, endBlock)

0 commit comments

Comments
 (0)