Skip to content

Commit e5736f5

Browse files
morningmanclaude
andcommitted
[fix](be) Deregister the result buffer metric hook when the Arrow Flight cancel test fixture ends
### What problem does this PR solve? Issue Number: None Related PR: #69945 Problem Summary: `ResultBufferMgr`'s constructor registers the process-wide `result_buffer_block_count` hook, and the hook captures the manager. Only `ResultBufferMgr::stop()` deregisters it. `ArrowFlightCancelTest` builds a manager per test and never stopped it, so after each test the global metric entity kept a hook that pointed at a destroyed manager. A later metric collection with hooks enabled would read freed memory. Because `MetricEntity::register_hook` uses `emplace`, a later fixture could not replace a stale hook either. `TearDown()` now calls `_mgr.stop()` after restoring the previous manager, the same way `LoadChannelMgrTest` stops its `LoadChannelMgr`. The manager is never `init()`ed here, so `stop()` only removes the hook and its gauge; no cleaner thread is joined. ### Release note None ### Check List (For Author) - Test: Unit Test - `ArrowFlightCancelTest.*`, `ArrowFlightRemoteCancelTest.*`, `ResultBufferMgrTest.*` - Behavior changed: No - Does this need documentation: No Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b0e2959 commit e5736f5

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎be/test/service/arrow_flight/arrow_flight_cancel_test.cpp‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ class ArrowFlightCancelTest : public testing::Test {
5656
address.port = config::brpc_port;
5757
_statement = std::make_shared<QueryStatement>(_id, address, "select value");
5858
}
59-
void TearDown() override { ExecEnv::GetInstance()->_result_mgr = _previous_mgr; }
59+
void TearDown() override {
60+
ExecEnv::GetInstance()->_result_mgr = _previous_mgr;
61+
// The constructor registers a process-wide result_buffer_block_count hook that captures
62+
// `this`; deregister it before the fixture destroys the manager.
63+
_mgr.stop();
64+
}
6065
void fill_buffer() {
6166
auto block = std::make_shared<Block>(ColumnHelper::create_block<DataTypeInt64>({1, 2}));
6267
ASSERT_TRUE(_buffer->add_batch(&_state, block).ok());

0 commit comments

Comments
 (0)