Repository navigation
[2.1] Add the audit log entity-type index before the 2.0.8 audit cleanup (backport 2.1 #38152) - #38154
Conversation
The 2.0.8 post-data script rewrites audit_log_event rows WHERE entity_type = 'user', and the table has no entity_type index before 2.1.0, so each UPDATE scans the whole table. The 2.0.8 Java data migration, which runs before that script, now adds idx_audit_log_entity_type_ts (same name and columns as 2.1.0, which then skips it). The released 2.0.8 SQL is unchanged, so no database that ran it replays anything.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
|
Upgrade run on a real 2.0.7 database, MySQL 8.3 and PostgreSQL 15: fresh database migrated by the released 2.0.7 image, 5,000
|
|
Upgrade test on real release instances, MySQL 8.3 and PostgreSQL 15, using the released Setup: a 2.0.7 server was started and given data through its API (tables, glossary terms, users, bots with JWT tokens, an admin access token). Before the upgrade, 22 of the 32 user audit events it wrote still had
2.1.0's own index statement never errors when the index already exists: on PostgreSQL |
Code Review ✅ Approved 🔴 High riskAdding an audit_log_event index migration changes upgrade-time database structure, and an interrupted or costly build could disrupt upgrades on large audit tables. Adds the VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Fixes #38157
Describe your changes:
Backport of #38152 to
2.1. Same change, no differences.The 2.0.8 post-data script rewrites
audit_log_eventrowsWHERE entity_type = 'user', and the table has noentity_typeindex before 2.1.0, so each UPDATE scans the whole table and a large audit log makes the 2.0.8 upgrade run for hours. The 2.0.8 Java data migration, which runs afterschemaChanges.sqland beforepostDataMigrationSQLScript.sql, now addsidx_audit_log_entity_type_ts(MySQL in place, PostgreSQLCONCURRENTLYwith an INVALID index rebuilt).Type of change:
Tests:
2.1:AuditLogEntityTypeIndexTest(real MySQL 8.3 and PostgreSQL 15)Tests run: 2, Failures: 0, Skipped: 0;WorkflowRedeployEntryPointTestTests run: 2, Failures: 0.mvn clean install -pl openmetadata-service -am -DskipTests: BUILD SUCCESS.Checklist:


Confidence Score: 5/5
The PR appears safe to merge; no blocking issues were found.Summary
The backport adds the audit-log index before the 2.0.8 cleanup without changing released SQL.
The earlier mock-test finding remains withdrawn: sonika-shah explained that the test checks wiring, while separate database tests cover the index behavior.
Reviews (6) · Last reviewed commit: "Document that migration queries on large..." · Reviewed by Greptile