Skip to content

[fix] Close consumer resources if creation fails - #1070

Merged
RobertIndie merged 1 commit into
apache:masterfrom
michaeljmarshall:close-consumer
Jul 26, 2023
Merged

RobertIndie merged 1 commit into
apache:masterfrom
michaeljmarshall:close-consumer

Conversation

@michaeljmarshall

Copy link
Copy Markdown
Member

Motivation

When a consumer fails to get created, we should close any resources that it created to prevent leaks of internal resources and leaks of the consumer on the broker side. The broker leak could happen if the connection was left open. These fixes are similar to #1061.

Modifications

  • Close ackGroupingTracker and chunkedMsgCtxMap if grabConn fails. We cannot call Close on the consumer because the state is not Ready. If we re-design the consumer, it could be nice to be able to call Close in this scenario.
  • Call Close on the consumer in cases where we move it to Ready but determine it is not able to be created.
  • Fix typo in comment

Verifying this change

This is a trivial change.

@RobertIndie RobertIndie added this to the v0.12.0 milestone Jul 26, 2023
@RobertIndie
RobertIndie merged commit a3fcc9a into apache:master Jul 26, 2023
RobertIndie pushed a commit that referenced this pull request Sep 7, 2023
### Motivation

When a consumer fails to get created, we should close any resources that it created to prevent leaks of internal resources and leaks of the consumer on the broker side. The broker leak could happen if the connection was left open. These fixes are similar to #1061.

### Modifications

* Close `ackGroupingTracker` and `chunkedMsgCtxMap` if `grabConn` fails. We cannot call `Close` on the consumer because the state is not `Ready`. If we re-design the consumer, it could be nice to be able to call `Close` in this scenario.
* Call `Close` on the consumer in cases where we move it to `Ready` but determine it is not able to be created.
* Fix typo in comment

(cherry picked from commit a3fcc9a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants