From 959a37dce22a2964a78f1feceafc8b6548033e2a Mon Sep 17 00:00:00 2001 From: Andrei Date: Fri, 3 Jul 2026 22:29:40 +0200 Subject: [PATCH] fix(native): send cancelled by a graceful stop is Debug, not Error (+ bump collector 0.6.2 / agent 0.5.28) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit HttpSendBatch logged every failed send at Error, including the in-flight POST that StopWorker cancels during a graceful stop ('HTTP 0 Operation was aborted by an application callback') — noise on every restart, the same class as the stop-drop (already Debug). Now: if send_cancelled_ is set (stop path), log at Debug; a genuine failure while running still logs Error. Read under hang_mutex_ (not held by the caller there). Per src/native/collector/AGENTS.md this is a behavior change with no ABI change -> collector PATCH 0.6.1 -> 0.6.2; per src/agent/AGENTS.md the collector ships in the agent -> agent 0.5.27 -> 0.5.28. Co-Authored-By: Claude Opus 4.8 --- src/agent/CMakeLists.txt | 2 +- src/native/collector/CMakeLists.txt | 2 +- .../include/hsm_collector/hsm_collector.h | 2 +- src/native/collector/src/hsm_collector.cpp | 20 ++++++++++++++++--- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/agent/CMakeLists.txt b/src/agent/CMakeLists.txt index f264a8bfa..6a1cc755b 100644 --- a/src/agent/CMakeLists.txt +++ b/src/agent/CMakeLists.txt @@ -18,7 +18,7 @@ if(CMAKE_HOST_WIN32 AND NOT DEFINED VCPKG_TARGET_TRIPLET) set(VCPKG_TARGET_TRIPLET "x64-windows-static" CACHE STRING "vcpkg triplet for the self-contained agent build") endif() -project(HsmAgent VERSION 0.5.27 LANGUAGES CXX) +project(HsmAgent VERSION 0.5.28 LANGUAGES CXX) if(MSVC) # Static CRT (/MT) to match the static triplet — the exe must run on a clean machine with no VC++ diff --git a/src/native/collector/CMakeLists.txt b/src/native/collector/CMakeLists.txt index d9362a9fb..2894e1a95 100644 --- a/src/native/collector/CMakeLists.txt +++ b/src/native/collector/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.21) # VERSION tracks the C ABI semver (HSM_COLLECTOR_VERSION_* in include/hsm_collector/hsm_collector.h); # keep the two in sync. It feeds the find_package(hsm_collector x.y) version check (#1100). -project(HsmCollectorNative VERSION 0.6.1 LANGUAGES CXX) +project(HsmCollectorNative VERSION 0.6.2 LANGUAGES CXX) # --------------------------------------------------------------------------- # Target topology (epic #1093 / issue #1095 §1 — "core lib / C ABI lib / C++ diff --git a/src/native/collector/include/hsm_collector/hsm_collector.h b/src/native/collector/include/hsm_collector/hsm_collector.h index 18ff4bf91..fb009adff 100644 --- a/src/native/collector/include/hsm_collector/hsm_collector.h +++ b/src/native/collector/include/hsm_collector/hsm_collector.h @@ -18,7 +18,7 @@ extern "C" reported as the ".module/Collector version" sensor. */ #define HSM_COLLECTOR_VERSION_MAJOR 0 #define HSM_COLLECTOR_VERSION_MINOR 6 -#define HSM_COLLECTOR_VERSION_PATCH 1 +#define HSM_COLLECTOR_VERSION_PATCH 2 #define HSM_COLLECTOR_VERSION \ ((HSM_COLLECTOR_VERSION_MAJOR * 10000) + (HSM_COLLECTOR_VERSION_MINOR * 100) + HSM_COLLECTOR_VERSION_PATCH) diff --git a/src/native/collector/src/hsm_collector.cpp b/src/native/collector/src/hsm_collector.cpp index 7baeac383..584e70933 100644 --- a/src/native/collector/src/hsm_collector.cpp +++ b/src/native/collector/src/hsm_collector.cpp @@ -4661,9 +4661,23 @@ namespace // to one line per window (the batch is re-enqueued by the dispatcher — the retry itself is // not logged, matching the queue's silent re-enqueue). if (!response.IsSuccess()) - LogError( - "Failed to send " + std::to_string(batch.size()) + " value(s): HTTP " + - std::to_string(response.status_code) + (response.error.empty() ? "" : " " + response.error)); + { + const std::string msg = "Failed to send " + std::to_string(batch.size()) + " value(s): HTTP " + + std::to_string(response.status_code) + + (response.error.empty() ? "" : " " + response.error); + // A send whose in-flight POST was cancelled by a graceful stop is expected, not an + // error — log it at Debug (same treatment as the stop-drop). A genuine failure while + // running still logs at Error (deduplicated). + bool cancelled_by_stop; + { + std::lock_guard guard(hang_mutex_); + cancelled_by_stop = send_cancelled_; + } + if (cancelled_by_stop) + LogMessage(HSM_LOG_LEVEL_DEBUG, msg); + else + LogError(msg); + } return response.IsSuccess(); }