Skip to content

Connection Leak During PhaseInstance.Status.TERMINATING #643

@diegolovison

Description

@diegolovison

Describe the bug
There are issues with connection management when a phase enters PhaseInstance.Status.TERMINATING state. The problems begin from the split responsibility between connection acquisition and release, combined with the stop mechanism during termination.

  • PrepareHttpRequestStep - Acquires connection via connectionPool.acquire(false, context)
  • SendHttpRequestStep - Sends request via request.send(context.connection, ...)

The connection is released later when the response completes via releasePoolAndPulse()

Problem 1: Connection Acquired But Request Not Sent

This can trigger TERMINATING check before SendHttpRequestStep runs. Connection is stored in context but never used or released.

PrepareHttpRequestStep executes
    ↓
connectionPool.acquire() called [line 89]
    ↓
Connection acquired and stored in context
    ↓
context.accept(connection) calls session.proceed() [line 40]
    ↓
Session checks TERMINATING status [line 265]
    ↓
Session calls stop() [line 269]
    ↓
SendHttpRequestStep NEVER executes
    ↓
Connection NEVER released - LEAK!

Problem 2: Request sent but response handling interrupted

SendHttpRequestStep executes
    ↓
Request sent to server
    ↓
Response starts arriving
    ↓
Phase enters TERMINATING
    ↓
Session.proceed() checks TERMINATING [line 265]
    ↓
Session stops [line 269]
    ↓
Response handler may or may not complete
    ↓
releasePoolAndPulse() may or may not be called
    ↓
Connection may be leaked OR released

To Reproduce
#641

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions