Skip to content

Recommend schema and table config migrations by default - #19270

Open
xiangfu0 wants to merge 1 commit into
apache:masterfrom
xiangfu0:cs_GqTMcOVI6Y/feature/config-schema-auto-migration
Open

xiangfu0 wants to merge 1 commit into
apache:masterfrom
xiangfu0:cs_GqTMcOVI6Y/feature/config-schema-auto-migration

Conversation

@xiangfu0

@xiangfu0 xiangfu0 commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Inspect stored table configs and schemas hourly, reporting warnings and metrics by default. Set cluster config controller.config.migration.auto.update.enabled=true through POST /cluster/configs to enable validated, version-checked updates of both without controller restarts (usage and examples).

Table config migration: v0 → v1

Deprecated config New config Rule
tableIndexConfig.streamConfigs ingestionConfig.streamIngestionConfig.streamConfigMaps[0] Wrap the non-empty stream-config map in a one-element list. If a modern streamIngestionConfig already exists, retain it instead. Clear the deprecated field.
segmentsConfig.segmentPushType ingestionConfig.batchIngestionConfig.segmentIngestionType Copy the legacy value only when the modern value is absent; otherwise retain the modern value. Clear the deprecated field.
segmentsConfig.segmentPushFrequency ingestionConfig.batchIngestionConfig.segmentIngestionFrequency Copy the legacy value only when the modern value is absent; otherwise retain the modern value. Clear the deprecated field.

When creating a stream-ingestion config, also copy tableIndexConfig.columnMajorSegmentBuilderEnabled to ingestionConfig.streamIngestionConfig.columnMajorSegmentBuilderEnabled, including an explicit false. The original flag is retained; an existing modern stream-ingestion flag is preserved.

Schema migration: v0 → v1

timeFieldSpec (TIME) → an entry in dateTimeFieldSpecs (DATE_TIME), removing the legacy field representation.

  • Derive the name, data type, format, and granularity from the outgoing granularity spec, or the incoming spec when no outgoing spec exists. For example, an outgoing one-hour epoch field becomes format: "1:HOURS:EPOCH" and granularity: "1:HOURS".
  • Use the existing transform, or generate an equivalent incoming-to-outgoing epoch conversion when supported; for example, incoming milliseconds to outgoing hours uses toEpochHours(incomingColumn). Move the resulting expression into table config through the rule below.
  • Preserve common field attributes, including field IDs, aliases, nullability, defaults, metadata, and length settings.
  • Skip unsupported conversions: an empty transform with differing incoming/outgoing specs, non-unit millisecond conversions requiring a generated transform, formatted-date conversions requiring a generated transform, or unsupported units in generated conversions.

Schema-field transform migration

schema.*FieldSpecs[].transformFunction → tableConfig.ingestionConfig.transformConfigs[], with the field name as columnName and the existing expression as transformFunction.

  • Copy active schema transforms into every affected OFFLINE/REALTIME table, adding only missing destinations. Preserve each table's existing overrides, including different expressions and decorator-supplied settings.
  • Check every affected table version and write changed table configs before clearing the shared schema transforms in one atomic ZooKeeper transaction. A stale/deleted record or validation failure leaves all definitions unchanged. Table creation fences cleanup through the schema version; ingestion readers fetch schema before table config to avoid a mixed pair.
  • Include expressions generated by TIME conversion. Leave empty, virtual-field, and nested-child transforms unchanged; skip candidates whose effective behavior would change through templates, decorators, or validation restrictions.

Changed candidates receive migration version 1: table configs use metadata.customConfigs["config.migration.version"]; schemas use configMigrationVersion. Modern definitions remain unchanged. Automatic writes retain raw templates, validate candidates, and skip concurrent-edit conflicts or stored fields that cannot survive a typed round trip.

Validation: 51 targeted JDK 25 tests passed, covering schema/table migration, unreadable hybrid counterparts, independent fallback after coordination failure, invalid stored schemas, and schema/table read ordering; affected-module formatting, license, Checkstyle, warning-enabled compilation, and independent review passed.

