github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/admin/commands/execution/checkpoint_trigger.go (about) 1 package execution 2 3 import ( 4 "context" 5 6 "github.com/rs/zerolog/log" 7 "go.uber.org/atomic" 8 9 "github.com/onflow/flow-go/admin" 10 "github.com/onflow/flow-go/admin/commands" 11 ) 12 13 var _ commands.AdminCommand = (*TriggerCheckpointCommand)(nil) 14 15 // TriggerCheckpointCommand will send a signal to compactor to trigger checkpoint 16 // once finishing writing the current WAL segment file 17 type TriggerCheckpointCommand struct { 18 trigger *atomic.Bool 19 } 20 21 func NewTriggerCheckpointCommand(trigger *atomic.Bool) *TriggerCheckpointCommand { 22 return &TriggerCheckpointCommand{ 23 trigger: trigger, 24 } 25 } 26 27 func (s *TriggerCheckpointCommand) Handler(_ context.Context, _ *admin.CommandRequest) (interface{}, error) { 28 if s.trigger.CompareAndSwap(false, true) { 29 log.Info().Msgf("admintool: trigger checkpoint as soon as finishing writing the current segment file. you can find log about 'compactor' to check the checkpointing progress") 30 } else { 31 log.Info().Msgf("admintool: checkpoint is already set to be triggered") 32 } 33 34 return "ok", nil 35 } 36 37 func (s *TriggerCheckpointCommand) Validator(_ *admin.CommandRequest) error { 38 return nil 39 }