@@ -247,31 +247,30 @@ func (r *Registry) ResumeOrCreateRegistration(ctx context.Context, info Registra
247
247
zap .String ("uuid" , operationUUID ),
248
248
zap .Strings ("filters" , info .FilterStrings ))
249
249
return taskID , nil
250
- } else {
251
- // task exists but was either created by another process or has been running
252
- // check if it's in running state
253
- runningRows , _ , err := execCtx .ExecRestrictedSQL (
254
- kv .WithInternalSourceType (ctx , kv .InternalTxnBR ),
255
- nil ,
256
- fmt .Sprintf (getRunningTaskIDSQLTemplate , RegistrationDBName , RegistrationTableName ),
257
- filterStrings , info .StartTS , info .RestoredTS , info .UpstreamClusterID , info .WithSysTable , info .Cmd )
258
- if err != nil {
259
- return 0 , errors .Annotatef (err , "failed to check for running task" )
260
- }
250
+ }
251
+ // task exists but was either created by another process or has been running
252
+ // check if it's in running state
253
+ runningRows , _ , err := execCtx .ExecRestrictedSQL (
254
+ kv .WithInternalSourceType (ctx , kv .InternalTxnBR ),
255
+ nil ,
256
+ fmt .Sprintf (getRunningTaskIDSQLTemplate , RegistrationDBName , RegistrationTableName ),
257
+ filterStrings , info .StartTS , info .RestoredTS , info .UpstreamClusterID , info .WithSysTable , info .Cmd )
258
+ if err != nil {
259
+ return 0 , errors .Annotatef (err , "failed to check for running task" )
260
+ }
261
261
262
- if len (runningRows ) > 0 {
263
- taskID := runningRows [0 ].GetUint64 (0 )
264
- log .Warn ("task already exists and is running" ,
265
- zap .Uint64 ("restore_id" , taskID ))
266
- return 0 , errors .Annotatef (berrors .ErrInvalidArgument ,
267
- "task with ID %d already exists and is running" , taskID )
268
- }
269
- // Task exists but is not running - unexpected state
270
- log .Warn ("task exists but is in an unexpected state" ,
271
- zap .Uint64 ("restore_id" , taskID ),
272
- zap .String ("uuid" , foundUUID ))
273
- return 0 , errors .New ("task exists but is in an unexpected state" )
262
+ if len (runningRows ) > 0 {
263
+ taskID := runningRows [0 ].GetUint64 (0 )
264
+ log .Warn ("task already exists and is running" ,
265
+ zap .Uint64 ("restore_id" , taskID ))
266
+ return 0 , errors .Annotatef (berrors .ErrInvalidArgument ,
267
+ "task with ID %d already exists and is running" , taskID )
274
268
}
269
+ // Task exists but is not running - unexpected state
270
+ log .Warn ("task exists but is in an unexpected state" ,
271
+ zap .Uint64 ("restore_id" , taskID ),
272
+ zap .String ("uuid" , foundUUID ))
273
+ return 0 , errors .New ("task exists but is in an unexpected state" )
275
274
}
276
275
277
276
// no existing task found, create a new one
@@ -389,6 +388,8 @@ func (r *Registry) GetRegistrationsByMaxID(ctx context.Context, maxID uint64) ([
389
388
}
390
389
391
390
for _ , row := range rows {
391
+ log .Info ("found existing restore task" , zap .Uint64 ("restore_id" , row .GetUint64 (0 )),
392
+ zap .Uint64 ("max_id" , maxID ))
392
393
var (
393
394
filterStrings = row .GetString (1 )
394
395
startTS = row .GetUint64 (2 )
0 commit comments