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

[fix][client] Make DeadLetterPolicy & KeySharedPolicy serializable #1

Closed
wants to merge 4 commits into from

Conversation

AnuragReddy2000
Copy link
Owner

@AnuragReddy2000 AnuragReddy2000 commented Dec 10, 2024

Fixes apache#23704

Motivation

We use the pulsar client to consume messages from a Pulsar broker in a Storm topology. Recently, we encountered an issue where the deadLetterPolicy that we set on the PulsarSpout seems to be lost when the topology is started. Upon investigation, we found that this is due to the deadLetterPolicy attribute in ConsumerConfigurationData being marked as transient. This prevents us from utilising the dead letter queue feature in our topology.

Modifications

Made DeadLetterPolicy, KeySharedPolicy and Range classes implement the java.io.Serializable interface and removed the transient keyword from the corresponding fields in the ConsumerConfigurationData class.

Verifying this change

  • Make sure that the change passes the CI checks.

This change is already covered by existing tests, such ClientConfigurationDataTest.java

Does this pull request potentially affect one of the following parts:

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@@ -29,7 +30,8 @@
*/
@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract class KeySharedPolicy {
public abstract class KeySharedPolicy implements Serializable {
private static final long serialVersionUID = 1L;
Copy link

Choose a reason for hiding this comment

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

Add private static final long serialVersionUID = 1L; to the implementation classes of the abstract KeySharedPolicy class instead of adding it to the abstract class where it is unnecessary.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes, my bad! Made these changes.

Copy link

Choose a reason for hiding this comment

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

Since this change is also included in this PR, I guess the transient definition for the keyHashRanges field in ReaderConfigurationData could be removed.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Agreed. Removed the transient keyword there too.

@lhotari
Copy link

lhotari commented Dec 10, 2024

This change is already covered by existing tests, such ClientConfigurationDataTest.java

I think it would be useful to reproduce the serialization problem that you explained in the issue apache#23704

@lhotari
Copy link

lhotari commented Dec 10, 2024

btw. I didn't notice until now that this is the PR in your fork to run Pulsar CI. Once you are ready with the initial pass, you can go ahead and open the PR at apache/pulsar for this PR branch. I can continue the review on that PR. I usually don't add review comments in the shadowed PR in the fork (which is for having full control of Pulsar CI and getting that feedback while working on the PR).

@AnuragReddy2000
Copy link
Owner Author

btw. I didn't notice until now that this is the PR in your fork to run Pulsar CI. Once you are ready with the initial pass, you can go ahead and open the PR at apache/pulsar for this PR branch. I can continue the review on that PR. I usually don't add review comments in the shadowed PR in the fork (which is for having full control of Pulsar CI and getting that feedback while working on the PR).

Sure. I just need one clarification though. When you said that it would be useful to reproduce the serialization problem, Did you mean for me to enhance the tests for that class to include checks on these fields?

@lhotari
Copy link

lhotari commented Dec 10, 2024

Sure. I just need one clarification though. When you said that it would be useful to reproduce the serialization problem, Did you mean for me to enhance the tests for that class to include checks on these fields?

I meant that there should be a test case what you described in the issue itself: "Create an instance of ConsumerConfigurationData class and set a deadLetterPolicy on it. Serialize it and de-serialize it back to get a new instance of the same. The deadLetterPolicy previously set should not be present after deserialization.".

@AnuragReddy2000
Copy link
Owner Author

@lhotari All the CI actions, (except the code coverage upload actions) have run successfully. I have raised a PR against the main repo master branch (apache#23718). Please do let me know if anything else is needed from my end.

@AnuragReddy2000
Copy link
Owner Author

Closing this PR as it is merged on the main repo (apache#23718)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] deadLetterPolicy attribute in the ConsumerConfigurationData class marked as transient
2 participants