Fix ProtoBufRecordExtractor cache invalidation for Protobuf schema evolution#18839
Closed
arunkumarucet wants to merge 2 commits into
Closed
Fix ProtoBufRecordExtractor cache invalidation for Protobuf schema evolution#18839arunkumarucet wants to merge 2 commits into
arunkumarucet wants to merge 2 commits into
Conversation
…ing via JMX Emit a per-table `tableTenantInfo` gauge from `SegmentStatusChecker` with the server tenant name embedded as an extra key segment in the metric name: pinot.controller.tableTenantInfo.<tableNameWithType>.<serverTenant> = 1 This lets Prometheus scrape the metric via the JMX exporter and use a `group_left(tenant)` join to attach the tenant label to any existing table-scoped metric without modifying the core metrics pipeline. Implementation details: - The gauge is registered only on first encounter or when the tenant changes, avoiding redundant writes on every 5-minute SegmentStatusChecker cycle. - Stale gauges are cleaned up on tenant change, null config, and table removal, tracked via an internal `_tableTenantMap`. - A dedicated JMX exporter rule in `controller.yml` extracts `table`, `tableType`, `tenant`, and `database` labels. The rule is placed before the generic tableNameWithType rules to ensure the tenant segment is captured.
The field-descriptor cache introduced in PR apache#17593 keyed invalidation on descriptor.getFullName(). When a Confluent Schema Registry schema evolves (e.g. a new column is added), KafkaProtobufDeserializer returns a fresh Descriptors.Descriptor object with the same full name but a different instance. The stale cache was never invalidated, so FieldDescriptors from the old Descriptor were applied to the new DynamicMessage. Protobuf enforces strict object identity between a FieldDescriptor and its containing Descriptor, causing: IllegalArgumentException: FieldDescriptor does not match message type Fix: replace full-name string comparison with object identity (!=). This is cheaper and correctly detects any descriptor change, including same-name schema evolutions. A regression test is added that directly replicates the failure scenario using two programmatically built Descriptor instances with the same full name but different schema IDs.
Contributor
Author
|
Superseded by a clean branch — only the 2 protobuf files are included. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #18839 +/- ##
============================================
+ Coverage 64.76% 64.77% +0.01%
- Complexity 1319 1322 +3
============================================
Files 3392 3393 +1
Lines 210949 211041 +92
Branches 33119 33140 +21
============================================
+ Hits 136611 136712 +101
+ Misses 63323 63297 -26
- Partials 11015 11032 +17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes a regression introduced in #17593 where
ProtoBufRecordExtractorthrowsIllegalArgumentException: FieldDescriptor does not match message typeafter a Confluent Schema Registry Protobuf schema evolves (e.g. a new column is added to the schema).Root cause: The field-descriptor cache added in #17593 used
descriptor.getFullName()equality to detect schema changes. When a new schema version is registered,KafkaProtobufDeserializerreturnsDynamicMessageinstances built from a newDescriptors.Descriptorobject — same full name, different instance. The stale cache was never invalidated, soFieldDescriptorobjects from the oldDescriptorwere passed toDynamicMessage.hasField()/getField()on the new message. Protobuf enforces strict object identity (fd.getContainingType() != descriptor), causing the crash.Fix: Replace the full-name string comparison with object identity (
!=). This is cheaper (no string allocation) and correctly detects any descriptor change, including same-name schema evolutions.Test plan
testSchemaEvolutionSameFullNameDifferentDescriptorInstancetoProtoBufRecordExtractorCachingTest— builds twoDescriptorinstances programmatically with the same full name (Order) but different fields (V1:id,amount; V2:id,amount,status), exactly replicating what Confluent Schema Registry does on schema evolution. Without the fix this test throwsIllegalArgumentException; with the fix all 13 caching tests pass../mvnw -pl pinot-plugins/pinot-input-format/pinot-protobuf -Dtest=ProtoBufRecordExtractorCachingTest test→ 13/13 pass./mvnw spotless:apply checkstyle:check license:check -pl pinot-plugins/pinot-input-format/pinot-protobuf→ clean