-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: Move version metadata migration to 2.0.0 and remove crashing MySQL multi-valued index #27816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
338fdf8
7c3afeb
322436a
14cb78e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,8 +5,10 @@ | |||||||||||||||||||
| import java.nio.charset.StandardCharsets; | ||||||||||||||||||||
| import java.util.ArrayList; | ||||||||||||||||||||
| import java.util.Collections; | ||||||||||||||||||||
| import java.util.LinkedHashSet; | ||||||||||||||||||||
| import java.util.List; | ||||||||||||||||||||
| import java.util.Map; | ||||||||||||||||||||
| import java.util.Set; | ||||||||||||||||||||
| import java.util.UUID; | ||||||||||||||||||||
| import lombok.extern.slf4j.Slf4j; | ||||||||||||||||||||
| import org.jdbi.v3.core.Handle; | ||||||||||||||||||||
|
|
@@ -25,6 +27,7 @@ | |||||||||||||||||||
| import org.openmetadata.service.jdbi3.CollectionDAO; | ||||||||||||||||||||
| import org.openmetadata.service.jdbi3.locator.ConnectionType; | ||||||||||||||||||||
| import org.openmetadata.service.migration.utils.SearchSettingsMergeUtil; | ||||||||||||||||||||
| import org.openmetadata.service.resources.databases.DatasourceConfig; | ||||||||||||||||||||
| import org.openmetadata.service.resources.feeds.MessageParser; | ||||||||||||||||||||
| import org.openmetadata.service.util.EntityUtil; | ||||||||||||||||||||
| import org.openmetadata.service.util.FullyQualifiedName; | ||||||||||||||||||||
|
|
@@ -34,6 +37,20 @@ public class MigrationUtil { | |||||||||||||||||||
|
|
||||||||||||||||||||
| private static final String TABLE_COLUMN_ASSET_TYPE = "tableColumn"; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| private static final int BATCH_SIZE = 1000; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| private static final String UPDATE_MYSQL = | ||||||||||||||||||||
| "UPDATE entity_extension SET versionNum = :versionNum, changedFieldKeys = :changedFieldKeys " | ||||||||||||||||||||
| + "WHERE id = :id AND extension = :extension"; | ||||||||||||||||||||
|
Comment on lines
+41
to
+45
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| private static final String UPDATE_POSTGRES = | ||||||||||||||||||||
| "UPDATE entity_extension SET versionNum = :versionNum, changedFieldKeys = :changedFieldKeys::jsonb " | ||||||||||||||||||||
| + "WHERE id = :id AND extension = :extension"; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| private static final String UPDATE_VERSION_NUM_ONLY = | ||||||||||||||||||||
| "UPDATE entity_extension SET versionNum = :versionNum " | ||||||||||||||||||||
| + "WHERE id = :id AND extension = :extension"; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| private MigrationUtil() {} | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public static void addTableColumnSearchSettings() { | ||||||||||||||||||||
|
|
@@ -1341,4 +1358,124 @@ private static void insertTaskDomainRelationships( | |||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public static void backfillVersionMetadata(Handle handle) { | ||||||||||||||||||||
| String updateSql = | ||||||||||||||||||||
| Boolean.TRUE.equals(DatasourceConfig.getInstance().isMySQL()) | ||||||||||||||||||||
| ? UPDATE_MYSQL | ||||||||||||||||||||
| : UPDATE_POSTGRES; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| LOG.info("Starting backfill of versionNum and changedFieldKeys in entity_extension"); | ||||||||||||||||||||
| int totalProcessed = 0; | ||||||||||||||||||||
| List<Map<String, Object>> batch; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| do { | ||||||||||||||||||||
| batch = | ||||||||||||||||||||
| handle | ||||||||||||||||||||
| .createQuery( | ||||||||||||||||||||
| "SELECT id, extension, json FROM entity_extension " | ||||||||||||||||||||
| + "WHERE extension LIKE '%.version.%' " | ||||||||||||||||||||
| + "AND versionNum IS NULL " | ||||||||||||||||||||
| + "LIMIT :limit") | ||||||||||||||||||||
|
gitar-bot[bot] marked this conversation as resolved.
Comment on lines
+1378
to
+1382
|
||||||||||||||||||||
| + "WHERE (id, extension) > (:lastId, :lastExt) " | |
| + "ORDER BY id, extension " | |
| + "LIMIT :limit") | |
| + "WHERE versionNum IS NULL " | |
| + "AND extension LIKE :extensionPattern " | |
| + "AND (id, extension) > (:lastId, :lastExt) " | |
| + "ORDER BY id, extension " | |
| + "LIMIT :limit") | |
| .bind("extensionPattern", "%.version.%") |
Uh oh!
There was an error while loading. Please reload this page.