From b80b97f43c80cd4e18443f339c60e5be437b4851 Mon Sep 17 00:00:00 2001 From: xiefengzhu Date: Tue, 26 May 2026 16:19:13 +0800 Subject: [PATCH 1/2] fix ut bug Signed-off-by: xiefengzhu --- .../syncer/distributeddb_relational_ver_p2p_sync_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_relational_ver_p2p_sync_test.cpp b/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_relational_ver_p2p_sync_test.cpp index f05048490f..4550f8c3bd 100644 --- a/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_relational_ver_p2p_sync_test.cpp +++ b/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_relational_ver_p2p_sync_test.cpp @@ -1857,13 +1857,13 @@ HWTEST_F(DistributedDBRelationalVerP2PSyncTest, Observer006, TestSize.Level3) */ Query query = Query::Select(g_tableName); g_rdbDelegatePtr->Sync({DEVICE_B}, SyncMode::SYNC_MODE_PULL_ONLY, query, nullptr, false); - std::this_thread::sleep_for(std::chrono::seconds(1)); + std::this_thread::sleep_for(std::chrono::seconds(10)); // sleep 10 second to wait sync finish + + RuntimeContext::GetInstance()->StopTaskPool(); ASSERT_EQ(g_mgr.CloseStore(g_rdbDelegatePtr), OK); g_rdbDelegatePtr = nullptr; delete g_observer; g_observer = nullptr; - std::this_thread::sleep_for(std::chrono::seconds(10)); // sleep 10 second to wait sync finish - RuntimeContext::GetInstance()->StopTaskPool(); } /* -- Gitee From dcead41e34d8f76a343f4b4a6295b901770b9849 Mon Sep 17 00:00:00 2001 From: xiefengzhu Date: Wed, 27 May 2026 16:36:30 +0800 Subject: [PATCH 2/2] Revert "fix bug" This reverts commit 67b7fb427b3b6d55d6b9f7e24390f6e1a9f2cae8. --- .../syncer/src/cloud/cloud_sync_utils.cpp | 26 +++++++------------ .../syncer/src/cloud/cloud_sync_utils.h | 2 -- .../syncer/src/cloud/cloud_syncer.cpp | 8 +++--- .../syncer/src/cloud/cloud_syncer.h | 2 +- .../src/cloud/cloud_syncer_extend_extend.cpp | 2 +- .../distributeddb_rdb_cloud_error_test.cpp | 18 ++++++++----- 6 files changed, 27 insertions(+), 31 deletions(-) diff --git a/frameworks/libs/distributeddb/syncer/src/cloud/cloud_sync_utils.cpp b/frameworks/libs/distributeddb/syncer/src/cloud/cloud_sync_utils.cpp index 9bd39cd6a3..a0619f8888 100644 --- a/frameworks/libs/distributeddb/syncer/src/cloud/cloud_sync_utils.cpp +++ b/frameworks/libs/distributeddb/syncer/src/cloud/cloud_sync_utils.cpp @@ -1291,24 +1291,16 @@ void CloudSyncUtils::FillCloudErrorActionFromExtend(const std::vector & ICloudSyncer::InnerProcessInfo &info) { for (const auto &item : extend) { - if (FillCloudErrorActionFromExtend(item, info)) { - return; + auto actionIt = item.find(CloudDbConstant::CLOUD_ERROR_ACTION_FIELD); + if (actionIt == item.end() || (actionIt->second.index() != TYPE_INDEX)) { + continue; + } + CloudErrorAction cloudAction = static_cast(std::get(actionIt->second)); + if (cloudAction >= CloudErrorAction::ACTION_DEFAULT && cloudAction < CloudErrorAction::ACTION_BUTT) { + info.innerCloudErrorInfo.cloudAction = cloudAction; + LOGI("[CloudSyncUtils] fill cloud error action: %d", cloudAction); + break; } } } - -bool CloudSyncUtils::FillCloudErrorActionFromExtend(const VBucket &extend, ICloudSyncer::InnerProcessInfo &info) -{ - auto actionIt = extend.find(CloudDbConstant::CLOUD_ERROR_ACTION_FIELD); - if (actionIt == extend.end() || (actionIt->second.index() != TYPE_INDEX)) { - return false; - } - CloudErrorAction cloudAction = static_cast(std::get(actionIt->second)); - if (cloudAction >= CloudErrorAction::ACTION_DEFAULT && cloudAction < CloudErrorAction::ACTION_BUTT) { - info.innerCloudErrorInfo.cloudAction = cloudAction; - LOGI("[CloudSyncUtils] fill cloud error action: %d", cloudAction); - return true; - } - return false; -} } \ No newline at end of file diff --git a/frameworks/libs/distributeddb/syncer/src/cloud/cloud_sync_utils.h b/frameworks/libs/distributeddb/syncer/src/cloud/cloud_sync_utils.h index 3394b3f542..e2eaf6bcb8 100644 --- a/frameworks/libs/distributeddb/syncer/src/cloud/cloud_sync_utils.h +++ b/frameworks/libs/distributeddb/syncer/src/cloud/cloud_sync_utils.h @@ -182,8 +182,6 @@ public: static void FillCloudErrorActionFromExtend(const std::vector &extend, ICloudSyncer::InnerProcessInfo &info); - - static bool FillCloudErrorActionFromExtend(const VBucket &extend, ICloudSyncer::InnerProcessInfo &info); private: static void InsertOrReplaceChangedDataByType(ChangeType type, std::vector &pkVal, ChangedData &changedData); diff --git a/frameworks/libs/distributeddb/syncer/src/cloud/cloud_syncer.cpp b/frameworks/libs/distributeddb/syncer/src/cloud/cloud_syncer.cpp index e8a99e5112..d191506754 100644 --- a/frameworks/libs/distributeddb/syncer/src/cloud/cloud_syncer.cpp +++ b/frameworks/libs/distributeddb/syncer/src/cloud/cloud_syncer.cpp @@ -1398,12 +1398,11 @@ int CloudSyncer::PreHandleData(VBucket &datum, const std::vector &p return E_OK; } -int CloudSyncer::QueryCloudData(TaskId taskId, ICloudSyncer::InnerProcessInfo &info, std::string &cloudWaterMark, +int CloudSyncer::QueryCloudData(TaskId taskId, const std::string &tableName, std::string &cloudWaterMark, DownloadData &downloadData, bool &needCheckWaterMark) { int ret = E_OK; bool isNeedDownload = true; - const std::string &tableName = info.tableName; if (needCheckWaterMark) { needCheckWaterMark = false; ret = IsNeedDownload(tableName, cloudWaterMark, isNeedDownload); @@ -1420,7 +1419,6 @@ int CloudSyncer::QueryCloudData(TaskId taskId, ICloudSyncer::InnerProcessInfo &i ret = cloudDB_.Query(tableName, extend, downloadData.data); storageProxy_->FilterDownloadRecordNotFound(tableName, downloadData); storageProxy_->FilterDownloadRecordNoneSchemaField(tableName, downloadData); - CloudSyncUtils::FillCloudErrorActionFromExtend(extend, info); if ((ret == E_OK || ret == -E_QUERY_END) && downloadData.data.empty()) { if (extend[CloudDbConstant::CURSOR_FIELD].index() != TYPE_INDEX) { LOGE("[CloudSyncer] cursor type is not valid=%d", extend[CloudDbConstant::CURSOR_FIELD].index()); @@ -2103,12 +2101,14 @@ int CloudSyncer::DownloadDataFromCloud(TaskId taskId, SyncParam ¶m, bool isF if (param.isAssetsOnly) { param.cloudWaterMarkForAssetsOnly = param.cloudWaterMark; } - int ret = QueryCloudData(taskId, param.info, param.cloudWaterMark, param.downloadData, param.needCheckWaterMark); + int ret = QueryCloudData(taskId, param.info.tableName, param.cloudWaterMark, param.downloadData, + param.needCheckWaterMark); { std::lock_guard autoLock(dataLock_); CloudSyncUtils::CheckQueryCloudData( cloudTaskInfos_[taskId].prepareTraceId, param.downloadData, param.pkColNames); } + CloudSyncUtils::FillCloudErrorActionFromExtend(param.downloadData.data, param.info); if (ret == -E_QUERY_END) { // Won't break here since downloadData may not be null param.isLastBatch = true; diff --git a/frameworks/libs/distributeddb/syncer/src/cloud/cloud_syncer.h b/frameworks/libs/distributeddb/syncer/src/cloud/cloud_syncer.h index 6d473d7692..dfa2958cb2 100644 --- a/frameworks/libs/distributeddb/syncer/src/cloud/cloud_syncer.h +++ b/frameworks/libs/distributeddb/syncer/src/cloud/cloud_syncer.h @@ -216,7 +216,7 @@ protected: int PreHandleData(VBucket &datum, const std::vector &pkColNames); - int QueryCloudData(TaskId taskId, ICloudSyncer::InnerProcessInfo &info, std::string &cloudWaterMark, + int QueryCloudData(TaskId taskId, const std::string &tableName, std::string &cloudWaterMark, DownloadData &downloadData, bool &needCheckWaterMark); size_t GetCurrentCommonTaskNum(); diff --git a/frameworks/libs/distributeddb/syncer/src/cloud/cloud_syncer_extend_extend.cpp b/frameworks/libs/distributeddb/syncer/src/cloud/cloud_syncer_extend_extend.cpp index 017bd830f8..df59219973 100644 --- a/frameworks/libs/distributeddb/syncer/src/cloud/cloud_syncer_extend_extend.cpp +++ b/frameworks/libs/distributeddb/syncer/src/cloud/cloud_syncer_extend_extend.cpp @@ -397,7 +397,7 @@ int CloudSyncer::DownloadGIDFromCloud(SyncParam ¶m) errCode = E_OK; param.isLastBatch = true; } - CloudSyncUtils::FillCloudErrorActionFromExtend(extend, param.info); + CloudSyncUtils::FillCloudErrorActionFromExtend(param.downloadData.data, param.info); if (errCode != E_OK) { LOGE("[CloudSyncer] Query cloud gid failed[%d]", errCode); } else if (!param.downloadData.data.empty()) { diff --git a/frameworks/libs/distributeddb/test/unittest/common/store_test/rdb/distributeddb_rdb_cloud_error_test.cpp b/frameworks/libs/distributeddb/test/unittest/common/store_test/rdb/distributeddb_rdb_cloud_error_test.cpp index a4753241a5..7938c6e3f7 100644 --- a/frameworks/libs/distributeddb/test/unittest/common/store_test/rdb/distributeddb_rdb_cloud_error_test.cpp +++ b/frameworks/libs/distributeddb/test/unittest/common/store_test/rdb/distributeddb_rdb_cloud_error_test.cpp @@ -198,8 +198,10 @@ HWTEST_F(DistributedDBRDBCloudErrorTest, RdbCloudErrorActionTest001, TestSize.Le ASSERT_NO_FATAL_FAILURE(InsertCloudRecordBatch(CLOUD_TABLE, 1, DATA_COUNT)); cloudDB->ForkAfterQueryResult([](VBucket &extend, std::vector &data) -> DBStatus { - extend[CloudDbConstant::CLOUD_ERROR_ACTION_FIELD] = - static_cast(CloudErrorAction::ACTION_RETRY_SYNC_TASK); + for (auto &record : data) { + record[CloudDbConstant::CLOUD_ERROR_ACTION_FIELD] = + static_cast(CloudErrorAction::ACTION_RETRY_SYNC_TASK); + } return DBStatus::QUERY_END; }); @@ -224,8 +226,10 @@ HWTEST_F(DistributedDBRDBCloudErrorTest, RdbCloudErrorActionTest002, TestSize.Le ASSERT_NO_FATAL_FAILURE(InsertCloudRecordBatch(CLOUD_TABLE, 1, DATA_COUNT)); ASSERT_NO_FATAL_FAILURE(InsertLocalRecordBatch(info1_, CLOUD_TABLE, DATA_COUNT + 1, DATA_COUNT)); cloudDB->ForkAfterQueryResult([](VBucket &extend, std::vector &data) -> DBStatus { - extend[CloudDbConstant::CLOUD_ERROR_ACTION_FIELD] = - static_cast(CloudErrorAction::ACTION_RETRY_SYNC_TASK); + for (auto &record : data) { + record[CloudDbConstant::CLOUD_ERROR_ACTION_FIELD] = + static_cast(CloudErrorAction::ACTION_RETRY_SYNC_TASK); + } return DBStatus::QUERY_END; }); cloudDB->ForkUpload([](const std::string &tableName, VBucket &extend) { @@ -260,8 +264,10 @@ HWTEST_F(DistributedDBRDBCloudErrorTest, RdbCloudErrorActionTest003, TestSize.Le ASSERT_NO_FATAL_FAILURE(InsertCloudRecordBatch(CLOUD_TABLE, DATA_COUNT, DATA_COUNT)); cloudDB->ForkAfterQueryResult([](VBucket &extend, std::vector &data) -> DBStatus { - extend[CloudDbConstant::CLOUD_ERROR_ACTION_FIELD] = - static_cast(CloudErrorAction::ACTION_RETRY_SYNC_TASK); + for (auto &record : data) { + record[CloudDbConstant::CLOUD_ERROR_ACTION_FIELD] = + static_cast(CloudErrorAction::ACTION_RETRY_SYNC_TASK); + } return DBStatus::QUERY_END; }); cloudDB->ForkBeforeBatchUpdate([](const std::string &tableName, std::vector &record, -- Gitee