From f521ea1a83f9f6491639632e112916e30d317b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=9C=A3?= Date: Tue, 20 May 2025 14:29:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=83=E7=B4=A0=E6=95=B0=E6=8D=AE=E8=A1=A8?= =?UTF-8?q?=E8=AF=BB=E5=86=99=E5=8F=AF=E5=B9=B6=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 谭凯圣 --- ...qlite_single_ver_natural_store_connection.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp b/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp index 146fc42ee6d..cff5606c038 100755 --- a/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp +++ b/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp @@ -101,13 +101,15 @@ int SQLiteSingleVerNaturalStoreConnection::Get(const IOption &option, const Key DBDfxAdapter::StartTracing(); { // need to check if the transaction started - std::lock_guard lock(transactionMutex_); - if (writeHandle_ != nullptr) { - LOGD("Transaction started already."); - Timestamp recordTimestamp; - errCode = writeHandle_->GetKvData(dataType, key, value, recordTimestamp); - DBDfxAdapter::FinishTracing(); - return errCode; + auto res = transactionMutex_.try_lock(); + if (res) { + if (writeHandle_ != nullptr) { + LOGD("Transaction started already."); + Timestamp recordTimestamp; + errCode = writeHandle_->GetKvData(dataType, key, value, recordTimestamp); + DBDfxAdapter::FinishTracing(); + return errCode; + } } } -- Gitee