Skip to content

fix(pool): prevent infinite loop during idleTimeout cleanup in transaction#4347

Closed
thanathip41 wants to merge 2 commits into
sidorares:masterfrom
thanathip41:fix/idle-timeout-infinite-loop
Closed

fix(pool): prevent infinite loop during idleTimeout cleanup in transaction#4347
thanathip41 wants to merge 2 commits into
sidorares:masterfrom
thanathip41:fix/idle-timeout-infinite-loop

Conversation

@thanathip41

@thanathip41 thanathip41 commented Jun 18, 2026

Copy link
Copy Markdown

Problem:

  • When a transaction remains open longer than the configured idleTimeout, the pool may destroy the underlying connection.
  • This results in an Error: idle timeout being thrown while the transaction is still active.
  • In some cases, the error repeatedly propagates through the cleanup logic, causing an infinite loop that continuously emits errors and consumes resources.
  • The process may become unresponsive or eventually crash.

Root Cause:

  • The idle timeout cleanup path can repeatedly trigger error handling for the same connection state.
  • Instead of terminating cleanly, the process may enter a continuous error loop.

Fix:

  • Detect the idle timeout failure condition and terminate the process immediately.
  • Avoid repeatedly executing the cleanup/error handling path for the same connection.
  • Fail fast rather than allowing the process to enter an infinite error loop.

Test:

  • Added a test covering a long-running transaction that exceeds the configured idleTimeout.
  • Verified that the process exits cleanly instead of repeatedly throwing Error: idle timeout.
  • Verified that normal idle connection cleanup behavior remains unchanged.

@thanathip41
thanathip41 deleted the fix/idle-timeout-infinite-loop branch June 19, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant