Skip to content

Conversation

@BewareMyPower
Copy link
Contributor

@BewareMyPower BewareMyPower commented Jun 29, 2022

Fixes #15976

Motivation

Currently even if the producer, consumer, or reader failed to
create, it would still be added to the producers or consumers in
Client. Client::close first closes the internal producers and
consumers, if the producers or consumers to close include failed
producers or consumers, Client::close would return
ResultAlreadyClosed. Even worse, closing a failed partitioned producer
might stuck.

It also makes the Python test test_listener_name_client flaky because
client.close() will throw an exception if the underlying
Client::close call in C++ client doesn't return ResultOk.

Modifications

  • Only adding the created producer or consumer to the internal list of
    Client after the creation succeeded.
  • Add ClientTest.testWrongListener to verify when producer, consumer,
    reader failed to create, the internal producer list and consumer list
    are both empty. And client.close() would return ResultOk.

Documentation

Check the box below or label this PR directly.

Need to update docs?

  • doc-required
    (Your PR needs to update docs and you will update later)

  • doc-not-needed
    (Please explain why)

  • doc
    (Your PR contains doc changes)

  • doc-complete
    (Docs have been already added)

…ng result

Fixes apache#15976

### Motivation

Currently even if the producer, consumer, or reader failed to
create, it would still be added to the producers or consumers in
`Client`. `Client::close` first closes the internal producers and
consumers, if the producers or consumers to close include failed
producers or consumers, `Client::close` would return
`ResultAlreadyClosed`. Even worse, closing a failed partitioned producer
might stuck.

It also makes the Python test `test_listener_name_client` flaky because
`client.close()` will throw an exception if the underlying
`Client::close` call in C++ client doesn't return `ResultOk`.

### Modifications

- Only adding the created producer or consumer to the internal list of
  `Client` after the creation succeeded.
- Add `ClientTest.testWrongListener` to verify when producer, consumer,
  reader failed to create, the internal producer list and consumer list
  are both empty. And `client.close()` would return `ResultOk`.
@github-actions
Copy link

@BewareMyPower Please provide a correct documentation label for your PR.
Instructions see Pulsar Documentation Label Guide.

@BewareMyPower
Copy link
Contributor Author

In addition, test_listener_name_client uses a partitioned topic created by other tests. This bug can only be easily reproduced against a partitioned topic. See #15976 (comment).

@github-actions
Copy link

@BewareMyPower Please provide a correct documentation label for your PR.
Instructions see Pulsar Documentation Label Guide.

@BewareMyPower BewareMyPower added doc-not-needed Your PR changes do not impact docs and removed doc-label-missing labels Jun 29, 2022
@BewareMyPower BewareMyPower added this to the 2.11.0 milestone Jun 30, 2022
@BewareMyPower
Copy link
Contributor Author

