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 faaa671e6eef7b97f307b16696a0bf68beb9d934..39c12f0fb1f2eb552d6a43e353499d497088bd4c 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) diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb.cpp index 9802edf55ac5dc0c0f6e41b35e1cccffc6887e2c..e9aa62c25226c9772509b9a055f87761c428bc5e 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 8bc0c90269ec110691681b6d1b70cf562ceb996b..1ef52d6bda0bbd8b3ffb393bdeedade73a002511 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 fc54546f8160acbf6b8724f19370f345557465a4..b1f9dc77c2e7d39afb7a20fc7c314d379c08422c 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) {