@codecov-commenter

codecov-commenter commented Aug 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.83556% with 95 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.52%. Comparing base (3c43f68) to head (994e69f).

Files with missing lines Patch % Lines
...ntroller/helix/core/PinotHelixResourceManager.java 73.03% 25 Missing and 23 partials ⚠️
...elix/core/periodictask/ConfigMigrationManager.java 91.16% 6 Missing and 10 partials ⚠️
...ache/pinot/common/metadata/ZKMetadataProvider.java 50.00% 6 Missing and 1 partial ⚠️
.../spi/config/migration/ConfigMigrationRegistry.java 89.36% 2 Missing and 3 partials ⚠️
...utils/migration/LegacyTimeFieldSchemaMigrator.java 84.61% 2 Missing and 2 partials ⚠️
...sks/refreshsegment/RefreshSegmentTaskExecutor.java 0.00% 3 Missing ⚠️
...upsertcompaction/UpsertCompactionTaskExecutor.java 0.00% 3 Missing ⚠️
...not/spi/config/migration/ConfigMigrationUtils.java 83.33% 2 Missing and 1 partial ⚠️
...va/org/apache/pinot/controller/ControllerConf.java 71.42% 1 Missing and 1 partial ⚠️
.../pinot/core/data/manager/BaseTableDataManager.java 50.00% 0 Missing and 1 partial ⚠️
... and 3 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #19270      +/-   ##
============================================
+ Coverage     71.45%   71.52%   +0.07%     
  Complexity     1639     1639              
============================================
  Files          3609     3616       +7     
  Lines        243835   244330     +495     
  Branches      39630    39724      +94     
============================================
+ Hits         174230   174768     +538     
+ Misses        56492    56418      -74     
- Partials      13113    13144      +31     
Flag Coverage Δ
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (ø)
java-25 71.52% <81.83%> (+0.07%) ⬆️
lane-a 100.00% <ø> (ø)
lane-b 0.00% <ø> (ø)
temurin 71.52% <81.83%> (+0.07%) ⬆️
unittests 71.52% <81.83%> (+0.07%) ⬆️
unittests1 61.20% <44.28%> (-0.01%) ⬇️
unittests2 43.15% <80.68%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@xiangfu0

Copy link
Copy Markdown
Contributor Author

Self-review pass (multi-domain) + fixes applied

Ran an independent multi-domain review over the branch diff. 0 CRITICAL, 7 MAJOR. Addressed the substantive findings in the latest commit:

Fixed

  • Schema re-migration infinite loop (verified bug): marker-only schema migrations were persisted via PinotHelixResourceManager.updateSchema, which short-circuits on schema.equals(oldSchema) — and Schema.equals() deliberately excludes the migration marker, so the marker never persisted and the schema re-migrated every cycle (with false success metrics). Latent today (empty schema chain) but a real trap. Now persisted directly via ZKMetadataProvider.setSchema + best-effort refresh messages. Covered by a new test asserting the stored marker advances and a refresh is sent.
  • Default flipped to OFF (opt-in): the task rewrites stored ZK configs cluster-wide, so it now defaults off and is intended to be enabled only after all nodes are upgraded. Resolves the rolling-upgrade/rollback and soak-period concerns.
  • Empty-chain short-circuit: no ZK reads/writes when a migration chain is empty (the shipped schema chain is empty), and the schema is fetched once per table.
  • Mixed-version field clearing: documented on the migrator; verified current readers resolve via the ingestionConfig-preferred fallback, so same-version reads are unaffected — the opt-in-after-upgrade posture covers the old-binary-rollback edge.
  • More tests: deprecated ingestion-config collision folding (existing ingestionConfig wins, deprecated cleared), schema-marker persistence + refresh + once-per-hybrid-run, empty-chain short-circuit, and Schema serialization asserted through the full objectToString path.
  • Renamed MIGRATION_VERSION_KEY → CONFIG_MIGRATION_VERSION_KEY; documented the controller-managed reserved custom-config key.

