From 10b3f8a90963bd89986e3fc9bc80fa15b1aecc1c Mon Sep 17 00:00:00 2001 From: Mykola Malik Date: Tue, 14 Jul 2026 14:54:39 +0200 Subject: [PATCH] Cover pending requests with logs The extended logs are under the ifdef, so they don't appear in production. This is a temporary commit to extend the logs for certain integration tests, so that we could have more insights from the CI failed psv and sv jobs. This commit will be reverted once OCMAM-771 is resolved. Relates-To: OCMAM-771 Signed-off-by: Mykola Malik --- .../include/olp/core/client/PendingRequests.h | 4 +- .../src/client/PendingRequests.cpp | 71 +++++++++++++++++-- 2 files changed, 68 insertions(+), 7 deletions(-) diff --git a/olp-cpp-sdk-core/include/olp/core/client/PendingRequests.h b/olp-cpp-sdk-core/include/olp/core/client/PendingRequests.h index 7f7db1af3..48498c6d4 100644 --- a/olp-cpp-sdk-core/include/olp/core/client/PendingRequests.h +++ b/olp-cpp-sdk-core/include/olp/core/client/PendingRequests.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 HERE Europe B.V. + * Copyright (C) 2019-2026 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,8 @@ namespace client { */ class CORE_API PendingRequests final { public: + ~PendingRequests(); + /** * @brief Cancels all the pending tasks. * diff --git a/olp-cpp-sdk-core/src/client/PendingRequests.cpp b/olp-cpp-sdk-core/src/client/PendingRequests.cpp index 160411a89..f00dab53c 100644 --- a/olp-cpp-sdk-core/src/client/PendingRequests.cpp +++ b/olp-cpp-sdk-core/src/client/PendingRequests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 HERE Europe B.V. + * Copyright (C) 2019-2026 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,13 @@ namespace { constexpr auto kLogTag = "PendingRequests"; } +PendingRequests::~PendingRequests() { +#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL + OLP_SDK_LOG_INFO_F(kLogTag, "Destructor: pending task count=%zu, this=%p", + GetTaskCount(), static_cast(this)); +#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL +} + bool PendingRequests::CancelAll() { ContextMap contexts; { @@ -36,6 +43,11 @@ bool PendingRequests::CancelAll() { contexts = task_contexts_; } +#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL + OLP_SDK_LOG_INFO_F(kLogTag, "CancelAll: pending task count=%zu, this=%p", + contexts.size(), static_cast(this)); +#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL + for (auto context : contexts) { context.CancelToken().Cancel(); } @@ -52,23 +64,70 @@ bool PendingRequests::CancelAllAndWait() { contexts = std::move(task_contexts_); } +#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL + OLP_SDK_LOG_INFO_F( + kLogTag, "CancelAllAndWait: started, pending task count=%zu, this=%p", + contexts.size(), static_cast(this)); +#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL + for (auto context : contexts) { if (!context.BlockingCancel()) { - OLP_SDK_LOG_WARNING(kLogTag, "Timeout, when waiting on BlockingCancel"); + OLP_SDK_LOG_WARNING_F(kLogTag, + "Timeout, when waiting on BlockingCancel, this=%p", + static_cast(this)); } } +#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL + OLP_SDK_LOG_INFO_F(kLogTag, "CancelAllAndWait: finished, this=%p", + static_cast(this)); +#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL + return true; } void PendingRequests::Insert(TaskContext task_context) { - std::lock_guard lock(task_contexts_lock_); - task_contexts_.insert(task_context); +#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL + size_t size = 0; +#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL + + { + std::lock_guard lock(task_contexts_lock_); + task_contexts_.insert(task_context); + +#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL + size = task_contexts_.size(); +#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL + } + +#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL + OLP_SDK_LOG_INFO_F( + kLogTag, + "Insert: a new task context inserted. Pending task count=%zu, this=%p", + size, static_cast(this)); +#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL } void PendingRequests::Remove(TaskContext task_context) { - std::lock_guard lock(task_contexts_lock_); - task_contexts_.erase(task_context); +#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL + size_t size = 0; +#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL + + { + std::lock_guard lock(task_contexts_lock_); + task_contexts_.erase(task_context); + +#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL + size = task_contexts_.size(); +#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL + } + +#ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL + OLP_SDK_LOG_INFO_F( + kLogTag, + "Remove: a task context removed. Pending task count=%zu, this=%p", size, + static_cast(this)); +#endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL } size_t PendingRequests::GetTaskCount() const {