Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High CPU Usage Due to Infinite Loop in Connection Class's run() Method #35

Closed
NassimBtk opened this issue Jun 6, 2024 · 0 comments · Fixed by #36
Closed

High CPU Usage Due to Infinite Loop in Connection Class's run() Method #35

NassimBtk opened this issue Jun 6, 2024 · 0 comments · Fixed by #36
Assignees
Labels
bug Something isn't working

Comments

@NassimBtk
Copy link
Member

NassimBtk commented Jun 6, 2024

Description:

We have encountered an issue in the run() method of the Connection class (executed through a Timer). The method enters an infinite loop, causing high CPU usage and significantly impacting performance. This issue arises due to repeated attempts to send keep-alive messages without proper exit conditions or delays between retries.

The issue has been observed on MetricsHub 0.9.03.

Affected Class:

  • org.sentrysoftware.ipmi.core.connection.Connection

Details:

  1. High CPU Usage: The run() method can enter a tight loop, retrying to send keep-alive messages without sufficient delay, leading to 100% CPU usage.
  2. Infinite Loop: The absence of proper exit conditions results in an infinite retry loop when the connection is not valid or messages fail to send.

Proposed Solution:

  1. Option to Disable Keep-Alive Messages: Introduce a feature allowing users to disable keep-alive messages, giving API users better control. Implement the ability to override the pingPeriod, allowing it to be set to 0 to disable keep-alive messages.
  2. Introduce Delays: Add a delay between retries to avoid tight looping and reduce CPU usage.
  3. Thread Interruption Handling: Include a check for thread interruption to allow graceful shutdown.
  4. Closable Runners (Entry Points): Modify the runner code to ensure that closable instances are properly closed.

Environment:

  • Version: 1.0.01 / MetricsHub 0.9.03
  • OS: Windows
  • Java Version: 17
@NassimBtk NassimBtk self-assigned this Jun 6, 2024
@NassimBtk NassimBtk added the bug Something isn't working label Jun 6, 2024
NassimBtk added a commit that referenced this issue Jun 6, 2024
* Implemented the ability to override the `pingPeriod`, allowing it to
be set to `0` to disable keep-alive messages.

* Added a delay (1 second) between retries to avoid tight looping and
reduce CPU usage.

* Included a check for thread interruption to allow graceful shutdown.

* Modified the runner code to ensure that closable instances are
properly closed.
NassimBtk added a commit that referenced this issue Jun 7, 2024
NassimBtk added a commit that referenced this issue Jun 7, 2024
…usage-due-to-infinite-loop-in-connection-classs-run-method

Issue #35: High CPU Usage Due to Infinite Loop in IPMI Core library `Connection.run()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant