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

[C++] Fix some pending requests may never complete when broker's down #8232

Merged

Conversation

BewareMyPower
Copy link
Contributor

Fixes #8230

Motivation

When ClientConnection calls close, some promises of pending request were not completed. It may cause some methods that wait for promise become completed never return, like Reader::hasMessageAvailable.

Modifications

  • Complete GetLastMessageId and GetNamespaceTopics requests in ClientConnection::close.
  • Refactor ClientConnection::close, use move instead of swap to process some fields outside the lock section.
  • Add error log before connection was closed by read error.

Verifying this change

  • Make sure that the change passes the CI checks.

Try to reproduce #8230 , Reader::hasMessageAvailable would return ResultConnectError if broker was killed by force.

@BewareMyPower
Copy link
Contributor Author

/pulsarbot run-failure-checks

@jiazhai
Copy link
Member

jiazhai commented Oct 10, 2020

Thanks @BewareMyPower for the help

@BewareMyPower
Copy link
Contributor Author

/pulsarbot run-failure-checks

1 similar comment
@BewareMyPower
Copy link
Contributor Author

/pulsarbot run-failure-checks

@jiazhai jiazhai merged commit 5e60775 into apache:master Oct 12, 2020
jiazhai pushed a commit to jiazhai/pulsar that referenced this pull request Oct 12, 2020
…apache#8232)

Fixes apache#8230

### Motivation

When `ClientConnection` calls `close`, some promises of pending request were not completed. It may cause some methods that wait for promise become completed never return, like `Reader::hasMessageAvailable`.

### Modifications

- Complete `GetLastMessageId` and `GetNamespaceTopics` requests in `ClientConnection::close`.
- Refactor `ClientConnection::close`, use move instead of swap to process some fields outside the lock section.
- Add error log before connection was closed by read error.

### Verifying this change

Try to reproduce apache#8230 , `Reader::hasMessageAvailable` would return `ResultConnectError` if broker was killed by force.
(cherry picked from commit 5e60775)
wolfstudy added a commit that referenced this pull request Oct 30, 2020
wolfstudy pushed a commit that referenced this pull request Oct 30, 2020
…#8232)

Fixes #8230

### Motivation

When `ClientConnection` calls `close`, some promises of pending request were not completed. It may cause some methods that wait for promise become completed never return, like `Reader::hasMessageAvailable`.

### Modifications

- Complete `GetLastMessageId` and `GetNamespaceTopics` requests in `ClientConnection::close`.
- Refactor `ClientConnection::close`, use move instead of swap to process some fields outside the lock section.
- Add error log before connection was closed by read error.

### Verifying this change

Try to reproduce #8230 , `Reader::hasMessageAvailable` would return `ResultConnectError` if broker was killed by force.

(cherry picked from commit 5e60775)
huangdx0726 pushed a commit to huangdx0726/pulsar that referenced this pull request Nov 13, 2020
…apache#8232)

Fixes apache#8230

### Motivation

When `ClientConnection` calls `close`, some promises of pending request were not completed. It may cause some methods that wait for promise become completed never return, like `Reader::hasMessageAvailable`.

### Modifications

- Complete `GetLastMessageId` and `GetNamespaceTopics` requests in `ClientConnection::close`.
- Refactor `ClientConnection::close`, use move instead of swap to process some fields outside the lock section.
- Add error log before connection was closed by read error.

### Verifying this change

Try to reproduce apache#8230 , `Reader::hasMessageAvailable` would return `ResultConnectError` if broker was killed by force.
@BewareMyPower BewareMyPower deleted the bewaremypower/has-msg-available-stuck branch January 25, 2021 02:34
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.

[pulsar-client-cpp] Reader::hasMessageAvailable would never return if broker was terminated by force
2 participants