Make thread monitoring opt-in, harden ThreadMonitor, and remove sleep from async backoff handler#39
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c1cdc48c89
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (NovaAPIConfig.isMemoryThreadLogsEnabled()) { | ||
| ThreadMonitor.startMonitoring(); | ||
| } |
There was a problem hiding this comment.
Start monitor when thread-log config is toggled on
Gating ThreadMonitor.startMonitoring() to server startup means enableMemoryThreadLogs can no longer be enabled dynamically: with the default false, the monitor thread never starts, and onConfigReload (same file) does not start it later, so thread/deadlock monitoring remains disabled until a full server restart. Before this change, the monitor was already running and the config flag took effect on the next cycle.
Useful? React with 👍 / 👎.
Motivation
Description
ThreadMonitor.startMonitoring()inNovaAPIwith a guard based onNovaAPIConfig.isMemoryThreadLogsEnabled()so monitoring only starts when enabled.ThreadMonitorto prevent multiple monitor instances, run the monitor thread as a daemon, handle interruptions cleanly, and stop via arunningflag instopMonitoring().ThreadMonitor.logAllThreads()to useThreadMXBeanfor a lightweight thread count and only gather per-thread stack traces when trace logging is enabled, and to respectNovaAPIConfig.isMemoryThreadLogsEnabled().ThreadMonitor.checkForDeadlocks()usingThreadMXBean.findDeadlockedThreads()and improved logging of detected deadlocks.Thread.sleepbackoff from thecallerRunsWithBackoffhandler inAsyncTaskManagerso caller-run fallback executes immediately without sleeping.Testing
./gradlew testand./gradlew buildas the project automated checks, and the build and test suite completed successfully.Codex Task