From 1293d5acc7bb3b18ad158856a64a7cf8fe911343 Mon Sep 17 00:00:00 2001 From: zph Date: Thu, 31 Jul 2025 19:03:21 +0800 Subject: [PATCH 1/3] update Signed-off-by: zph --- .../service/kvdb/kvdb_service_impl.cpp | 23 +-------------- .../service/udmf/udmf_service_impl.cpp | 28 +++++++++++++++---- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp b/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp index 7c628c8d4..1bcfea353 100644 --- a/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp +++ b/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp @@ -1094,39 +1094,18 @@ Status KVDBServiceImpl::DoSync(const StoreMetaData &meta, const SyncInfo &info, Status KVDBServiceImpl::DoSyncInOrder( const StoreMetaData &meta, const SyncInfo &info, const SyncEnd &complete, int32_t type) { - ZLOGD("type:%{public}d seqId:0x%{public}" PRIx64 " remote:%{public}zu appId:%{public}s storeId:%{public}s", type, - info.seqId, info.devices.size(), meta.bundleName.c_str(), Anonymous::Change(meta.storeId).c_str()); auto uuids = ConvertDevices(info.devices); if (uuids.empty()) { - ZLOGW("no device seqId:0x%{public}" PRIx64 " remote:%{public}zu appId:%{public}s storeId:%{public}s", - info.seqId, info.devices.size(), meta.bundleName.c_str(), Anonymous::Change(meta.storeId).c_str()); return Status::DEVICE_NOT_ONLINE; } if (IsNeedMetaSync(meta, uuids)) { - auto recv = DeviceMatrix::GetInstance().GetRecvLevel(uuids[0], - static_cast(DataType::TYPE_DYNAMICAL)); - RADAR_REPORT(STANDARD_DEVICE_SYNC, STANDARD_META_SYNC, RADAR_START, - SYNC_STORE_ID, Anonymous::Change(meta.storeId), SYNC_APP_ID, meta.bundleName, CONCURRENT_ID, - std::to_string(info.syncId), DATA_TYPE, meta.dataType, WATER_VERSION, recv.second); - auto result = MetaDataManager::GetInstance().Sync( - uuids, [this, meta, info, complete, type](const auto &results) { - RADAR_REPORT(STANDARD_DEVICE_SYNC, STANDARD_META_SYNC, RADAR_SUCCESS, - SYNC_STORE_ID, Anonymous::Change(meta.storeId), SYNC_APP_ID, meta.bundleName, CONCURRENT_ID, - std::to_string(info.syncId), DATA_TYPE, meta.dataType); + auto result = MetaDataManager::GetInstance().Sync(uuids, [this, meta, info, complete, type](const auto &results) { auto ret = ProcessResult(results); if (ret.first.empty()) { - DoComplete(meta, info, RefCount(), ret.second); return; } auto status = DoSyncBegin(ret.first, meta, info, complete, type); - ZLOGD("data sync status:%{public}d appId:%{public}s, storeId:%{public}s", - static_cast(status), meta.bundleName.c_str(), Anonymous::Change(meta.storeId).c_str()); }); - if (!result) { - RADAR_REPORT(STANDARD_DEVICE_SYNC, STANDARD_META_SYNC, RADAR_FAILED, ERROR_CODE, Status::ERROR, - BIZ_STATE, END, SYNC_STORE_ID, Anonymous::Change(meta.storeId), SYNC_APP_ID, meta.bundleName, - CONCURRENT_ID, std::to_string(info.syncId), DATA_TYPE, meta.dataType); - } return result ? Status::SUCCESS : Status::ERROR; } return DoSyncBegin(uuids, meta, info, complete, type); diff --git a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp index dc285565a..86b78036d 100644 --- a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp +++ b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp @@ -672,16 +672,19 @@ int32_t UdmfServiceImpl::StoreSync(const UnifiedKey &key, const QueryOption &que int32_t id = AccountDelegate::GetInstance()->GetUserByToken(IPCSkeleton::GetCallingFullTokenID()); StoreMetaData meta = StoreMetaData(std::to_string(id), Bootstrap::GetInstance().GetProcessLabel(), key.intention); auto uuids = DmAdapter::GetInstance().ToUUID(devices); - if (IsNeedMetaSync(meta, uuids) && !MetaDataManager::GetInstance().Sync(uuids, - [devices, callback, store] (auto &results) { - if (store->Sync(devices, callback) != E_OK) { + if (IsNeedMetaSync(meta, uuids)) { + bool res = MetaDataManager::GetInstance().Sync(uuids, [this, devices, callback, store] (auto &results) { + auto successRes = ProcessResult(results); + if (store->Sync(successRes, callback) != E_OK) { ZLOGE("Store sync failed"); RadarReporterAdapter::ReportFail(std::string(__FUNCTION__), BizScene::SYNC_DATA, SyncDataStage::SYNC_END, StageRes::FAILED, E_DB_ERROR, BizState::DFX_END); + } + }); + if (!res) { + ZLOGE("Meta sync failed"); } - })) { - ZLOGE("bundleName:%{public}s, meta sync failed", key.bundleName.c_str()); - return E_DB_ERROR; + return res ? E_OK : E_DB_ERROR; } if (store->Sync(devices, callback) != E_OK) { ZLOGE("Store sync failed"); @@ -1294,5 +1297,18 @@ void UdmfServiceImpl::HandleDbError(const std::string &intention, int32_t &statu status = E_DB_ERROR; } } + +std::vector UdmfServiceImpl::ProcessResult(const std::map &results) +{ + std::vector devices; + for (const auto &[uuid, status] : results) { + if (static_cast(status) == DistributedDB::DBStatus::OK) { + DeviceMatrix::GetInstance().OnExchanged(uuid, DeviceMatrix::META_STORE_MASK); + devices.emplace_back(uuid); + } + } + ZLOGI("Meta sync finish, total size:%{public}zu, success size:%{public}zu", results.size(), devices.size()); + return devices; +} } // namespace UDMF } // namespace OHOS \ No newline at end of file -- Gitee From 82b75df17cac82c19f2013e1b6a17f009eb07f22 Mon Sep 17 00:00:00 2001 From: zph Date: Mon, 4 Aug 2025 11:18:46 +0800 Subject: [PATCH 2/3] update Signed-off-by: zph --- .../distributeddataservice/service/udmf/udmf_service_impl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp index 61ea9f78c..581a5baa5 100644 --- a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp +++ b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp @@ -684,8 +684,9 @@ int32_t UdmfServiceImpl::StoreSync(const UnifiedKey &key, const QueryOption &que ZLOGE("Meta sync failed"); RadarReporterAdapter::ReportFail(std::string(__FUNCTION__), BizScene::SYNC_DATA, SyncDataStage::SYNC_END, StageRes::FAILED, E_DB_ERROR, BizState::DFX_END); + return E_DB_ERROR; } - return res ? E_OK : E_DB_ERROR; + return E_OK; } if (store->Sync(devices, callback) != E_OK) { ZLOGE("Store sync failed"); -- Gitee From 18549ab2cd5d606254155f01320baac60cd32ebc Mon Sep 17 00:00:00 2001 From: zph Date: Mon, 4 Aug 2025 15:01:44 +0800 Subject: [PATCH 3/3] update Signed-off-by: zph --- .../distributeddataservice/service/udmf/udmf_service_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp index 581a5baa5..668f65a0a 100644 --- a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp +++ b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp @@ -707,7 +707,7 @@ bool UdmfServiceImpl::IsNeedMetaSync(const StoreMetaData &meta, const std::vecto CapMetaData capMeta; auto capKey = CapMetaRow::GetKeyFor(uuid); if (!MetaDataManager::GetInstance().LoadMeta(std::string(capKey.begin(), capKey.end()), capMeta) || - !MetaDataManager::GetInstance().LoadMeta(metaData.GetKey(), metaData)) { + !MetaDataManager::GetInstance().LoadMeta(metaData.GetKeyWithoutPath(), metaData)) { isAfterMeta = true; break; } -- Gitee