|
1 | 1 | /* |
2 | | - Copyright 2016 GitHub Inc. |
| 2 | + Copyright 2022 GitHub Inc. |
3 | 3 | See https://github.com/github/gh-ost/blob/master/LICENSE |
4 | 4 | */ |
5 | 5 |
|
@@ -176,16 +176,6 @@ func (this *Migrator) retryOperationWithExponentialBackoff(operation func() erro |
176 | 176 | return err |
177 | 177 | } |
178 | 178 |
|
179 | | -// executeAndThrottleOnError executes a given function. If it errors, it |
180 | | -// throttles. |
181 | | -func (this *Migrator) executeAndThrottleOnError(operation func() error) (err error) { |
182 | | - if err := operation(); err != nil { |
183 | | - this.throttler.throttle(nil) |
184 | | - return err |
185 | | - } |
186 | | - return nil |
187 | | -} |
188 | | - |
189 | 179 | // consumeRowCopyComplete blocks on the rowCopyComplete channel once, and then |
190 | 180 | // consumes and drops any further incoming events that may be left hanging. |
191 | 181 | func (this *Migrator) consumeRowCopyComplete() { |
@@ -823,78 +813,78 @@ func (this *Migrator) initiateStatus() error { |
823 | 813 | // migration, and as response to the "status" interactive command. |
824 | 814 | func (this *Migrator) printMigrationStatusHint(writers ...io.Writer) { |
825 | 815 | w := io.MultiWriter(writers...) |
826 | | - fmt.Fprintln(w, fmt.Sprintf("# Migrating %s.%s; Ghost table is %s.%s", |
| 816 | + fmt.Fprintf(w, "# Migrating %s.%s; Ghost table is %s.%s\n", |
827 | 817 | sql.EscapeName(this.migrationContext.DatabaseName), |
828 | 818 | sql.EscapeName(this.migrationContext.OriginalTableName), |
829 | 819 | sql.EscapeName(this.migrationContext.DatabaseName), |
830 | 820 | sql.EscapeName(this.migrationContext.GetGhostTableName()), |
831 | | - )) |
832 | | - fmt.Fprintln(w, fmt.Sprintf("# Migrating %+v; inspecting %+v; executing on %+v", |
| 821 | + ) |
| 822 | + fmt.Fprintf(w, "# Migrating %+v; inspecting %+v; executing on %+v\n", |
833 | 823 | *this.applier.connectionConfig.ImpliedKey, |
834 | 824 | *this.inspector.connectionConfig.ImpliedKey, |
835 | 825 | this.migrationContext.Hostname, |
836 | | - )) |
837 | | - fmt.Fprintln(w, fmt.Sprintf("# Migration started at %+v", |
| 826 | + ) |
| 827 | + fmt.Fprintf(w, "# Migration started at %+v\n", |
838 | 828 | this.migrationContext.StartTime.Format(time.RubyDate), |
839 | | - )) |
| 829 | + ) |
840 | 830 | maxLoad := this.migrationContext.GetMaxLoad() |
841 | 831 | criticalLoad := this.migrationContext.GetCriticalLoad() |
842 | | - fmt.Fprintln(w, fmt.Sprintf("# chunk-size: %+v; max-lag-millis: %+vms; dml-batch-size: %+v; max-load: %s; critical-load: %s; nice-ratio: %f", |
| 832 | + fmt.Fprintf(w, "# chunk-size: %+v; max-lag-millis: %+vms; dml-batch-size: %+v; max-load: %s; critical-load: %s; nice-ratio: %f\n", |
843 | 833 | atomic.LoadInt64(&this.migrationContext.ChunkSize), |
844 | 834 | atomic.LoadInt64(&this.migrationContext.MaxLagMillisecondsThrottleThreshold), |
845 | 835 | atomic.LoadInt64(&this.migrationContext.DMLBatchSize), |
846 | 836 | maxLoad.String(), |
847 | 837 | criticalLoad.String(), |
848 | 838 | this.migrationContext.GetNiceRatio(), |
849 | | - )) |
| 839 | + ) |
850 | 840 | if this.migrationContext.ThrottleFlagFile != "" { |
851 | 841 | setIndicator := "" |
852 | 842 | if base.FileExists(this.migrationContext.ThrottleFlagFile) { |
853 | 843 | setIndicator = "[set]" |
854 | 844 | } |
855 | | - fmt.Fprintln(w, fmt.Sprintf("# throttle-flag-file: %+v %+v", |
| 845 | + fmt.Fprintf(w, "# throttle-flag-file: %+v %+v\n", |
856 | 846 | this.migrationContext.ThrottleFlagFile, setIndicator, |
857 | | - )) |
| 847 | + ) |
858 | 848 | } |
859 | 849 | if this.migrationContext.ThrottleAdditionalFlagFile != "" { |
860 | 850 | setIndicator := "" |
861 | 851 | if base.FileExists(this.migrationContext.ThrottleAdditionalFlagFile) { |
862 | 852 | setIndicator = "[set]" |
863 | 853 | } |
864 | | - fmt.Fprintln(w, fmt.Sprintf("# throttle-additional-flag-file: %+v %+v", |
| 854 | + fmt.Fprintf(w, "# throttle-additional-flag-file: %+v %+v\n", |
865 | 855 | this.migrationContext.ThrottleAdditionalFlagFile, setIndicator, |
866 | | - )) |
| 856 | + ) |
867 | 857 | } |
868 | 858 | if throttleQuery := this.migrationContext.GetThrottleQuery(); throttleQuery != "" { |
869 | | - fmt.Fprintln(w, fmt.Sprintf("# throttle-query: %+v", |
| 859 | + fmt.Fprintf(w, "# throttle-query: %+v\n", |
870 | 860 | throttleQuery, |
871 | | - )) |
| 861 | + ) |
872 | 862 | } |
873 | 863 | if throttleControlReplicaKeys := this.migrationContext.GetThrottleControlReplicaKeys(); throttleControlReplicaKeys.Len() > 0 { |
874 | | - fmt.Fprintln(w, fmt.Sprintf("# throttle-control-replicas count: %+v", |
| 864 | + fmt.Fprintf(w, "# throttle-control-replicas count: %+v\n", |
875 | 865 | throttleControlReplicaKeys.Len(), |
876 | | - )) |
| 866 | + ) |
877 | 867 | } |
878 | 868 |
|
879 | 869 | if this.migrationContext.PostponeCutOverFlagFile != "" { |
880 | 870 | setIndicator := "" |
881 | 871 | if base.FileExists(this.migrationContext.PostponeCutOverFlagFile) { |
882 | 872 | setIndicator = "[set]" |
883 | 873 | } |
884 | | - fmt.Fprintln(w, fmt.Sprintf("# postpone-cut-over-flag-file: %+v %+v", |
| 874 | + fmt.Fprintf(w, "# postpone-cut-over-flag-file: %+v %+v\n", |
885 | 875 | this.migrationContext.PostponeCutOverFlagFile, setIndicator, |
886 | | - )) |
| 876 | + ) |
887 | 877 | } |
888 | 878 | if this.migrationContext.PanicFlagFile != "" { |
889 | | - fmt.Fprintln(w, fmt.Sprintf("# panic-flag-file: %+v", |
| 879 | + fmt.Fprintf(w, "# panic-flag-file: %+v\n", |
890 | 880 | this.migrationContext.PanicFlagFile, |
891 | | - )) |
| 881 | + ) |
892 | 882 | } |
893 | | - fmt.Fprintln(w, fmt.Sprintf("# Serving on unix socket: %+v", |
| 883 | + fmt.Fprintf(w, "# Serving on unix socket: %+v\n", |
894 | 884 | this.migrationContext.ServeSocketFile, |
895 | | - )) |
| 885 | + ) |
896 | 886 | if this.migrationContext.ServeTCPPort != 0 { |
897 | | - fmt.Fprintln(w, fmt.Sprintf("# Serving on TCP port: %+v", this.migrationContext.ServeTCPPort)) |
| 887 | + fmt.Fprintf(w, "# Serving on TCP port: %+v\n", this.migrationContext.ServeTCPPort) |
898 | 888 | } |
899 | 889 | } |
900 | 890 |
|
@@ -1195,7 +1185,6 @@ func (this *Migrator) iterateChunks() error { |
1195 | 1185 | // Enqueue copy operation; to be executed by executeWriteFuncs() |
1196 | 1186 | this.copyRowsQueue <- copyRowsFunc |
1197 | 1187 | } |
1198 | | - return nil |
1199 | 1188 | } |
1200 | 1189 |
|
1201 | 1190 | func (this *Migrator) onApplyEventStruct(eventStruct *applyEventStruct) error { |
@@ -1301,7 +1290,6 @@ func (this *Migrator) executeWriteFuncs() error { |
1301 | 1290 | } |
1302 | 1291 | } |
1303 | 1292 | } |
1304 | | - return nil |
1305 | 1293 | } |
1306 | 1294 |
|
1307 | 1295 | // finalCleanup takes actions at very end of migration, dropping tables etc. |
|
0 commit comments