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

KAFKA-15208: Upgrade Jackson dependencies to version 2.16.0 #13662

Merged
merged 11 commits into from
Dec 19, 2023

Conversation

bmscomp
Copy link
Contributor

@bmscomp bmscomp commented May 2, 2023

Upgrade Jackson dependencies to version 2.16.0

  • Unify the Jackson and Jackson Data bind dependencies and upgrade to the latest stable version 2.15.2
  • Remove deprecation call of JsonNodeFactory.withExactBigDecimals
  • Fix some typos in comments and documentation

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@bmscomp bmscomp changed the title MINOR: Upgrade Jackson dependencies to version to 2.15.0 MINOR: Upgrade Jackson dependencies to version 2.15.0 May 2, 2023
@bmscomp
Copy link
Contributor Author

bmscomp commented May 4, 2023

@divijvaidya this pull request targets an update to version 2.15.0, please can you tell me better about updating not only minor versions ?

@divijvaidya
Copy link
Contributor

@bmscomp this is a nice PR and I support it. I opened the other one ( #13673 ) for minor versions upgrades because minor versions have a lower risk and require less detailed review for reviewers. My ideal situation would be if we can merge the minor version updates into the upcoming 3.5 (it's safe because of minor upgrades) and then target key major version upgrades of dependencies such as this PR for 3.6. Nevertheless, let's hear back from what other folks in the community have to say about this.

(If the minor version PR doesn't make it to 3.5, I will remove jackson changes from it so that jackson can be addressed by this PR).

@bmscomp
Copy link
Contributor Author

bmscomp commented May 5, 2023

@divijvaidya I get your point, thanks so much for those explanations

@ijuma
Copy link
Contributor

ijuma commented May 12, 2023

It would be better to have a separate PR for clean-ups unrelated to the Jackson dependency update.

@bmscomp
Copy link
Contributor Author

bmscomp commented May 12, 2023

@ijuma thank you for the comment, I'll update this pull PR and make another one for clean-ups

@bmscomp bmscomp force-pushed the upgrade/jackson_version_to_2.15.0 branch 2 times, most recently from 3838fd2 to 950d2d5 Compare May 13, 2023 20:35
@bmscomp
Copy link
Contributor Author

bmscomp commented May 13, 2023

@ijuma the PR is updated , I managed to keep only modifications related to the upgrade of Jackson version to 2.15.0, I'll make another separate PR related to clean-ups

@divijvaidya
Copy link
Contributor

Breaking changes between 2.13.x and 2.15.x:

  1. @JsonIgnore gets more precedence than @JsonProperty in 2.15.x in case both annotations are assigned to a property. Prior to 2.14.x, it was the opposite precedence. See: https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.14#observedreported-changes
    This should not impact Kafka since I couldn't find usages of @JsonIgnore in the code base.

  2. ProcessingLimits adds limitation to length of different tokens. Prior to 2.15.x, there was no limits. See: https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.15#processing-limits
    Verified that FileBasedStateStore is not impacted by the new limits.

  3. Modified handling of datetime with zone information in it. See: https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.15#changes-behavior-other

@bmscomp could you please go through the usage of Jackson in Kafka code base and add here (similar to above) on why the new processing limits won't impact existing code (or comment if we want to increase the limits from default values). Same for ZoneId handling. Given the number of breaking changes, I think we should also create a JIRA for this (and associate the PR). This is not a minor change!

Thanks!

@divijvaidya
Copy link
Contributor

I found today that there is another change that needs to make it in this PR. We need to update the LICENSE file with the correct version at https://github.com/apache/kafka/blob/trunk/LICENSE-binary#L211

@divijvaidya divijvaidya added the dependencies Pull requests that update a dependency file label May 24, 2023
@showuon
Copy link
Contributor

showuon commented Jun 7, 2023

@bmscomp , could you respond to @divijvaidya 's comments above? Thanks.

@bmscomp
Copy link
Contributor Author

bmscomp commented Jun 8, 2023

@showuon Yes I'll do ,Thanks so much @divijvaidya for reviews, I am back from holidays :) , I'll continue working on this topic, I'll check all comments one by one and try to bring the best answer possible that I'lll be able to do

Thanks again for all reviews

@bmscomp bmscomp force-pushed the upgrade/jackson_version_to_2.15.0 branch from 66ac8b7 to 2ed8685 Compare July 16, 2023 09:04
@bmscomp bmscomp changed the title MINOR: Upgrade Jackson dependencies to version 2.15.0 MINOR: Upgrade Jackson dependencies to version 2.15.2 Jul 16, 2023
@bmscomp
Copy link
Contributor Author

bmscomp commented Jul 16, 2023

@divijvaidya License file updated to mention the correct jackson version

@bmscomp
Copy link
Contributor Author

bmscomp commented Jul 16, 2023

@divijvaidya The third point you mentioned
Modified handling of datetime with zone information in it. See: https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.15#changes-behavior-other does not affect the existing code base, it solves an issue, it's a correction of an existing bug in previous jackson version that prevent producing that kind of bugs

ZonedDateTime now = ZonedDateTime.now();
assertTrue(now.withZoneSameInstant(ZoneOffset.UTC)
        .equals(now.withZoneSameInstant(ZoneId.of("UTC"))));

I use to think that we need to write tests on json Serialization and Deserialization of zoned datetime values

@bmscomp
Copy link
Contributor Author

bmscomp commented Jul 16, 2023

@divijvaidya Yes I agree with you this is not a minor change, we need to create a JIRA ticket for that

@bmscomp bmscomp force-pushed the upgrade/jackson_version_to_2.15.0 branch from d587671 to 4d4a285 Compare July 17, 2023 21:47
@divijvaidya
Copy link
Contributor

Hey @bmscomp
I am waiting for an answer to the following. Please tag me again when this is ready for review.

@bmscomp could you please go through the usage of Jackson in Kafka code base and add here (similar to above) on why the new processing limits won't impact existing code (or comment if we want to increase the limits from default values).

@bmscomp
Copy link
Contributor Author

bmscomp commented Jul 18, 2023

@divijvaidya I am pretty sure the introduced default values for limits wont affect the existing processing capacity, FileBasedStateStore is mainly used to store Quorum state data, and I use to think there is no need to raise the limits from default values

Since in this version:

  • Maximum number token lengths is set to 1000 as maximum number of bytes or chars that we will parse in a number
  • Maximum String value length is raised to 20_000_000 (20 million) input units bytes/chars depending on input source) in 2.15.1 and the initial value in version 2.15.0 was 5_000_000 (5 million)
  • Maximum Input nesting depth is set up to 1000 levels, and this is too huge QuorumStateData does not have as much as levels

@bmscomp bmscomp changed the title MINOR: Upgrade Jackson dependencies to version 2.15.2 KAFKA-15208: Upgrade Jackson dependencies to version 2.15.2 Jul 18, 2023
@divijvaidya divijvaidya added the backport-candidate This pull request is a candidate to be backported to previous versions label Jul 18, 2023
@bmscomp bmscomp force-pushed the upgrade/jackson_version_to_2.15.0 branch from 4d4a285 to d1c44b0 Compare July 18, 2023 22:02
@divijvaidya
Copy link
Contributor

FileBasedStateStore and QuorumState are not the only place that uses jackson. Did you check usage of objectmapper, Json.scala etc. for the limits question?

@bmscomp
Copy link
Contributor Author

bmscomp commented Jul 19, 2023

@divijvaidya For the internal usage of Jackson, I can say with much confidence that the limits are far more then what is needed to run Kafka, for it's usage the message.max.bytes in Kafka it's by default 1MB, and this is also far below limits for message transformation Serialization and Deserialization

The limit not put in the message size but the attribute value size and for example String values limit is raised to 20 megabytes, and this is already huge,

Do not think it's necessary to raise those default values

@bmscomp bmscomp force-pushed the upgrade/jackson_version_to_2.15.0 branch from d1c44b0 to f306247 Compare July 21, 2023 15:45
@divijvaidya
Copy link
Contributor

2.15.0 has a regression: FasterXML/jackson-databind#3968

We may want to directly want to jump to that to avoid the regression. Let's see what is the latest available version by code freeze date of 3.6 and we will merge that in.

@bmscomp
Copy link
Contributor Author

bmscomp commented Dec 6, 2023

@mimaison Thanks for the review I'll to this asap by the end of day

@bmscomp bmscomp force-pushed the upgrade/jackson_version_to_2.15.0 branch from ec9ac99 to 6e92864 Compare December 6, 2023 23:36
@bmscomp
Copy link
Contributor Author

bmscomp commented Dec 6, 2023

@mimaison Done!

Copy link
Member

@mimaison mimaison left a comment

Choose a reason for hiding this comment

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

Thanks for the updates. I left a couple of questions

@@ -143,7 +143,7 @@ public class JsonConverter implements Converter, HeaderConverter, Versioned {
// names specified in the field
private static final HashMap<String, LogicalTypeConverter> LOGICAL_CONVERTERS = new HashMap<>();

private static final JsonNodeFactory JSON_NODE_FACTORY = JsonNodeFactory.withExactBigDecimals(true);
private static final JsonNodeFactory JSON_NODE_FACTORY = new JsonNodeFactory(true);
Copy link
Member

Choose a reason for hiding this comment

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

Can you clarify why we're making this changes?

Copy link
Contributor Author

@bmscomp bmscomp Dec 15, 2023

Choose a reason for hiding this comment

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

@mimaison Sorry I missed answering this point, the change is made because the static method is deprecated

    /**
     * Return a factory instance with the desired behavior for BigDecimals
     * <p>See {@link #JsonNodeFactory(boolean)} for a full description.</p>
     *
     * @param bigDecimalExact If {code true} DISABLE normalization of {@link BigDecimal} values;
     *    if {code false} ENABLE normalization
     * @return a factory instance with specified configuration
     *
     * @deprecated Use {@link com.fasterxml.jackson.databind.cfg.JsonNodeFeature#STRIP_TRAILING_BIGDECIMAL_ZEROES}
     *   instead for configuring behavior.
     */
    @Deprecated
    public static JsonNodeFactory withExactBigDecimals(boolean bigDecimalExact)
    {
        return new JsonNodeFactory(bigDecimalExact);
    }
 

and the best available replacement for it is the the constructor

    /**
     * @param bigDecimalExact see Class description on "BigDecimal normalization"
     *
     * @see BigDecimal
     */
    public JsonNodeFactory(boolean bigDecimalExact)
    {
        _cfgBigDecimalExact = bigDecimalExact;
    }

LICENSE-binary Outdated
jackson-module-jaxb-annotations-2.13.5
jackson-module-scala_2.13-2.13.5
jackson-module-scala_2.12-2.13.5
jackson-annotations-2.15.3
Copy link
Member

Choose a reason for hiding this comment

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

There's even a 2.16.0 release now. Is there a reason you picked 2.15.3?

Copy link
Contributor Author

@bmscomp bmscomp Dec 8, 2023

Choose a reason for hiding this comment

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

@mimaison I know about this release I think it worth it to upgrade to it, I'll give it a try, but suppose the 2.15.3 is far stable till now

@bmscomp
Copy link
Contributor Author

bmscomp commented Dec 8, 2023

@mimaison I already upgraded to version 2.16.0 and updated the pull request

@bmscomp bmscomp changed the title KAFKA-15208: Upgrade Jackson dependencies to version 2.15.3 KAFKA-15208: Upgrade Jackson dependencies to version 2.16.0 Dec 8, 2023
@bmscomp bmscomp force-pushed the upgrade/jackson_version_to_2.15.0 branch from adf612f to 5247cda Compare December 9, 2023 11:29
Copy link
Member

@mimaison mimaison left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the PR

@mimaison
Copy link
Member

@divijvaidya Do you have any further comments?

Copy link
Contributor

@divijvaidya divijvaidya left a comment

Choose a reason for hiding this comment

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

Some additional things that I verified:

  • JDK version supported is 8 and above.
  • scala versions 2.11 and above are supported.
  • the limits added in this version are sufficiently large for Kafka use cases. 1000 levels of nesting, 50k chars in property name and unlimited maximum content length.
  • this version upgrades dependency PCollection to 4.x, Kafka already uses 4.1 version for PCollection

Overall change looks good to me. I am waiting for CI to succeed.

@mimaison
Copy link
Member

None of the failures in the latest build seem related, merging to trunk

@mimaison mimaison merged commit 05014ba into apache:trunk Dec 19, 2023
1 check failed
mimaison pushed a commit that referenced this pull request Dec 19, 2023
@mimaison
Copy link
Member

Backported to 3.7: 62c7e8b

gaurav-narula pushed a commit to gaurav-narula/kafka that referenced this pull request Jan 24, 2024
yyu1993 pushed a commit to yyu1993/kafka that referenced this pull request Feb 15, 2024
AnatolyPopov pushed a commit to aiven/kafka that referenced this pull request Feb 16, 2024
clolov pushed a commit to clolov/kafka that referenced this pull request Apr 5, 2024
showuon added a commit to showuon/kafka that referenced this pull request Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-candidate This pull request is a candidate to be backported to previous versions dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants