GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [improve][broker] PIP-246: Improved PROTOBUF_NATIVE schema compatibility checks without using avro-protobuf by Denovo1998 · Pull Request #19566 · apache/pulsar

Conversation

@Denovo1998

@Denovo1998 Denovo1998 commented Feb 19, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

PIP: PIP-246

The shared Protobuf native deserialization fixes are already included in master through #26725.

Motivation

The default PROTOBUF_NATIVE checker compares only root message names, so it can accept field changes that break message reading. This PR introduces an opt-in checker that compares Protobuf descriptors directly, without converting them to Avro. The existing checker remains the default, and the schema storage format is unchanged.

Modifications

  • Add ProtobufNativeSchemaAdvancedCompatibilityCheck with directional checks for fields, required values, defaults, maps, oneofs, enums, and supported Protobuf features, including native components of KEY_VALUE schemas.
  • Apply the conservative compatibility policies defined in PIP-246, including rejecting scalar type changes and unsupported features.
  • Bound comparison work per historical schema pair and direction, memoize message and enum pairs, and return COMPARISON_LIMIT_EXCEEDED when the budget is exhausted.
  • Reuse byte-identical schema pairs while still checking other selected historical versions. Include the conflicting stored schema version in bounded error messages, including for key/value components.
  • Fail startup when a configured checker cannot be instantiated. When the advanced checker is selected, also reject conflicting native checkers and unavailable schema storage.
  • Add descriptor, registry, consumer, configuration, and generated-message regressions, plus a compatibility benchmark and appropriate lightproto exclusions.

Activation requires consistent checker configuration and broker restarts. Reconnecting consumers can still be rejected against other retained schema versions, even when their own schema is unchanged. Restore the default checker before downgrading to binaries that do not contain the advanced checker.

Verifying this change

  • Make sure that the change passes the CI checks.

Added tests cover directional compatibility, unsupported features, work-budget boundaries, shared message and enum pairs, historical schema version attribution, INLINE and SEPARATED KEY_VALUE schemas, startup validation, and diagnostics delivered to producers and consumers.

Local validation on JDK 21:

  • Protobuf 4.36.2: 148 focused broker/client tests passed.
  • Protobuf 3.25.5: 52 focused client/Functions tests passed.
  • ./gradlew quickCheck and ./gradlew :microbench:compileJava passed.

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

Schema impact: selecting the advanced checker changes compatibility validation for PROTOBUF_NATIVE schemas, including native components of KEY_VALUE schemas.

Deployment impact: activation requires consistent checker configuration and broker restarts. Invalid checker classes now fail startup. Restore the default checker before downgrading broker binaries.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Denovo1998
PIP-246: Improved PROTOBUF_NATIVE schema compatibility checks without…
bd883f0
… using avro-protobuf.
@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Feb 19, 2023
This was referenced Feb 19, 2023
[improve][broker] PIP-246: Improved PROTOBUF_NATIVE schema compatibility checks without using avro-protobuf Denovo1998/pulsar#2
Closed
PIP-246: Improved PROTOBUF_NATIVE schema compatibility checks without using avro-protobuf #19565
Closed
@sijie sijie mentioned this pull request Feb 19, 2023
ISSUE-19565: PIP-246: Improved PROTOBUF_NATIVE schema compatibility checks without using avro-protobuf streamnative/pulsar-archived#5538
Open
Denovo1998 added 2 commits March 5, 2023 20:18
@Denovo1998
add a flag to modify ProtobufNativeSchemaValidator different implemen…
8f5497c
…tations in the conf; fix test; when the field type changes there is no check, only a warning.
@Denovo1998
chang design
c2674d7
@github-actions

github-actions Bot commented Apr 5, 2023

Copy link
Copy Markdown

The pr had no activity for 30 days, mark with Stale label.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the Stale label Apr 5, 2023
@Technoboy- Technoboy- added this to the 3.2.0 milestone Jul 31, 2023
@Technoboy- Technoboy- modified the milestones: 3.2.0, 3.3.0 Dec 22, 2023
@coderzc coderzc modified the milestones: 3.3.0, 3.4.0 May 8, 2024
@lhotari lhotari modified the milestones: 4.0.0, 4.1.0 Oct 14, 2024
@coderzc coderzc modified the milestones: 4.1.0, 4.2.0 Sep 1, 2025
@Denovo1998 Denovo1998 closed this Apr 3, 2026
Denovo1998 added 2 commits September 21, 2026 19:43
@Denovo1998
Merge branch 'master' into protobuf-native-improve
83431ec
# Conflicts:
#	pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/ProtobufNativeSchemaUtils.java
@Denovo1998
[improve][broker] Add opt-in Protobuf native field compatibility checks
d2178fe
@Denovo1998 Denovo1998 reopened this Sep 23, 2026
@Denovo1998
Denovo1998 marked this pull request as draft September 23, 2026 12:40
Denovo1998 added 2 commits September 23, 2026 20:59
@Denovo1998
[fix][broker] Reject unsupported Protobuf native feature metadata
b4ceb2f
@Denovo1998
[fix][broker] Fix Protobuf native enum and feature boundary checks
471f2cb
@Denovo1998 Denovo1998 mentioned this pull request Sep 23, 2026
[improve][pip] PIP-246: Improved PROTOBUF_NATIVE schema compatibility checks without using avro-protobuf #26695
Merged
@Denovo1998
[fix][client] Preserve Protobuf v3 compatibility for native schemas
48cd3c2
@Denovo1998
Denovo1998 marked this pull request as ready for review September 23, 2026 14:45
lhotari
lhotari reviewed Sep 25, 2026
View reviewed changes

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for the continued work on this — the rule engine is careful, and it is mostly right on protobuf semantics: fields matched by number, directional required, the oneof rule including proto3 optional, open/closed enums including the proto2 default-reordering case, packed/unpacked in both directions, and fail-closed handling of unknown editions and features. Keeping the default checker untouched and failing fast when two PROTOBUF_NATIVE checkers are configured are both good.

Two things need resolving before this can merge: the comparison has no work bound and runs synchronously on the registry path (inline on ProtobufNativeSchemaCompatibility.java), and enabling the checker can refuse consumers that reconnect with an unchanged schema under the transitive strategies.

Separately, the description only links to #26695 and leaves the template placeholders. Please summarise the change there, including that the ProtobufNativeSchemaUtils.deserialize() changes reach every native-schema user — the default checker, the upload validator and the client's generic readers — not only those who opt in. Those parts (cycle detection, nested-root resolution without a package, Java feature parsing) could arguably be a separate [fix] PR. The @FieldContext doc of schemaRegistryCompatibilityCheckers (ServiceConfiguration.java:3861) should also get the activation note you added to broker.conf.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...src/main/java/org/apache/pulsar/broker/service/schema/ProtobufNativeSchemaCompatibility.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread .../org/apache/pulsar/broker/service/schema/ProtobufNativeSchemaAdvancedCompatibilityCheck.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...src/main/java/org/apache/pulsar/broker/service/schema/ProtobufNativeSchemaCompatibility.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread .../org/apache/pulsar/broker/service/schema/ProtobufNativeSchemaAdvancedCompatibilityCheck.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pulsar-broker/build.gradle.kts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Denovo1998
[fix][broker] Bound native schema checks and preserve schema reuse
8bc3f4e
@Denovo1998 Denovo1998 mentioned this pull request Sep 27, 2026
[fix][schema] Fix Protobuf native descriptor deserialization #26725
Merged
2 of 11 tasks
@Denovo1998
Denovo1998 requested a review from lhotari September 27, 2026 03:59
@Denovo1998
[improve][broker] Define Protobuf native comparison work accounting
f010a11
lhotari
lhotari approved these changes Oct 13, 2026
View reviewed changes

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM. Every point from my last review is handled, and the new work budget and version diagnostics read correctly. The PR description and the schemaRegistryCompatibilityCheckers doc now carry the activation notes I asked for.

Two non-blocking test ideas: a case where the cap is hit during the support-graph scan, and a shared writer enum paired with two different reader enums where only the second pair is incompatible. The PIP-246 vote (#26695) still needs to finish before this merges.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
codelipenghui
codelipenghui reviewed Oct 13, 2026
View reviewed changes

@codelipenghui codelipenghui left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for the thorough rework. The opt-in checker matches PIP-246 as voted, and I didn't find defects in the new comparison logic: the strategy-to-direction mapping, per-entry reuse of identical pairs, version attribution (including KEY_VALUE components), pair memoization and the startup fail-fast all check out. The focused tests pass locally on protobuf 4.35.1 / JDK 21 (ProtobufNativeSchemaCompatibilityTest, …ReadTest, …ConfigurationTest, KeyValueSchemaCompatibilityCheckTest, SchemaServiceTest, ProtobufNativeSchemaUtilsTest, ProtobufNativeSchemaTest), and the branch merges cleanly with current master.

The main item is merge order. The copy of ProtobufNativeSchemaUtils in this PR predates the review fixes in #26725, and it changes which message some stored root aliases resolve to, for default-checker users too (see the inline comment). I'd hold this PR until #26725 lands and this branch takes its final version and tests. The other inline comments are low severity or nits.

Not inline:

  • The doc-not-needed label doesn't seem to fit, since the PIP's General Notes say operator docs belong in pulsar-site. In the template, "The schema" (shared deserializer) and arguably "Anything that affects deployment" also apply, because startup now fails for any configured checker class that can't be loaded.
  • Test gaps worth considering:
    • No end-to-end client→broker test shows the new diagnostic reaching a producer or consumer through ServerCnx with the advanced checker configured.
    • Only INLINE KEY_VALUE encoding is covered. SEPARATED shares the decode path, so the risk is low.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/ProtobufNativeSchemaUtils.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...c/main/java/org/apache/pulsar/broker/service/ProtobufNativeSchemaCompatibilityBenchmark.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...src/main/java/org/apache/pulsar/broker/service/schema/ProtobufNativeSchemaCompatibility.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...src/main/java/org/apache/pulsar/broker/service/schema/ProtobufNativeSchemaCompatibility.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...ain/java/org/apache/pulsar/broker/service/schema/ProtobufNativeSchemaCompatibilityCheck.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread conf/standalone.conf Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Denovo1998
[fix][schema] Preserve native schema aliases and clarify diagnostics
3dbd8c8
@Denovo1998
Denovo1998 requested a review from codelipenghui October 13, 2026 14:35
codelipenghui
codelipenghui approved these changes Oct 13, 2026
View reviewed changes

@codelipenghui codelipenghui left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Approving. 3dbd8c8 addresses everything from my previous review:

  • The shared deserializer files are now byte-identical to #26725's current head: ProtobufNativeSchemaUtils and its tests, ProtobufNativeSchemaDeserializationTest, the deserialization benchmark, run_unit_group_gradle.sh and microbench/build.gradle.kts. The alias cases resolve as on master again, and either merge order is clean. If #26725 changes again before merging, please re-sync. If this PR lands first, #26725 becomes redundant.
  • Other fixes:
    • Unsupported-feature and work-limit diagnostics now use side=/detail= and work=/limit=.
    • The cap's practical ceiling is documented and pinned by tests.
    • The benchmark compares non-identical schemas.
    • The unrelated whitespace changes are reverted.
    • The new end-to-end producer/consumer test and the SEPARATED KEY_VALUE coverage close the test gaps I mentioned.

Verified locally on 3dbd8c8 (protobuf 4.35.1, JDK 21): quickCheck, :microbench:compileJava and the focused broker/client schema tests all pass, including SchemaServiceTest with the new end-to-end test. No CI checks are reported on this head yet, so please make sure CI is green before merging.

Non-blocking:

  • The PIP text in #26695 still says the legacy root lookup applies "when canonical lookup fails". The implementation now tries the legacy lookup first for non-canonical names in packaged files, so it's worth aligning there.
  • The doc-not-needed label and the unchecked "The schema" box don't match the change. The shared deserializer behaviour changes, and the PIP's General Notes say operator docs belong in pulsar-site.

The two inline comments are optional wording nits.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...src/main/java/org/apache/pulsar/broker/service/schema/ProtobufNativeSchemaCompatibility.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread .../org/apache/pulsar/broker/service/schema/ProtobufNativeSchemaAdvancedCompatibilityCheck.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Denovo1998

Denovo1998 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

@codelipenghui Hi, penghui. Could you help change the label from doc-not-needed to doc-required for this PR? I don’t have permission to update the labels. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lhotari
lhotari reviewed Oct 14, 2026
View reviewed changes

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM. I read the new commit (alias precedence in ProtobufNativeSchemaUtils, the cached extension registry, the clearer UNSUPPORTED_FEATURE and COMPARISON_LIMIT_EXCEEDED diagnostics, and the large-schema notes in the config docs). I found no problems. Legacy root aliases still resolve as before the PR, and the 14,500-field and 16,700-value figures match the work accounting.

Optional wording nit: the config text says a "fixed 100,000-work-unit cap", but the limit is min(100000, 16 * G), so small schemas get a lower cap. Saying "up to 100,000" would be more precise.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Denovo1998 added 2 commits October 14, 2026 20:14
@Denovo1998
Merge remote-tracking branch 'apache-https/master' into protobuf-nati…
5f981f4
…ve-improve
@Denovo1998
[fix][schema] Clarify Protobuf native compatibility diagnostics
f36a052
@codelipenghui codelipenghui added doc-required Your PR changes impact docs and you will update later. and removed doc-not-needed Your PR changes do not impact docs labels Oct 14, 2026
@codelipenghui codelipenghui assigned Denovo1998 Oct 14, 2026
@codelipenghui
codelipenghui merged commit 51f8238 into apache:master Oct 14, 2026
44 checks passed

Uh oh!

There was an error while loading. Please reload this page.

lhotari pushed a commit that referenced this pull request Oct 15, 2026
@Denovo1998 @lhotari
[improve][broker] PIP-246: Improved PROTOBUF_NATIVE schema compatibil…
8aaf321
…ity checks without using avro-protobuf (#19566)

(cherry picked from commit 51f8238)
@lhotari lhotari added release/5.0.1 cherry-picked/branch-5.0 labels Oct 15, 2026
@Denovo1998 Denovo1998 mentioned this pull request Oct 17, 2026
[improve][doc] Document PIP-246 native schema compatibility apache/pulsar-site#1256
Merged
2 tasks done
@Denovo1998

Denovo1998 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

Document update PR submitted: apache/pulsar-site#1256

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@merlimat merlimat mentioned this pull request Oct 24, 2026
Proper compatibility check for PROTOBUF_NATIVE schema #19385
Closed
1 of 2 tasks
@Denovo1998 Denovo1998 added doc-complete Your PR changes impact docs and the related docs have been already added. and removed doc-required Your PR changes impact docs and you will update later. labels Oct 27, 2026
@poorbarcode poorbarcode modified the milestones: 4.2.0, 5.0.0, 5.1.0 Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lhotari lhotari lhotari approved these changes
@codelipenghui codelipenghui codelipenghui approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@Denovo1998 Denovo1998

Labels

cherry-picked/branch-5.0 doc-complete Your PR changes impact docs and the related docs have been already added. release/5.0.1 Stale

Projects

None yet

Milestone

5.1.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@Denovo1998 @lhotari @codelipenghui @Technoboy- @poorbarcode @coderzc
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.