apache / apache/logging-log4j2
log4j-cassandra: failed appender startup leaks the DataStax Cluster, so the JVM never exits
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.7k
- Avg merge
- 21h 30m
- Merged PRs (30d)
- 27
Description
## Description
`CassandraManager.startupInternal()` fails → the `Cluster` is never closed → the JVM never exits, because the DataStax 3.x driver's threads are non-daemon.
`cluster.close()` is only reachable from `shutdownInternal()`, and `AbstractDatabaseManager.shutdown()` skips that when `running == false` (see #4241).
**Version:** 2.x `04c93c1d33` (no 3.x release) · Cassandra 4.1.11, driver 3.11.x
## Logs
```
main DEBUG Shut down CassandraManager Cassandra, all resources released: true
```
Thread dump 8s later — five non-daemon threads, each carrying the configured `clusterName`:
```
"log4j-bench-nio-worker-0" "log4j-bench-nio-worker-1" "log4j-bench-timeouter-0"
"log4j-bench-connection-reaper-0" "log4j-bench-scheduled-task-worker-0"
```
## Reproduction
Point a `Cassandra` appender at a live node with the keyspace **absent**, log one event, call `LogManager.shutdown()`, return from `main`. The JVM hangs.
## Suggested fix
Close the `Cluster` when `startupInternal()` fails — wrap its body in `try`/`catch` that calls `cluster.close()` and rethrows, or make `shutdownInternal()` null-tolerant and let it run irrespective of `running`, per #4241.
Contributor guide
No contributing guide indexed for this repository
Research direction
Read CassandraManager.startupInternal(), AbstractDatabaseManager.shutdown(), and shutdownInternal() first, then reproduce with a missing keyspace and LogManager.shutdown(). Done means failed startup releases the Cluster and the JVM exits without the five non-daemon driver threads.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cassandra, java
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100