@BewareMyPower BewareMyPower merged commit e23d312 into apache:master Jul 6, 2022
@BewareMyPower BewareMyPower deleted the bewaremypower/cpp-flaky-client-close branch July 6, 2022 15:21
codelipenghui pushed a commit that referenced this pull request Jul 10, 2022
…ng result (#16285)

Fixes #15976

### Motivation

Currently even if the producer, consumer, or reader failed to
create, it would still be added to the producers or consumers in
`Client`. `Client::close` first closes the internal producers and
consumers, if the producers or consumers to close include failed
producers or consumers, `Client::close` would return
`ResultAlreadyClosed`. Even worse, closing a failed partitioned producer
might stuck.

It also makes the Python test `test_listener_name_client` flaky because
`client.close()` will throw an exception if the underlying
`Client::close` call in C++ client doesn't return `ResultOk`.

### Modifications

- Only adding the created producer or consumer to the internal list of
  `Client` after the creation succeeded.
- Add `ClientTest.testWrongListener` to verify when producer, consumer,
  reader failed to create, the internal producer list and consumer list
  are both empty. And `client.close()` would return `ResultOk`.

(cherry picked from commit e23d312)
zymap pushed a commit to zymap/pulsar that referenced this pull request Jul 11, 2022
…ng result (apache#16285)

Fixes apache#15976

### Motivation

Currently even if the producer, consumer, or reader failed to
create, it would still be added to the producers or consumers in
`Client`. `Client::close` first closes the internal producers and
consumers, if the producers or consumers to close include failed
producers or consumers, `Client::close` would return
`ResultAlreadyClosed`. Even worse, closing a failed partitioned producer
might stuck.

It also makes the Python test `test_listener_name_client` flaky because
`client.close()` will throw an exception if the underlying
`Client::close` call in C++ client doesn't return `ResultOk`.

### Modifications

- Only adding the created producer or consumer to the internal list of
  `Client` after the creation succeeded.
- Add `ClientTest.testWrongListener` to verify when producer, consumer,
  reader failed to create, the internal producer list and consumer list
  are both empty. And `client.close()` would return `ResultOk`.
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Jul 11, 2022
…ng result (apache#16285)

Fixes apache#15976

### Motivation

Currently even if the producer, consumer, or reader failed to
create, it would still be added to the producers or consumers in
`Client`. `Client::close` first closes the internal producers and
consumers, if the producers or consumers to close include failed
producers or consumers, `Client::close` would return
`ResultAlreadyClosed`. Even worse, closing a failed partitioned producer
might stuck.

It also makes the Python test `test_listener_name_client` flaky because
`client.close()` will throw an exception if the underlying
`Client::close` call in C++ client doesn't return `ResultOk`.

### Modifications

- Only adding the created producer or consumer to the internal list of
  `Client` after the creation succeeded.
- Add `ClientTest.testWrongListener` to verify when producer, consumer,
  reader failed to create, the internal producer list and consumer list
  are both empty. And `client.close()` would return `ResultOk`.

(cherry picked from commit e23d312)
(cherry picked from commit 88b1636)
wuxuanqicn pushed a commit to wuxuanqicn/pulsar that referenced this pull request Jul 14, 2022
…ng result (apache#16285)

Fixes apache#15976

### Motivation

Currently even if the producer, consumer, or reader failed to
create, it would still be added to the producers or consumers in
`Client`. `Client::close` first closes the internal producers and
consumers, if the producers or consumers to close include failed
producers or consumers, `Client::close` would return
`ResultAlreadyClosed`. Even worse, closing a failed partitioned producer
might stuck.

It also makes the Python test `test_listener_name_client` flaky because
`client.close()` will throw an exception if the underlying
`Client::close` call in C++ client doesn't return `ResultOk`.

### Modifications

- Only adding the created producer or consumer to the internal list of
  `Client` after the creation succeeded.
- Add `ClientTest.testWrongListener` to verify when producer, consumer,
  reader failed to create, the internal producer list and consumer list
  are both empty. And `client.close()` would return `ResultOk`.
mattisonchao pushed a commit that referenced this pull request Jul 15, 2022
…ng result (#16285)

Fixes #15976

### Motivation

Currently even if the producer, consumer, or reader failed to
create, it would still be added to the producers or consumers in
`Client`. `Client::close` first closes the internal producers and
consumers, if the producers or consumers to close include failed
producers or consumers, `Client::close` would return
`ResultAlreadyClosed`. Even worse, closing a failed partitioned producer
might stuck.

It also makes the Python test `test_listener_name_client` flaky because
`client.close()` will throw an exception if the underlying
`Client::close` call in C++ client doesn't return `ResultOk`.

### Modifications

- Only adding the created producer or consumer to the internal list of
  `Client` after the creation succeeded.
- Add `ClientTest.testWrongListener` to verify when producer, consumer,
  reader failed to create, the internal producer list and consumer list
  are both empty. And `client.close()` would return `ResultOk`.

(cherry picked from commit e23d312)
@mattisonchao mattisonchao added the cherry-picked/branch-2.9 Archived: 2.9 is end of life label Jul 15, 2022
BewareMyPower added a commit that referenced this pull request Jul 29, 2022
…ng result (#16285)

Fixes #15976

### Motivation

Currently even if the producer, consumer, or reader failed to
create, it would still be added to the producers or consumers in
`Client`. `Client::close` first closes the internal producers and
consumers, if the producers or consumers to close include failed
producers or consumers, `Client::close` would return
`ResultAlreadyClosed`. Even worse, closing a failed partitioned producer
might stuck.

It also makes the Python test `test_listener_name_client` flaky because
`client.close()` will throw an exception if the underlying
`Client::close` call in C++ client doesn't return `ResultOk`.

### Modifications

- Only adding the created producer or consumer to the internal list of
  `Client` after the creation succeeded.
- Add `ClientTest.testWrongListener` to verify when producer, consumer,
  reader failed to create, the internal producer list and consumer list
  are both empty. And `client.close()` would return `ResultOk`.

(cherry picked from commit e23d312)
@BewareMyPower BewareMyPower added the cherry-picked/branch-2.8 Archived: 2.8 is end of life label Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/branch-2.8 Archived: 2.8 is end of life cherry-picked/branch-2.9 Archived: 2.9 is end of life cherry-picked/branch-2.10 doc-not-needed Your PR changes do not impact docs release/2.8.4 release/2.9.4 release/2.10.2 type/bug The PR fixed a bug or issue reported a bug type/flaky-tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Python] Flaky-test: test_listener_name_client

5 participants