@@ -43,9 +43,10 @@ const (
43
43
type PrintStatusRule int
44
44
45
45
const (
46
- HeuristicPrintStatusRule PrintStatusRule = iota
47
- ForcePrintStatusRule = iota
48
- ForcePrintStatusAndHint = iota
46
+ HeuristicPrintStatusRule PrintStatusRule = iota
47
+ ForcePrintStatusRule = iota
48
+ ForcePrintStatusOnlyRule = iota
49
+ ForcePrintStatusAndHintRule = iota
49
50
)
50
51
51
52
// Migrator is the main schema migration flow manager.
@@ -522,7 +523,7 @@ func (this *Migrator) waitForEventsUpToLock() (err error) {
522
523
waitForEventsUpToLockDuration := time .Since (waitForEventsUpToLockStartTime )
523
524
524
525
log .Infof ("Done waiting for events up to lock; duration=%+v" , waitForEventsUpToLockDuration )
525
- this .printStatus (ForcePrintStatusAndHint )
526
+ this .printStatus (ForcePrintStatusAndHintRule )
526
527
527
528
return nil
528
529
}
@@ -662,7 +663,8 @@ func (this *Migrator) onServerCommand(command string, writer *bufio.Writer) (err
662
663
case "help" :
663
664
{
664
665
fmt .Fprintln (writer , `available commands:
665
- status # Print a status message
666
+ status # Print a detailed status message
667
+ sup # Print a short status message
666
668
chunk-size=<newsize> # Set a new chunk-size
667
669
nice-ratio=<ratio> # Set a new nice-ratio, immediate sleep after each row-copy operation, float (examples: 0 is agrressive, 0.7 adds 70% runtime, 1.0 doubles runtime, 2.0 triples runtime, ...)
668
670
critical-load=<load> # Set a new set of max-load thresholds
@@ -678,16 +680,18 @@ panic # panic and quit without cleanup
678
680
help # This message
679
681
` )
680
682
}
683
+ case "sup" :
684
+ this .printStatus (ForcePrintStatusOnlyRule , writer )
681
685
case "info" , "status" :
682
- this .printStatus (ForcePrintStatusAndHint , writer )
686
+ this .printStatus (ForcePrintStatusAndHintRule , writer )
683
687
case "chunk-size" :
684
688
{
685
689
if chunkSize , err := strconv .Atoi (arg ); err != nil {
686
690
fmt .Fprintf (writer , "%s\n " , err .Error ())
687
691
return log .Errore (err )
688
692
} else {
689
693
this .migrationContext .SetChunkSize (int64 (chunkSize ))
690
- this .printStatus (ForcePrintStatusAndHint , writer )
694
+ this .printStatus (ForcePrintStatusAndHintRule , writer )
691
695
}
692
696
}
693
697
case "max-lag-millis" :
@@ -697,13 +701,13 @@ help # This message
697
701
return log .Errore (err )
698
702
} else {
699
703
this .migrationContext .SetMaxLagMillisecondsThrottleThreshold (int64 (maxLagMillis ))
700
- this .printStatus (ForcePrintStatusAndHint , writer )
704
+ this .printStatus (ForcePrintStatusAndHintRule , writer )
701
705
}
702
706
}
703
707
case "replication-lag-query" :
704
708
{
705
709
this .migrationContext .SetReplicationLagQuery (arg )
706
- this .printStatus (ForcePrintStatusAndHint , writer )
710
+ this .printStatus (ForcePrintStatusAndHintRule , writer )
707
711
}
708
712
case "nice-ratio" :
709
713
{
@@ -712,7 +716,7 @@ help # This message
712
716
return log .Errore (err )
713
717
} else {
714
718
this .migrationContext .SetNiceRatio (niceRatio )
715
- this .printStatus (ForcePrintStatusAndHint , writer )
719
+ this .printStatus (ForcePrintStatusAndHintRule , writer )
716
720
}
717
721
}
718
722
case "max-load" :
@@ -721,21 +725,21 @@ help # This message
721
725
fmt .Fprintf (writer , "%s\n " , err .Error ())
722
726
return log .Errore (err )
723
727
}
724
- this .printStatus (ForcePrintStatusAndHint , writer )
728
+ this .printStatus (ForcePrintStatusAndHintRule , writer )
725
729
}
726
730
case "critical-load" :
727
731
{
728
732
if err := this .migrationContext .ReadCriticalLoad (arg ); err != nil {
729
733
fmt .Fprintf (writer , "%s\n " , err .Error ())
730
734
return log .Errore (err )
731
735
}
732
- this .printStatus (ForcePrintStatusAndHint , writer )
736
+ this .printStatus (ForcePrintStatusAndHintRule , writer )
733
737
}
734
738
case "throttle-query" :
735
739
{
736
740
this .migrationContext .SetThrottleQuery (arg )
737
741
fmt .Fprintf (writer , throttleHint )
738
- this .printStatus (ForcePrintStatusAndHint , writer )
742
+ this .printStatus (ForcePrintStatusAndHintRule , writer )
739
743
}
740
744
case "throttle-control-replicas" :
741
745
{
@@ -744,13 +748,13 @@ help # This message
744
748
return log .Errore (err )
745
749
}
746
750
fmt .Fprintf (writer , "%s\n " , this .migrationContext .GetThrottleControlReplicaKeys ().ToCommaDelimitedList ())
747
- this .printStatus (ForcePrintStatusAndHint , writer )
751
+ this .printStatus (ForcePrintStatusAndHintRule , writer )
748
752
}
749
753
case "throttle" , "pause" , "suspend" :
750
754
{
751
755
atomic .StoreInt64 (& this .migrationContext .ThrottleCommandedByUser , 1 )
752
756
fmt .Fprintf (writer , throttleHint )
753
- this .printStatus (ForcePrintStatusAndHint , writer )
757
+ this .printStatus (ForcePrintStatusAndHintRule , writer )
754
758
}
755
759
case "no-throttle" , "unthrottle" , "resume" , "continue" :
756
760
{
@@ -840,7 +844,7 @@ func (this *Migrator) initiateInspector() (err error) {
840
844
841
845
// initiateStatus sets and activates the printStatus() ticker
842
846
func (this * Migrator ) initiateStatus () error {
843
- this .printStatus (ForcePrintStatusAndHint )
847
+ this .printStatus (ForcePrintStatusAndHintRule )
844
848
statusTick := time .Tick (1 * time .Second )
845
849
for range statusTick {
846
850
go this .printStatus (HeuristicPrintStatusRule )
@@ -949,9 +953,12 @@ func (this *Migrator) printStatus(rule PrintStatusRule, writers ...io.Writer) {
949
953
950
954
// Before status, let's see if we should print a nice reminder for what exactly we're doing here.
951
955
shouldPrintMigrationStatusHint := (elapsedSeconds % 600 == 0 )
952
- if rule == ForcePrintStatusAndHint {
956
+ if rule == ForcePrintStatusAndHintRule {
953
957
shouldPrintMigrationStatusHint = true
954
958
}
959
+ if rule == ForcePrintStatusOnlyRule {
960
+ shouldPrintMigrationStatusHint = false
961
+ }
955
962
if shouldPrintMigrationStatusHint {
956
963
this .printMigrationStatusHint (writers ... )
957
964
}
@@ -992,7 +999,7 @@ func (this *Migrator) printStatus(rule PrintStatusRule, writers ...io.Writer) {
992
999
} else {
993
1000
shouldPrintStatus = (elapsedSeconds % 30 == 0 )
994
1001
}
995
- if rule == ForcePrintStatusRule || rule == ForcePrintStatusAndHint {
1002
+ if rule == ForcePrintStatusRule || rule == ForcePrintStatusAndHintRule {
996
1003
shouldPrintStatus = true
997
1004
}
998
1005
if ! shouldPrintStatus {
0 commit comments