github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/dm/proto/dmworker.proto (about) 1 syntax = "proto3"; 2 3 package pb; 4 5 6 service Worker { 7 rpc QueryStatus (QueryStatusRequest) returns (QueryStatusResponse) {} 8 9 // PurgeRelay purges relay log files for this dm-worker 10 rpc PurgeRelay (PurgeRelayRequest) returns (CommonWorkerResponse) {} 11 12 // Operate (get/set/remove) schema for a specified table in tracker. 13 // a `set`/`remove` operation should be an one-time operation (only take effect once), 14 // so we use a gRPC method rather than a etcd operation now (no persistent operation state). 15 rpc OperateSchema(OperateWorkerSchemaRequest) returns(CommonWorkerResponse) {} 16 17 rpc OperateV1Meta(OperateV1MetaRequest) returns(OperateV1MetaResponse) {} 18 19 rpc HandleError(HandleWorkerErrorRequest) returns(CommonWorkerResponse) {} 20 21 rpc GetWorkerCfg(GetWorkerCfgRequest) returns(GetWorkerCfgResponse) {} 22 23 // only some fields of the configuration of the subtask in the sync phase can be updated 24 rpc CheckSubtasksCanUpdate(CheckSubtasksCanUpdateRequest) returns (CheckSubtasksCanUpdateResponse) {} 25 26 rpc GetWorkerValidatorStatus(GetValidationStatusRequest) returns (GetValidationStatusResponse) {} 27 28 rpc GetValidatorError(GetValidationErrorRequest) returns(GetValidationErrorResponse) {} 29 30 rpc OperateValidatorError(OperateValidationErrorRequest) returns(OperateValidationErrorResponse) {} 31 32 rpc UpdateValidator(UpdateValidationWorkerRequest) returns(CommonWorkerResponse) {} 33 } 34 35 enum TaskOp { 36 InvalidOp = 0; // placeholder 37 Stop = 1; 38 Pause = 2; 39 Resume = 3; 40 Start = 4; 41 Update = 5; 42 AutoResume = 6; 43 Delete = 7; 44 } 45 46 message QueryStatusRequest { 47 string name = 1; // sub task's name, empty for all sub tasks 48 } 49 50 message CommonWorkerResponse { 51 bool result = 1; 52 string msg = 2; // when result is true, msg is empty, except for operate schema 53 string source = 3; // source ID, set by dm-master 54 string worker = 4; // worker name, set by dm-worker config 55 } 56 57 // QueryStatusResponse represents status response for query on a dm-worker 58 // status: dm-worker's current sub tasks' status 59 message QueryStatusResponse { 60 bool result = 1; 61 string msg = 2; 62 SourceStatus sourceStatus = 3; 63 repeated SubTaskStatus subTaskStatus = 4; 64 } 65 66 // Stage represents current stage for a (sub) task 67 // a (sub) task should be always in one stage of the following stages 68 // (sub) task can transfer from on stage to some special other stages 69 // New: initial stage when a sub task is created 70 // can not be transferred from other stages 71 // transfers to Running when initialize with no error 72 // Running: indicates the sub task is processing 73 // is transferred from New when created successfully 74 // is transferred from Paused when resuming is requested 75 // transfers to Paused when error occurred or requested from external 76 // transfers to Stopped when requested from external 77 // transfers to Finished when sub task processing completed (no Syncer used) 78 // Paused: indicates the processing is paused, and can be resume from external request 79 // is transferred from Running when error occurred or requested from external 80 // transfers to Running when resuming is requested from external 81 // transfers to Stopped when requested from external 82 // Stopped: indicates the processing is stopped, and can not be resume (or re-run) again 83 // is transferred from Running / Paused when requested from external 84 // can not transfer to any stages 85 // Finished: indicates the processing is finished, and no need to re-run 86 // is transferred from Running when processing completed 87 // should not transfer to any stages 88 enum Stage { 89 InvalidStage = 0; // placeholder 90 New = 1; 91 Running = 2; 92 Paused = 3; 93 Stopped = 4; 94 Finished = 5; 95 96 Pausing = 6; 97 Resuming = 7; 98 Stopping = 8; 99 } 100 101 // CheckStatus represents status for check unit 102 // adds fields later 103 message CheckStatus { 104 bool passed = 1; 105 int32 total = 2; 106 int32 successful = 3; 107 int32 failed = 4; 108 int32 warning = 5; 109 110 bytes detail = 6; 111 } 112 113 // DumpStatus represents status for dump unit 114 // add fields later 115 message DumpStatus { 116 int64 totalTables = 1; 117 double completedTables = 2; 118 double finishedBytes = 3; 119 double finishedRows = 4; 120 double estimateTotalRows = 5; 121 int64 bps = 6; 122 string progress = 7; 123 } 124 125 // LoadStatus represents status for load unit 126 message LoadStatus { 127 int64 finishedBytes = 1; 128 int64 totalBytes = 2; 129 string progress = 3; 130 string metaBinlog = 4; 131 string metaBinlogGTID = 5; 132 int64 bps = 6; 133 } 134 135 // ShardingGroup represents a DDL sharding group, this is used by SyncStatus, and is differ from ShardingGroup in syncer pkg 136 // target: target table name 137 // DDL: in syncing DDL 138 // firstPos: first DDL binlog pos for this group 139 // synced: synced source tables 140 // unsynced: unsynced source tables 141 message ShardingGroup { 142 string target = 1; 143 repeated string DDLs = 2; 144 string firstLocation = 3; 145 repeated string synced = 4; 146 repeated string unsynced = 5; 147 } 148 149 // SyncStatus represents status for sync unit 150 message SyncStatus { 151 // totalEvents/totalTps/recentTps has been deprecated now 152 int64 totalEvents = 1; 153 int64 totalTps = 2; 154 int64 recentTps = 3; 155 string masterBinlog = 4; 156 string masterBinlogGtid = 5; 157 string syncerBinlog = 6; 158 string syncerBinlogGtid = 7; 159 repeated string blockingDDLs = 8; // sharding DDL which current is blocking 160 repeated ShardingGroup unresolvedGroups = 9; // sharding groups which current are un-resolved 161 bool synced = 10; // whether sync is catched-up in this moment 162 string binlogType = 11; 163 int64 secondsBehindMaster = 12; // sync unit delay seconds behind master. 164 string blockDDLOwner = 13; // block ddl upstream info, format "task-`upstreamDatabase`.`upstreamTable`" 165 string conflictMsg = 14; // block ddl conflict reason 166 int64 totalRows = 15; 167 int64 totalRps = 16; 168 int64 recentRps = 17; 169 } 170 171 // SourceStatus represents status for source runing on dm-worker 172 message SourceStatus { 173 string source = 1; // sourceID, set by dm-master 174 string worker = 2; // worker name bound to this source 175 ProcessResult result = 3; 176 RelayStatus relayStatus = 4; 177 } 178 179 // RelayStatus represents status for relay unit. 180 message RelayStatus { 181 string masterBinlog = 1; 182 string masterBinlogGtid = 2; 183 string relaySubDir = 3; 184 string relayBinlog = 4; 185 string relayBinlogGtid = 5; 186 bool relayCatchUpMaster = 6; 187 Stage stage = 7; 188 ProcessResult result = 8; 189 } 190 191 // SubTaskStatus represents status for a sub task 192 // name: sub task'name, when starting a sub task the name should be unique 193 // stage: sub task's current stage 194 // unit: sub task's current dm unit's UnitType 195 // result: current unit's process result, when the stage is Running, no result 196 // unresolvedDDLLockID: un-resolved sharding DDL lock ID (ref DDLLockInfo) 197 // if needed, we can put this to SyncStatus 198 // status: current unit's statistics 199 // for Load, includes total bytes, progress, etc. 200 // for Sync, includes TPS, binlog meta, etc. 201 message SubTaskStatus { 202 string name = 1; 203 Stage stage = 2; 204 UnitType unit = 3; 205 ProcessResult result = 4; 206 string unresolvedDDLLockID = 5; 207 oneof status { 208 string msg = 6; // message when error occurred 209 CheckStatus check = 7; 210 DumpStatus dump = 8; 211 LoadStatus load = 9; 212 SyncStatus sync = 10; 213 } 214 ValidationStatus validation = 11; 215 } 216 217 // SubTaskStatusList used for internal jsonpb marshal 218 message SubTaskStatusList { 219 repeated SubTaskStatus status = 1; 220 } 221 222 // CheckError represents error for check unit 223 // adds fields later 224 message CheckError { 225 string msg = 1; 226 } 227 228 // DumpError represents error for dump unit 229 // add fields later 230 message DumpError { 231 string msg = 1; 232 } 233 234 // LoadError represents error for load unit 235 message LoadError { 236 string msg = 1; 237 } 238 239 // SyncSQLError represents a sql error in sync unit 240 message SyncSQLError { 241 string msg = 1; 242 string failedBinlogPosition = 2; 243 string errorSQL = 3; 244 } 245 246 // SyncError represents error list for sync unit 247 message SyncError { 248 repeated SyncSQLError errors = 1; 249 } 250 251 // SourceError represents error for start/stop source on dm-worker 252 message SourceError { 253 string source = 1; 254 string worker = 2; 255 string SourceError = 3; 256 RelayError RelayError = 4; // RelayError represents error for relay unit. 257 } 258 259 // RelayError represents error for relay unit. 260 message RelayError { 261 string msg = 1; 262 } 263 264 // SubTaskError represents error for a sub task during running 265 // name: sub task'name, when starting a sub task the name should be unique 266 // stage: sub task's current stage 267 // unit: sub task's current dm unit's UnitType 268 // error: current unit's error information 269 // for Sync, includes failed sql, failed sql pos in binlog, etc. 270 message SubTaskError { 271 string name = 1; 272 Stage stage = 2; 273 UnitType unit = 3; 274 oneof error { 275 string msg = 4; // message when error occurred 276 CheckError check = 5; 277 DumpError dump = 6; 278 LoadError load = 7; 279 SyncError sync = 8; 280 } 281 } 282 283 // SubTaskErrorList used for internal jsonpb marshal 284 message SubTaskErrorList { 285 repeated SubTaskError error = 1; 286 } 287 288 // UnitType represents the dm unit's type 289 enum UnitType { 290 InvalidUnit = 0; // placeholder 291 Check = 1; 292 Dump = 2; 293 Load = 3; 294 Sync = 4; 295 Relay = 100; // relay is a special unit 296 } 297 298 // ProcessResult represents results produced by a dm unit 299 // isCanceled: indicates whether the process is canceled from external 300 // when Stop or Pause is requested from external, isCanceled will be true 301 // errors: includes all (potential) errors occured when processing 302 message ProcessResult { 303 bool isCanceled = 1; 304 repeated ProcessError errors = 2; 305 bytes detail = 3; 306 } 307 308 // ProcessError is same as terror used in dm 309 // NOTE: currently stack trace is not supported, `Message` is the `terror.Error.getMsg` result 310 // and `RawCause` is the `Error` result of error from `terror.Error.Cause()`. 311 message ProcessError { 312 int32 ErrCode = 1; 313 string ErrClass = 2; 314 string ErrScope = 3; 315 string ErrLevel = 4; 316 string Message = 5; 317 string RawCause = 6; 318 string Workaround = 7; 319 } 320 321 // RelayOp differs from TaskOp 322 enum RelayOp { 323 InvalidRelayOp = 0; // placeholder 324 StopRelay = 1; 325 PauseRelay = 2; 326 ResumeRelay = 3; 327 } 328 329 // PurgeRelayRequest represents a request to purge relay log files for this dm-worker 330 // inactive: whether purge inactive relay log files 331 // time: whether purge relay log files before this time, the number of seconds elapsed since January 1, 1970 UTC 332 // filename: whether purge relay log files before this filename 333 // subDir: specify relay sub directory for @filename 334 message PurgeRelayRequest { 335 bool inactive = 1; 336 int64 time = 2; 337 string filename = 3; 338 string subDir = 4; 339 } 340 341 enum SchemaOp { 342 InvalidSchemaOp = 0; 343 GetSchema = 1; 344 SetSchema = 2; 345 RemoveSchema = 3; 346 ListSchema = 4; 347 ListTable = 5; 348 ListMigrateTargets = 6; 349 } 350 351 message OperateWorkerSchemaRequest { 352 SchemaOp op = 1; // operation type 353 string task = 2; // task name 354 string source = 3; // source ID 355 string database = 4; // database name 356 string table = 5; // table name 357 string schema = 6; // schema content, a `CREATE TABLE` statement 358 bool flush = 7; // flush table info and checkpoint 359 bool sync = 8; // sync the table info to master 360 bool fromSource = 9; // update schema from source schema 361 bool fromTarget = 10; // update schema from target schema 362 } 363 364 // copied `TaskMeta` from release-1.0 branch. 365 message V1SubTaskMeta { 366 TaskOp op = 1; 367 Stage stage = 2; // the stage of sub-task after we apply some operations 368 string name = 3; // sub task's name 369 bytes task = 4; // (sub) task's configuration 370 } 371 372 enum V1MetaOp { 373 InvalidV1MetaOp = 0; 374 GetV1Meta = 1; 375 RemoveV1Meta = 2; 376 } 377 378 message OperateV1MetaRequest { 379 V1MetaOp op = 1; 380 } 381 382 message OperateV1MetaResponse { 383 bool result = 1; 384 string msg = 2; // error message if failed. 385 map<string, V1SubTaskMeta> meta = 3; // subtasks' meta for `get` operation. 386 } 387 388 enum ErrorOp { 389 InvalidErrorOp = 0; 390 Skip = 1; // skip the error event 391 Replace = 2; // replace the error event with a specified SQL 392 Revert = 3; // remove the error operator 393 Inject = 4; // inject a specified SQL 394 List = 5; // show handle error commands 395 } 396 397 message HandleWorkerErrorRequest { 398 ErrorOp op = 1; // operation type 399 string task = 2; // task name 400 string binlogPos = 3; // binlog-pos (that's file:pos format) 401 repeated string sqls = 4; // sqls (use for replace) 402 } 403 404 message GetWorkerCfgRequest { 405 } 406 407 message GetWorkerCfgResponse { 408 string cfg = 1; 409 } 410 411 enum ValidatorOp { 412 InvalidValidatorOp = 0; 413 StartValidator = 1; 414 StopValidator = 2; 415 } 416 417 message CheckSubtasksCanUpdateRequest { string subtaskCfgTomlString = 1; } 418 419 message CheckSubtasksCanUpdateResponse { 420 bool success = 1; 421 string msg = 2; // message when error occurred 422 } 423 424 message GetValidationStatusRequest { 425 string taskName = 1; 426 Stage filterStatus = 2; 427 } 428 429 message ValidationStatus { 430 string task = 1; 431 string source = 2; 432 string mode = 3; 433 Stage stage = 4; 434 string validatorBinlog = 5; 435 string validatorBinlogGtid = 6; 436 ProcessResult result = 7; 437 string processedRowsStatus = 8; 438 string pendingRowsStatus = 9; 439 string errorRowsStatus = 10; 440 string cutoverBinlogPos = 11; 441 string cutoverBinlogGtid = 12; 442 } 443 444 message ValidationTableStatus { 445 string source = 1; 446 string srcTable = 2; 447 string dstTable = 3; 448 Stage stage = 4; 449 string message = 5; 450 } 451 452 message GetValidationStatusResponse { 453 bool result = 1; 454 string msg = 2; 455 repeated ValidationStatus validators = 3; 456 repeated ValidationTableStatus tableStatuses = 4; 457 } 458 message GetValidationErrorRequest { 459 ValidateErrorState errState = 1; 460 string taskName = 2; 461 } 462 463 message ValidationError { 464 string id = 1; // error-id 465 string source = 2; 466 string srcTable = 3; 467 string srcData = 4; 468 string dstTable = 5; 469 string dstData = 6; 470 string errorType = 7; 471 ValidateErrorState status = 8; 472 string time = 9; 473 string message = 10; 474 } 475 476 message GetValidationErrorResponse { 477 bool result = 1; 478 string msg = 2; 479 repeated ValidationError error = 3; 480 } 481 482 enum ValidateErrorState { 483 InvalidErr = 0; 484 NewErr = 1; 485 IgnoredErr = 2; 486 ResolvedErr = 3; 487 } 488 489 message OperateValidationErrorRequest { 490 ValidationErrOp op = 1; 491 bool isAllError = 2; 492 string taskName = 3; 493 uint64 errId = 4; // error-id 494 } 495 496 message OperateValidationErrorResponse { 497 bool result = 1; 498 string msg = 2; 499 } 500 501 enum ValidationErrOp { 502 InvalidErrOp = 0; 503 IgnoreErrOp = 1; 504 ResolveErrOp = 2; 505 ClearErrOp = 3; 506 } 507 508 509 message UpdateValidationWorkerRequest { 510 string taskName = 1; 511 string binlogPos = 2; // binlog-pos (that's (file:pos) format) 512 string binlogGTID = 3; 513 }