From 370c25512822ad679cd9ce9bc91b1a4845d49e63 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sat, 11 May 2024 10:27:55 +0800 Subject: [PATCH] refactor: do some internal refactor. --- source/common/src/rsync.c | 22 +++++++++++++--------- source/libs/stream/src/streamCheckpoint.c | 3 +-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/source/common/src/rsync.c b/source/common/src/rsync.c index 867b407296..2324829dbb 100644 --- a/source/common/src/rsync.c +++ b/source/common/src/rsync.c @@ -153,16 +153,16 @@ void startRsync() { } int32_t uploadRsync(const char* id, const char* path) { + int64_t st = taosGetTimestampMs(); + char command[PATH_MAX] = {0}; + #ifdef WINDOWS char pathTransform[PATH_MAX] = {0}; changeDirFromWindowsToLinux(path, pathTransform); -#endif - char command[PATH_MAX] = {0}; -#ifdef WINDOWS - if(pathTransform[strlen(pathTransform) - 1] != '/'){ + if(pathTransform[strlen(pathTransform) - 1] != '/') { #else - if(path[strlen(path) - 1] != '/'){ + if (path[strlen(path) - 1] != '/') { #endif snprintf(command, PATH_MAX, "rsync -av --delete --timeout=10 --bwlimit=100000 %s/ rsync://%s/checkpoint/%s/", #ifdef WINDOWS @@ -178,16 +178,20 @@ int32_t uploadRsync(const char* id, const char* path) { #else path #endif - , tsSnodeAddress, id); + , + tsSnodeAddress, id); } int32_t code = execCommand(command); - if(code != 0){ - uError("[rsync] send failed code:%d," ERRNO_ERR_FORMAT, code, ERRNO_ERR_DATA); + if (code != 0) { + uError("[rsync] s-task:%s upload checkpoint data in:%s to %s failed, code:%d", id, path, tsSnodeAddress, + ERRNO_ERR_FORMAT, code, ERRNO_ERR_DATA); return -1; } - uDebug("[rsync] upload data:%s successful", id); + int64_t el = (taosGetTimestampMs() - st); + uDebug("[rsync] s-task:%s upload checkpoint data in:%s to %s successfully, elapsed time:%" PRId64 "ms", id, path, + tsSnodeAddress, el); return 0; } diff --git a/source/libs/stream/src/streamCheckpoint.c b/source/libs/stream/src/streamCheckpoint.c index a1e6838ac3..2f1771279f 100644 --- a/source/libs/stream/src/streamCheckpoint.c +++ b/source/libs/stream/src/streamCheckpoint.c @@ -368,8 +368,7 @@ int32_t uploadCheckpointData(void* param) { } if ((code = taskDbGenChkpUploadData(pParam->pTask->pBackend, ((SStreamMeta*)pParam->pMeta)->bkdChkptMgt, - pParam->chkpId, - (int8_t)(pParam->type), &path, toDelFiles)) != 0) { + pParam->chkpId, (int8_t)(pParam->type), &path, toDelFiles)) != 0) { stError("s-task:%s failed to gen upload checkpoint:%" PRId64, taskStr, pParam->chkpId); }