Deferred (tracked, low-risk)

  • A ControllerTest-based end-to-end test through the real ZK write path (current controller tests mock the resource manager) — worth adding but the unit coverage now exercises the persistence/skip/validation/metric paths.
  • SPI callout: this adds a new org.apache.pinot.spi.config.migration package and a Schema.configMigrationVersion field (both additive, rollback-safe) — flagging for plugin/enterprise maintainers.

All precommit checks (spotless, license, checkstyle: 0 violations) pass on the four touched modules; unit suites green (spi 29, segment-local 6, controller 6).

@xiangfu0
xiangfu0 force-pushed the cs_GqTMcOVI6Y/feature/config-schema-auto-migration branch from e92acee to 2cdc824 Compare August 16, 2026 09:04
@intentlab-ai
intentlab-ai Bot force-pushed the cs_GqTMcOVI6Y/feature/config-schema-auto-migration branch from 2cdc824 to 04da9d3 Compare August 17, 2026 06:29
@xiangfu0
xiangfu0 force-pushed the cs_GqTMcOVI6Y/feature/config-schema-auto-migration branch from 04da9d3 to 15417f5 Compare August 18, 2026 09:04
@xiangfu0 xiangfu0 added feature New functionality configuration Config changes (addition/deletion/change in behavior) extension-point Adds or modifies an extension/SPI point needs-attention Used for sensitive changes - allows searching PRs post release to narrow down causes for regression. release-notes Referenced by PRs that need attention when compiling the next release notes labels Aug 19, 2026
@xiangfu0
xiangfu0 force-pushed the cs_GqTMcOVI6Y/feature/config-schema-auto-migration branch 4 times, most recently from 580cb93 to 5788e21 Compare August 26, 2026 09:23
@xiangfu0
xiangfu0 force-pushed the cs_GqTMcOVI6Y/feature/config-schema-auto-migration branch 6 times, most recently from 7f3053d to ab2b9b0 Compare September 2, 2026 09:33
@xiangfu0
xiangfu0 force-pushed the cs_GqTMcOVI6Y/feature/config-schema-auto-migration branch 3 times, most recently from 30bb438 to 1b9606c Compare September 5, 2026 09:20
@xiangfu0
xiangfu0 force-pushed the cs_GqTMcOVI6Y/feature/config-schema-auto-migration branch from 1b9606c to 17a93a6 Compare October 8, 2026 04:31
@xiangfu0
xiangfu0 force-pushed the cs_GqTMcOVI6Y/feature/config-schema-auto-migration branch 2 times, most recently from 2f76230 to 489ad79 Compare October 29, 2026 01:44
@xiangfu0 xiangfu0 changed the title Add versioned auto-migration for table configs and schemas Recommend schema and table config migrations by default Oct 29, 2026
@xiangfu0
xiangfu0 force-pushed the cs_GqTMcOVI6Y/feature/config-schema-auto-migration branch 5 times, most recently from c8bb93e to 7eda583 Compare October 29, 2026 22:39
@xiangfu0
xiangfu0 force-pushed the cs_GqTMcOVI6Y/feature/config-schema-auto-migration branch from 7eda583 to 7ba03eb Compare November 3, 2026 05:57
@xiangfu0
xiangfu0 force-pushed the cs_GqTMcOVI6Y/feature/config-schema-auto-migration branch 2 times, most recently from 60ab38b to 1bc0ed5 Compare November 16, 2026 10:00
Warn and record metrics for legacy definitions. Set cluster config controller.config.migration.auto.update.enabled=true to update both; see pinot-controller/CONFIG_MIGRATION.md.
@xiangfu0
xiangfu0 force-pushed the cs_GqTMcOVI6Y/feature/config-schema-auto-migration branch from 1bc0ed5 to 994e69f Compare November 24, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

configuration Config changes (addition/deletion/change in behavior) extension-point Adds or modifies an extension/SPI point feature New functionality needs-attention Used for sensitive changes - allows searching PRs post release to narrow down causes for regression. release-notes Referenced by PRs that need attention when compiling the next release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants