This is an automated email from the ASF dual-hosted git repository. boroknagyz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/impala.git
commit adbab4d5ae0e7857c8593258e5eab07445bfdd6a Author: Yubi Lee <[email protected]> AuthorDate: Fri Aug 22 18:46:12 2025 +0900 IMPALA-13413: fix ignored num_cores flag Previously, CpuInfo::Init() was called before ParseCommandLineFlags(), so FLAGS_num_cores was always 0, making the --num_cores flag ignored. Change-Id: I72454d74ccf8c5110c59f923cef4caf434e2fba7 Reviewed-on: http://gerrit.cloudera.org:8080/23333 Reviewed-by: Impala Public Jenkins <[email protected]> Tested-by: Impala Public Jenkins <[email protected]> --- be/src/common/init.cc | 13 +++++++------ be/src/util/CMakeLists.txt | 13 +++++++++++++ be/src/util/sys-info-test.cc | 9 +++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/be/src/common/init.cc b/be/src/common/init.cc index f4ea31b1d..1c78c15c7 100644 --- a/be/src/common/init.cc +++ b/be/src/common/init.cc @@ -490,12 +490,6 @@ void impala::InitCommonRuntime(int argc, char** argv, bool init_jvm, srand(time(NULL)); BlockImpalaShutdownSignal(); - CpuInfo::Init(); - DiskInfo::Init(); - MemInfo::Init(); - OsInfo::Init(); - TestInfo::Init(test_mode); - // Set the default hostname. The user can override this with the hostname flag. ABORT_IF_ERROR(GetHostname(&FLAGS_hostname)); @@ -517,6 +511,13 @@ void impala::InitCommonRuntime(int argc, char** argv, bool init_jvm, google::SetVersionString(impala::GetBuildVersion()); google::ParseCommandLineFlags(&argc, &argv, true); + + CpuInfo::Init(); + DiskInfo::Init(); + MemInfo::Init(); + OsInfo::Init(); + TestInfo::Init(test_mode); + if (!FLAGS_redaction_rules_file.empty()) { if (VLOG_ROW_IS_ON || !FLAGS_vmodule.empty()) { CLEAN_EXIT_WITH_ERROR("Redaction cannot be used in combination with log level 3 or " diff --git a/be/src/util/CMakeLists.txt b/be/src/util/CMakeLists.txt index 41ff9699b..e54a3c446 100644 --- a/be/src/util/CMakeLists.txt +++ b/be/src/util/CMakeLists.txt @@ -300,6 +300,19 @@ ADD_UNIFIED_BE_LSAN_TEST(summary-util-test "PrintTableTest.*") ADD_UNIFIED_BE_LSAN_TEST(symbols-util-test "SymbolsUtil.*") ADD_UNIFIED_BE_LSAN_TEST(system-state-info-test "SystemStateInfoTest.*") ADD_UNIFIED_BE_LSAN_TEST(sys-info-test "CpuInfoTest.*:DiskInfoTest.*") +# IMPALA-13413: Test that --num_cores flag is respected by CpuInfo::Init(). +# This requires a custom ADD_TEST because we need to pass --num_cores flag. +# Use system cores + 1 to ensure the test value differs from actual cores. +include(ProcessorCount) +ProcessorCount(SYSTEM_CORES) +math(EXPR NUM_CORES_FOR_TEST "${SYSTEM_CORES} + 1") +ADD_TEST(NAME num-cores-flag-test + COMMAND "${CMAKE_SOURCE_DIR}/bin/run-jvm-binary.sh" + "${BUILD_OUTPUT_ROOT_DIRECTORY}/service/unifiedbetests" + "--num_cores=${NUM_CORES_FOR_TEST}" + "--gtest_filter=CpuInfoTest.NumCoresFlag" + -log_dir=$ENV{IMPALA_BE_TEST_LOGS_DIR}) +set_tests_properties(num-cores-flag-test PROPERTIES DEPENDS unified-be-test-validated-executable) ADD_UNIFIED_BE_LSAN_TEST(thread-pool-test "ThreadPoolTest.*") ADD_UNIFIED_BE_LSAN_TEST(time-test "TimeTest.*") ADD_UNIFIED_BE_LSAN_TEST(tuple-row-compare-test "TupleRowCompareTest.*") diff --git a/be/src/util/sys-info-test.cc b/be/src/util/sys-info-test.cc index 132c33093..40492b585 100644 --- a/be/src/util/sys-info-test.cc +++ b/be/src/util/sys-info-test.cc @@ -26,6 +26,8 @@ #include "common/names.h" +DECLARE_int32(num_cores); + namespace impala { TEST(CpuInfoTest, Basic) { @@ -56,6 +58,13 @@ TEST(CpuInfoTest, InvalidSchedGetCpuValue) { } +// IMPALA-13413: Test that --num_cores flag is respected by CpuInfo::Init(). +TEST(CpuInfoTest, NumCoresFlag) { + if (FLAGS_num_cores > 0) { + EXPECT_EQ(FLAGS_num_cores, CpuInfo::num_cores()); + } +} + class DiskInfoTest : public ::testing::Test { protected: void TestTryNVMETrimPositive(const string& name, const string& expected_basename) {
