From 118a719836ecf586336578de7b1ce5d547177145 Mon Sep 17 00:00:00 2001 From: lidwchn Date: Tue, 11 Jan 2022 11:11:11 +0800 Subject: [PATCH 1/2] Add debug logs. Signed-off-by: lidwchn --- .../common/src/runtime_context_impl.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/services/distributeddataservice/libs/distributeddb/common/src/runtime_context_impl.cpp b/services/distributeddataservice/libs/distributeddb/common/src/runtime_context_impl.cpp index faaa671e6..39c12f0fb 100755 --- a/services/distributeddataservice/libs/distributeddb/common/src/runtime_context_impl.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/runtime_context_impl.cpp @@ -20,6 +20,7 @@ #include "network_adapter.h" namespace DistributedDB { +static std::atomic_uint taskID = 100000; // 100000 as the base no RuntimeContextImpl::RuntimeContextImpl() : adapter_(nullptr), communicatorAggregator_(nullptr), @@ -232,7 +233,12 @@ int RuntimeContextImpl::ScheduleTask(const TaskAction &task) LOGE("Schedule task failed, fail to prepare task pool."); return errCode; } - return taskPool_->Schedule(task); + auto id = taskID++; + LOGI("Schedule task succeed, ID:%u", id); + return taskPool_->Schedule([task, id] { + LOGI("Exec task, ID:%u", id); + task(); + }); } int RuntimeContextImpl::ScheduleQueuedTask(const std::string &queueTag, @@ -244,7 +250,13 @@ int RuntimeContextImpl::ScheduleQueuedTask(const std::string &queueTag, LOGE("Schedule queued task failed, fail to prepare task pool."); return errCode; } - return taskPool_->Schedule(queueTag, task); + + auto id = taskID++; + LOGI("Schedule queued task succeed, ID:%u", id); + return taskPool_->Schedule(queueTag, [task, id] { + LOGI("Exec queued task, ID:%u", id); + task(); + }); } void RuntimeContextImpl::ShrinkMemory(const std::string &description) -- Gitee From 5cc6d770bc0eef7d3ee0cdc130c06747173a7ba4 Mon Sep 17 00:00:00 2001 From: lidwchn Date: Tue, 11 Jan 2022 16:26:37 +0800 Subject: [PATCH 2/2] Add the whole log. Signed-off-by: lidwchn --- .../libs/distributeddb/storage/src/generic_kvdb.cpp | 2 ++ .../storage/src/generic_kvdb_connection.cpp | 9 +++++++++ .../sqlite_single_ver_natural_store_connection.cpp | 1 + 3 files changed, 12 insertions(+) diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb.cpp index 9802edf55..e9aa62c25 100755 --- a/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb.cpp @@ -115,10 +115,12 @@ void GenericKvDB::CommitNotify(int notifyEvent, KvDBCommitNotifyFilterAbleData * } ++eventNotifyCounter_; if (data == nullptr) { + LOGE("notify data empty, something wrong"); notificationChain_->NotifyEvent(static_cast(notifyEvent), nullptr); } else { data->SetMyDb(this, eventNotifyCounter_); data->IncObjRef(data); + LOGI("start to notify data changed"); int errCode = RuntimeContext::GetInstance()->ScheduleQueuedTask(GetStoreId(), std::bind(&GenericKvDB::CommitNotifyAsync, this, notifyEvent, data)); if (errCode != E_OK) { diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb_connection.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb_connection.cpp index 8bc0c9026..1ef52d6bd 100755 --- a/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb_connection.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb_connection.cpp @@ -278,22 +278,31 @@ NotificationChain::Listener *GenericKvDBConnection::RegisterSpecialListener(int uint64_t notifyBarrier = kvDB_->GetEventNotifyCounter(); return kvDB_->RegisterEventListener(static_cast(type), [key, action, conflict, notifyBarrier](void *ptr) { + LOGI("Callback succeed."); if (ptr == nullptr) { + LOGE("notify data is null, something wrong"); return; } KvDBCommitNotifyFilterAbleData *data = static_cast(ptr); if (data->GetNotifyID() <= notifyBarrier) { + LOGE("notify id invalid, something wrong"); return; } data->SetFilterKey(key); if (conflict) { + LOGI("this is a conflict notify"); if (!data->IsConflictedDataEmpty()) { + LOGI("conflict data not empty. call onchange"); action(*data); } + LOGI("conflict notify finish"); } else { + LOGI("this is a observer notify"); if (!data->IsChangedDataEmpty()) { + LOGI("observer data not empty. call onchange"); action(*data); } + LOGI("observer notify finish"); } }, nullptr, errCode); } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp index fc54546f8..b1f9dc77c 100755 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp @@ -1188,6 +1188,7 @@ int SQLiteSingleVerNaturalStoreConnection::CheckLocalKeysValid(const std::vector void SQLiteSingleVerNaturalStoreConnection::CommitAndReleaseNotifyData( SingleVerNaturalStoreCommitNotifyData *&committedData, bool isNeedCommit, int eventType) { + LOGI("SQLiteSingleVerNaturalStoreConnection::CommitAndReleaseNotifyData start, type=%d", eventType); SQLiteSingleVerNaturalStore *naturalStore = GetDB(); if ((naturalStore != nullptr) && (committedData != nullptr)) { if (isNeedCommit) { -- Gitee