Joe McDonnell has uploaded this change for review. ( https://gerrit.cloudera.org/25401
Change subject: IMPALA-15734: Shut down the JVM before exit for backend tests ...................................................................... IMPALA-15734: Shut down the JVM before exit for backend tests Backend tests that start an in-process JVM do not shut it down before exiting. With Google TCMalloc, this creates a race between process exit and running JVM threads calling malloc. This doesn't fail the backend tests, but it produces a minidump that fails the Jenkins job. To avoid that race, this adds logic to shutdown the JVM before exiting. This changes InitCommonRuntime() to return a CommonRuntimeCtx. If InitCommonRuntime() was called with init_jvm=true, then the CommonRuntimeCtx will shutdown the JVM when it is destructed (which happens before exiting). DestroyJavaVM() blocks until every thread attached to the JVM has exited. This fixes some test infrastructure to properly shut down threads: - TAcceptQueueServer::stop() now interrupts accepted connections (interruptChildren()), so connection threads blocked waiting for a request exit instead of waiting for the client to disconnect. The resulting INTERRUPTED exception is not logged as a client error. - Add StatestoreSubscriber::ShutdownForTesting() and InProcessImpalaServer::ShutdownForTesting(), and make Statestore::ShutdownForTesting() also stop its Thrift server. The in-process server shutdown also calls RpcMgr::Shutdown(), which stops the KRPC service threads that are attached to the JVM. - Call these from expr-test, otel-trace-manager-test and session-expiry-test. This also fixes two data races found by TSAN in the Thrift stop path: - TAcceptQueueServer::stop_ is now std::atomic<bool> - ThriftServer::StopForTesting() joins the server thread unconditionally to avoid a dirty read of 'started_' Since some daemons are always killed and don't properly clean up their threads, CommonRuntimeCtx has a Release() option that prevents the cleanup of the JVM. The IMPALA_BETEST_SKIP_JVM_SHUTDOWN environment variable can be set to 1 to skip JVM shutdown. This can be useful to identify hangs from leftover JVM threads. This migrates all the backend tests and benchmarks to keep the CommonRuntimeCtx as a local variable in main(). This changes all the other use cases to call Release() on CommonRuntimeCtx to keep their old behavior. Testing: - Ran backend tests with a debug build and a TSAN build - Ran backend tests with Google TCMalloc in a loop and verified that the shutdown issue didn't reproduce - Ran benchmarks and verified that they don't hang Change-Id: I1d8eca945e5fa2e519c022c601c64c96978a4525 Assisted-by: Claude Sonnet 5.5 (Claude Code) --- M be/src/benchmarks/arrow-converter-benchmark.cc M be/src/benchmarks/bloom-filter-benchmark.cc M be/src/benchmarks/convert-timestamp-benchmark.cc M be/src/benchmarks/expr-benchmark.cc M be/src/benchmarks/hash-benchmark.cc M be/src/benchmarks/hash-table-benchmark.cc M be/src/benchmarks/network-perf-benchmark.cc M be/src/benchmarks/process-wide-locks-benchmark.cc M be/src/benchmarks/row-batch-serialize-benchmark.cc M be/src/benchmarks/scheduler-benchmark.cc M be/src/catalog/catalogd-main.cc M be/src/codegen/llvm-codegen-cache-test.cc M be/src/codegen/llvm-codegen-test.cc M be/src/common/init.cc M be/src/common/init.h M be/src/exec/row-batch-list-test.cc M be/src/exec/scratch-tuple-batch-test.cc M be/src/experiments/hash-ring-util.cc M be/src/exprs/expr-codegen-test.cc M be/src/exprs/expr-test.cc M be/src/observe/otel-trace-manager-test.cc M be/src/rpc/TAcceptQueueServer.cpp M be/src/rpc/TAcceptQueueServer.h M be/src/rpc/authentication-test.cc M be/src/rpc/hs2-http-test.cc M be/src/rpc/rpc-mgr-kerberized-test.cc M be/src/rpc/rpc-mgr-test.cc M be/src/rpc/thrift-server-test.cc M be/src/rpc/thrift-server.cc M be/src/runtime/buffered-tuple-stream-test.cc M be/src/runtime/bufferpool/buffer-allocator-test.cc M be/src/runtime/bufferpool/buffer-pool-test.cc M be/src/runtime/bufferpool/reservation-tracker-test.cc M be/src/runtime/client-cache-test.cc M be/src/runtime/collection-value-builder-test.cc M be/src/runtime/data-stream-test.cc M be/src/runtime/io/data-cache-test.cc M be/src/runtime/io/data-cache-trace-replayer.cc M be/src/runtime/io/disk-io-mgr-stress-test.cc M be/src/runtime/row-batch-test.cc M be/src/runtime/runtime-state-test.cc M be/src/scheduling/admissiond-main.cc M be/src/service/fe-support.cc M be/src/service/impalad-main.cc M be/src/service/internal-server-test.cc M be/src/service/session-expiry-test.cc M be/src/service/unified-betest-main.cc M be/src/statestore/statestore-subscriber.cc M be/src/statestore/statestore-subscriber.h M be/src/statestore/statestore-test.cc M be/src/statestore/statestore.cc M be/src/statestore/statestore.h M be/src/statestore/statestored-main.cc M be/src/testutil/gtest-util.h M be/src/testutil/in-process-servers.cc M be/src/testutil/in-process-servers.h M be/src/util/decompress-test.cc M be/src/util/internal-queue-test.cc M be/src/util/jni-util.cc M be/src/util/jni-util.h M be/src/util/minidump-test.cc M be/src/util/webserver-test.cc 62 files changed, 212 insertions(+), 55 deletions(-) git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/01/25401/1 -- To view, visit https://gerrit.cloudera.org/25401 To unsubscribe, visit https://gerrit.cloudera.org/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: I1d8eca945e5fa2e519c022c601c64c96978a4525 Gerrit-Change-Number: 25401 Gerrit-PatchSet: 1 Gerrit-Owner: Joe McDonnell <[email protected]>
