Repository navigation
Fixes #35041: Batch the 2.1.0 creation-audit and DQ dimension backfills by entity id - #35043
Conversation
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
🚦 Removed from the merge queue —
|
Code Review ✅ Approved🔴 High risk · The 2.1.0 batched backfills populate creation-audit fields and dimension relationships, so incorrect ID selection could leave persistent entity metadata inaccurate or incomplete. Batches the 2.1.0 creation-audit and data quality dimension backfills by entity id in groups of 500 via a shared keyset walk, so large tenants no longer hit a single long-running statement that gets killed. No issues found. OptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Describe your changes:
Fixes #35041
The 2.1.0 creation-audit backfill now runs in batches of 500 entity ids instead of one statement per table, so the upgrade finishes on large tenants. The 2.1.0 data-quality dimension backfill, which had the same single-statement shape, uses the same batching.
On sandbox-beta (about 115k tables) the backfill's single
UPDATE … JOIN (ROW_NUMBER() OVER …)over everytable.version.%row inentity_extensionran for minutes and was killed by the database (MySQLQueryInterruptedException: Query execution was interrupted) at the same point on every attempt, because a killed statement keeps none of its work. Undermigrate --forcethe failure is recorded as a step failure, 2.1.0 is still written toSERVER_CHANGE_LOG, but the data migration's identity is not, so the server then refuses to start with "pending migrations: 2.1.0" and no re-run gets past the statement. Some production tenants are larger than sandbox-beta.Type of change:
High-level design:
migration/utils/IdBatches(new):fold(handle, table, identity, step)walks a table's ids by primary-key keyset (id > :afterId ORDER BY id LIMIT 500, neverOFFSET) and foldsstepover each non-empty batch. One place owns the walk, the batch size and the empty-batch guard (a JDBIbindListon an empty list throws).v210/CreationAuditMigration: per batch, one read finds the ids still missingcreatedAt; only those get the two existing passes (oldest version fromentity_extension, then current state), each restricted toid IN (<ids>)so the history read is a primary-key range read. History is ordered by the storedentity_extension.updatedAtcolumn (added in 1.12.0 on both engines, same expression as before) instead of parsing every version's JSON. A batch an earlier, interrupted run already filled costs one read and no history read, so a re-run resumes cheaply.v210/DataQualityDimensionMigration: the existingINSERT … SELECTgainsAND tc.id IN (<ids>)and runs once per batch of test case ids. Its non-fatal catch is unchanged.DataMigrationStep.runOnce); batching removes the reason it failed.OFFSETpaging (re-reads skipped rows, so later pages slow down again);EntityDAO.listAfter(loads every row's full JSON just for the id, and filters ondeleted, while soft-deleted entities need the fields too); per-entity Java like v205OverrideMetadataRestore(one query per entity); making the step non-fatal (hides missing data).runOncemarker exists.ConversationMigrationkeeps its own loop (it reads JSON and filters ontype).docs/decisions/2026-10-09-data-migration-backfills-walk-ids-in-batches.md(ADR:2026-10-09-data-migration-backfills-walk-ids-in-batches), cited fromIdBatches.Tests:
Use cases covered
IN ()statement.createdAt/createdBycome from the oldest stored version, and fall back to the entity's ownupdatedAt/updatedBywhen it has no history.Unit tests
openmetadata-service/src/test/java/org/openmetadata/service/migration/utils/IdBatchesTest.java(new),openmetadata-service/src/test/java/org/openmetadata/service/migration/utils/v210/CreationAuditMigrationTest.java(new).IdBatches100% (17/17 lines),CreationAuditMigration93% (50/54; itsBackfilledandAuditedEntityrecords 100%),DataQualityDimensionMigration0% (covered byDataQualityDimensionMigrationIT, see below).IdBatchesTest.anEmptyTableNeverReachesTheStepandCreationAuditMigrationTest.anEmptyTableIssuesNoBatchStatement; dropping the per-batch "missing" check failsaBatchWithNothingMissingNeverReadsVersionHistory.DataQualityDimensionMigrationhas no unit test: its behavior is unchanged and its SQL runs on both engines inDataQualityDimensionMigrationIT; the batching it now uses isIdBatchesTest's andIdBatchesIT's.Backend integration tests
openmetadata-integration-tests/.IdBatchesIT.java(new: walks a scratch table of 1,001 and 1,000 UUID ids across batch boundaries),CreationAuditMigrationIT.java(addsbackfillReachesSoftDeletedEntities).-Pmysql-elasticsearchdefault and-P postgres-opensearch):CreationAuditMigrationIT5/5 andDataQualityDimensionMigrationIT2/2 on MySQL and on Postgres.IdBatchesIT2/2 on MySQL and on Postgres; changing the cursor toid >= :afterIdmakes it fail.Local Java test run: PASSED
63147b702b03(baseorigin/main)Tests run locally
CreationAuditMigrationTest(2 passed),IdBatchesTest(2 passed)AlertBacklogMigrationIT(2 passed),BaseEntityIT$ListEntityHistoryByTimestampPaginationTest(16 passed, 4 skipped),ConfigResourceIT(13 passed),ContextMemoryStatusMigrationIT(1 passed),ContinuousMigrationIT(3 passed, 1 skipped),CreationAuditMigrationIT(116 passed, 17 skipped),DataProductDomainMigrationIT(41 passed, 2 skipped),DataQualityDimensionMigrationIT(2 passed),DatabaseSmokeIT(1 passed),DbTuneIT(20 passed),GlossaryTermResourceIT(192 passed, 6 skipped),IdBatchesIT(56 passed, 6 skipped),LifeCycleCreatedSentinelMigrationIT(17 passed),OpenMetadataOperationsIT(6 passed),OverrideMetadataRestoreMigrationIT(20 passed, 1 skipped),SampleDataStorageMigrationIT(3 passed),SeedDataPresenceIT(1 passed),ServiceLineagePipelineRoutingMigrationIT(8 passed),TableResourceIT(163 passed, 4 skipped),UserResourceIT(202 passed, 12 skipped)ConversationSchemaMigrationIT(2 passed),MetricMigrationIT(4 passed)Per-class counts come from the test reports, which can credit a test to the wrong class when classes run concurrently, and keep only the last run of a nested class that several test classes inherit. The step totals above are Maven's own counts.
Why these tests
area migrations-seed-data←openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/IdBatches.java,openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v210/CreationAuditMigration.java,openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v210/DataQualityDimensionMigration.javachanged test←openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/CreationAuditMigrationIT.java,openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/IdBatchesIT.java,openmetadata-service/src/test/java/org/openmetadata/service/migration/utils/IdBatchesTest.java,openmetadata-service/src/test/java/org/openmetadata/service/migration/utils/v210/CreationAuditMigrationTest.javasmoke←code other than a test class changedCommands
Ingestion integration tests
Playwright (UI) tests
.github/playwright/impact-map.json; nothing here reaches the UI, so they were not run.Manual testing performed
--memory=2g, 512 MB buffer pool) seeded with 115,000table_entityrows and 345,000table.version.*rows of about 2 KB JSON each.EXPLAINof the history read showstype: range, key: PRIMARY(1,500 rows); the historyUPDATEsets 500 rows in 0.05 s, and the batch's "missing" count goes 500 → 0.UI screen recording / screenshots:
Not applicable.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.ADR:2026-10-09-data-migration-backfills-walk-ids-in-batchesrecords the batching rule and the batch size of 500.