@@ -109,6 +109,7 @@ func (st *SubTask) Init() error {
109
109
110
110
st .DDLInfo = make (chan * pb.DDLInfo , 1 )
111
111
112
+ initializeUnitSuccess := true
112
113
// when error occurred, initialized units should be closed
113
114
// when continue sub task from loader / syncer, ahead units should be closed
114
115
var needCloseUnits []unit.Unit
@@ -117,7 +118,7 @@ func (st *SubTask) Init() error {
117
118
u .Close ()
118
119
}
119
120
120
- st .initialized .Set (len ( needCloseUnits ) == 0 )
121
+ st .initialized .Set (initializeUnitSuccess )
121
122
}()
122
123
123
124
// every unit does base initialization in `Init`, and this must pass before start running the sub task
@@ -126,6 +127,7 @@ func (st *SubTask) Init() error {
126
127
for i , u := range st .units {
127
128
err := u .Init ()
128
129
if err != nil {
130
+ initializeUnitSuccess = false
129
131
// when init fail, other units initialized before should be closed
130
132
for j := 0 ; j < i ; j ++ {
131
133
needCloseUnits = append (needCloseUnits , st .units [j ])
@@ -140,6 +142,7 @@ func (st *SubTask) Init() error {
140
142
u := st .units [i ]
141
143
isFresh , err := u .IsFreshTask ()
142
144
if err != nil {
145
+ initializeUnitSuccess = false
143
146
return terror .Annotatef (err , "fail to get fresh status of subtask %s %s" , st .cfg .Name , u .Type ())
144
147
} else if ! isFresh {
145
148
skipIdx = i
0 commit comments