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

Producer getting producer busy is removing existing producer from list #11804

Merged
merged 2 commits into from Aug 27, 2021

Conversation

merlimat
Copy link
Contributor

Motivation

When a producer is getting error because of ProducerBusy (existing producer with the same name), it will trigger a producer close operation that will eventually lead to the existing producer getting removed from the topic map (even though that producer is still writing on the topic).

The problem is the producer close is triggering a removal from the map:

if (producers.remove(producer.getProducerName(), producer)) {

Even though we check for producer equality, the Producer.equals() is only comparing the producer name, so the old instance gets removed from the map.

Instead, the equality of producer needs to be based on the connection id (local & remote addresses and unique id), plus the producer id within that connection.

@merlimat merlimat added this to the 2.9.0 milestone Aug 26, 2021
@merlimat merlimat self-assigned this Aug 26, 2021
@merlimat merlimat added type/bug The PR fixed a bug or issue reported a bug doc-not-needed Your PR changes do not impact docs labels Aug 26, 2021
Copy link
Contributor

@addisonj addisonj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@hangc0276 hangc0276 merged commit 6aef83f into apache:master Aug 27, 2021
hangc0276 pushed a commit that referenced this pull request Aug 27, 2021
#11804)

### Motivation
When a producer is getting error because of ProducerBusy (existing producer with the same name), it will trigger a producer close operation that will eventually lead to the existing producer getting removed from the topic map (even though that producer is still writing on the topic).

The problem is the producer close is triggering a removal from the map:
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java

Line 683 in 43ded59

 if (producers.remove(producer.getProducerName(), producer)) {
Even though we check for producer equality, the Producer.equals() is only comparing the producer name, so the old instance gets removed from the map.

Instead, the equality of producer needs to be based on the connection id (local & remote addresses and unique id), plus the producer id within that connection.

* Producer getting producer busy is removing existing producer from list

* Fixed test

(cherry picked from commit 6aef83f)
@hangc0276 hangc0276 added the cherry-picked/branch-2.8 Archived: 2.8 is end of life label Aug 27, 2021
@merlimat merlimat deleted the fix-producer-busy branch August 27, 2021 14:58
BewareMyPower added a commit to streamnative/kop that referenced this pull request Aug 30, 2021
### Motivation
apache/pulsar#11804 added the custom implementations of `equals` and `hashCode` methods of `ServiceCnx`, which made KoP's spotbugs check fail with 

> Medium: io.streamnative.pulsar.handlers.kop.InternalServerCnx doesn't override org.apache.pulsar.broker.service.ServerCnx.equals(Object) [io.streamnative.pulsar.handlers.kop.InternalServerCnx] At InternalServerCnx.java:[line 1] EQ_DOESNT_OVERRIDE_EQUALS

### Modifications
This PR adds the overrided `equals` and `hashCode` methods by calling base class' same name methods simply. On the other hand, since the new `equals` and `hashCode` methods are based on `ctx` field and they are called when removing `Producer` from `Topic`, this PR also updates the `ctx` field of `InternalServerCnx`.
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Nov 17, 2021
apache#11804)

When a producer is getting error because of ProducerBusy (existing producer with the same name), it will trigger a producer close operation that will eventually lead to the existing producer getting removed from the topic map (even though that producer is still writing on the topic).

The problem is the producer close is triggering a removal from the map:
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java

Line 683 in 43ded59

 if (producers.remove(producer.getProducerName(), producer)) {
Even though we check for producer equality, the Producer.equals() is only comparing the producer name, so the old instance gets removed from the map.

Instead, the equality of producer needs to be based on the connection id (local & remote addresses and unique id), plus the producer id within that connection.

* Producer getting producer busy is removing existing producer from list

* Fixed test

(cherry picked from commit 6aef83f)
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Nov 17, 2021
apache#11804)

### Motivation
When a producer is getting error because of ProducerBusy (existing producer with the same name), it will trigger a producer close operation that will eventually lead to the existing producer getting removed from the topic map (even though that producer is still writing on the topic).

The problem is the producer close is triggering a removal from the map:
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java

Line 683 in 43ded59

 if (producers.remove(producer.getProducerName(), producer)) {
Even though we check for producer equality, the Producer.equals() is only comparing the producer name, so the old instance gets removed from the map.

Instead, the equality of producer needs to be based on the connection id (local & remote addresses and unique id), plus the producer id within that connection.

* Producer getting producer busy is removing existing producer from list

* Fixed test

(cherry picked from commit 6aef83f)
codelipenghui pushed a commit that referenced this pull request Dec 11, 2021
#11804)

### Motivation
When a producer is getting error because of ProducerBusy (existing producer with the same name), it will trigger a producer close operation that will eventually lead to the existing producer getting removed from the topic map (even though that producer is still writing on the topic).

The problem is the producer close is triggering a removal from the map:
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java

Line 683 in 43ded59

 if (producers.remove(producer.getProducerName(), producer)) {
Even though we check for producer equality, the Producer.equals() is only comparing the producer name, so the old instance gets removed from the map.

Instead, the equality of producer needs to be based on the connection id (local & remote addresses and unique id), plus the producer id within that connection.

* Producer getting producer busy is removing existing producer from list

* Fixed test

(cherry picked from commit 6aef83f)
@codelipenghui codelipenghui added the cherry-picked/branch-2.7 Archived: 2.7 is end of life label Dec 11, 2021
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this pull request Mar 18, 2022
apache#11804)

### Motivation
When a producer is getting error because of ProducerBusy (existing producer with the same name), it will trigger a producer close operation that will eventually lead to the existing producer getting removed from the topic map (even though that producer is still writing on the topic).

The problem is the producer close is triggering a removal from the map:
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java

Line 683 in 43ded59

 if (producers.remove(producer.getProducerName(), producer)) { 
Even though we check for producer equality, the Producer.equals() is only comparing the producer name, so the old instance gets removed from the map.

Instead, the equality of producer needs to be based on the connection id (local & remote addresses and unique id), plus the producer id within that connection.

* Producer getting producer busy is removing existing producer from list

* Fixed test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-picked/branch-2.7 Archived: 2.7 is end of life cherry-picked/branch-2.8 Archived: 2.8 is end of life doc-not-needed Your PR changes do not impact docs release/2.7.4 release/2.8.1 type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants