Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.

Prevent incomplete future and add more logs for ProducerIdManager - #1391

Merged
BewareMyPower merged 1 commit into
streamnative:masterfrom
BewareMyPower:bewaremypower/init-pid-enhance
Jul 7, 2022
Merged

BewareMyPower merged 1 commit into
streamnative:masterfrom
BewareMyPower:bewaremypower/init-pid-enhance

Conversation

@BewareMyPower

Copy link
Copy Markdown
Contributor

Motivation

Currently, if the ProducerIdManager failed to generate the producer ID,
the future of epoch and TxnMetadata would never complete, see

if (throwable != null) {
responseCallback.accept(new InitProducerIdResult(
-1L,
producerEpoch
, Errors.UNKNOWN_SERVER_ERROR));
return;

epochAndTxnMetaFuture would not complete in the case above.

In addition, since epochAndTxnMetaFuture never complete exceptionally,
the following code is redundant:

}).exceptionally(ex -> {
log.error("Get epoch and TxnMetadata failed.", ex);
responseCallback.accept(initTransactionError(Errors.forException(ex.getCause())));
return null;
});

Modifications

When the ProducerIdManager failed to generate the producer ID,
complete epochAndTxnMetaFuture with null and handle the null value in
the callback.

Then add some debug and error logs for ProducerIdManager. Regarding
the exceptionally block of epochAndTxnMetaFuture, treat it as an
unexpected error caused by thenAccept block and return a
UNKNOWN_SERVER_ERROR as well. Because in this case
Errors.forException(ex.getCause()) never return a valid error code.

Documentation

Check the box below.

Need to update docs?

  • doc-required

    (If you need help on updating docs, create a doc issue)

  • no-need-doc

    (Please explain why)

  • doc

    (If this PR contains doc changes)

### Motivation

Currently, if the `ProducerIdManager` failed to generate the producer ID,
the future of epoch and `TxnMetadata` would never complete, see

https://github.com/streamnative/kop/blob/f63b191e72d2319f67f7a5ab7242e898c10ed9c5/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/coordinator/transaction/TransactionCoordinator.java#L248-L253

`epochAndTxnMetaFuture` would not complete in the case above.

In addition, since `epochAndTxnMetaFuture` never complete exceptionally,
the following code is redundant:

https://github.com/streamnative/kop/blob/f63b191e72d2319f67f7a5ab7242e898c10ed9c5/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/coordinator/transaction/TransactionCoordinator.java#L304-L309

### Modifications

When the `ProducerIdManager` failed to generate the producer ID,
complete `epochAndTxnMetaFuture` with null and handle the null value in
the callback.

Then add some debug and error logs for `ProducerIdManager`. Regarding
the `exceptionally` block of `epochAndTxnMetaFuture`, treat it as an
unexpected error caused by `thenAccept` block and return a
`UNKNOWN_SERVER_ERROR` as well. Because in this case
`Errors.forException(ex.getCause())` never return a valid error code.

@Demogorgon314 Demogorgon314 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@BewareMyPower
BewareMyPower merged commit dc9d49a into streamnative:master Jul 7, 2022
@BewareMyPower
BewareMyPower deleted the bewaremypower/init-pid-enhance branch July 7, 2022 13:54
BewareMyPower added a commit that referenced this pull request Jul 9, 2022
)

### Motivation

Currently, if the `ProducerIdManager` failed to generate the producer ID,
the future of epoch and `TxnMetadata` would never complete, see

https://github.com/streamnative/kop/blob/f63b191e72d2319f67f7a5ab7242e898c10ed9c5/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/coordinator/transaction/TransactionCoordinator.java#L248-L253

`epochAndTxnMetaFuture` would not complete in the case above.

In addition, since `epochAndTxnMetaFuture` never complete exceptionally,
the following code is redundant:

https://github.com/streamnative/kop/blob/f63b191e72d2319f67f7a5ab7242e898c10ed9c5/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/coordinator/transaction/TransactionCoordinator.java#L304-L309

### Modifications

When the `ProducerIdManager` failed to generate the producer ID,
complete `epochAndTxnMetaFuture` with null and handle the null value in
the callback.

Then add some debug and error logs for `ProducerIdManager`. Regarding
the `exceptionally` block of `epochAndTxnMetaFuture`, treat it as an
unexpected error caused by `thenAccept` block and return a
`UNKNOWN_SERVER_ERROR` as well. Because in this case
`Errors.forException(ex.getCause())` never return a valid error code.

(cherry picked from commit dc9d49a)
BewareMyPower added a commit that referenced this pull request Jul 19, 2022
)

### Motivation

Currently, if the `ProducerIdManager` failed to generate the producer ID,
the future of epoch and `TxnMetadata` would never complete, see

https://github.com/streamnative/kop/blob/f63b191e72d2319f67f7a5ab7242e898c10ed9c5/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/coordinator/transaction/TransactionCoordinator.java#L248-L253

`epochAndTxnMetaFuture` would not complete in the case above.

In addition, since `epochAndTxnMetaFuture` never complete exceptionally,
the following code is redundant:

https://github.com/streamnative/kop/blob/f63b191e72d2319f67f7a5ab7242e898c10ed9c5/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/coordinator/transaction/TransactionCoordinator.java#L304-L309

### Modifications

When the `ProducerIdManager` failed to generate the producer ID,
complete `epochAndTxnMetaFuture` with null and handle the null value in
the callback.

Then add some debug and error logs for `ProducerIdManager`. Regarding
the `exceptionally` block of `epochAndTxnMetaFuture`, treat it as an
unexpected error caused by `thenAccept` block and return a
`UNKNOWN_SERVER_ERROR` as well. Because in this case
`Errors.forException(ex.getCause())` never return a valid error code.

(cherry picked from commit dc9d49a)
BewareMyPower added a commit that referenced this pull request Jul 20, 2022
)

### Motivation

Currently, if the `ProducerIdManager` failed to generate the producer ID,
the future of epoch and `TxnMetadata` would never complete, see

https://github.com/streamnative/kop/blob/f63b191e72d2319f67f7a5ab7242e898c10ed9c5/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/coordinator/transaction/TransactionCoordinator.java#L248-L253

`epochAndTxnMetaFuture` would not complete in the case above.

In addition, since `epochAndTxnMetaFuture` never complete exceptionally,
the following code is redundant:

https://github.com/streamnative/kop/blob/f63b191e72d2319f67f7a5ab7242e898c10ed9c5/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/coordinator/transaction/TransactionCoordinator.java#L304-L309

### Modifications

When the `ProducerIdManager` failed to generate the producer ID,
complete `epochAndTxnMetaFuture` with null and handle the null value in
the callback.

Then add some debug and error logs for `ProducerIdManager`. Regarding
the `exceptionally` block of `epochAndTxnMetaFuture`, treat it as an
unexpected error caused by `thenAccept` block and return a
`UNKNOWN_SERVER_ERROR` as well. Because in this case
`Errors.forException(ex.getCause())` never return a valid error code.

(cherry picked from commit dc9d49a)
michaeljmarshall pushed a commit to michaeljmarshall/kop that referenced this pull request Dec 13, 2022
…reamnative#1391)

### Motivation

Currently, if the `ProducerIdManager` failed to generate the producer ID,
the future of epoch and `TxnMetadata` would never complete, see

https://github.com/streamnative/kop/blob/f63b191e72d2319f67f7a5ab7242e898c10ed9c5/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/coordinator/transaction/TransactionCoordinator.java#L248-L253

`epochAndTxnMetaFuture` would not complete in the case above.

In addition, since `epochAndTxnMetaFuture` never complete exceptionally,
the following code is redundant:

https://github.com/streamnative/kop/blob/f63b191e72d2319f67f7a5ab7242e898c10ed9c5/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/coordinator/transaction/TransactionCoordinator.java#L304-L309

### Modifications

When the `ProducerIdManager` failed to generate the producer ID,
complete `epochAndTxnMetaFuture` with null and handle the null value in
the callback.

Then add some debug and error logs for `ProducerIdManager`. Regarding
the `exceptionally` block of `epochAndTxnMetaFuture`, treat it as an
unexpected error caused by `thenAccept` block and return a
`UNKNOWN_SERVER_ERROR` as well. Because in this case
`Errors.forException(ex.getCause())` never return a valid error code.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants