[WIP] HIVE-29668: Add -rebuildIndexes utility to reconstruct backend Metastore indexes#6545
[WIP] HIVE-29668: Add -rebuildIndexes utility to reconstruct backend Metastore indexes#6545soumyakanti3578 wants to merge 3 commits into
Conversation
| @Override | ||
| public void rebuildIndex(IndexInfo index) throws HiveMetaException { | ||
| PgDdl ddl = ddlMap.get(index.indexName()); | ||
| executeRebuild(index, ddl.dropDdl(), ddl.createDdl()); |
There was a problem hiding this comment.
I think, drop+create ddl should be atomic.
For constraint-backed indexes (PKs and UNIQUE constraints), the Postgres path runs two separate DDL statements: DROP CONSTRAINT followed by ADD CONSTRAINT. If the connection has autocommit enabled and the second statement fails, the constraint is permanently dropped with no rollback. It would be safer to ensure these two steps run inside an explicit BEGIN/COMMIT block, or autocommit=false.
There was a problem hiding this comment.
Thanks, I have fixed this in the latest commit.
| .withDescription("Create table for Hive warehouse/compute logs") | ||
| .create("createLogsTable"); | ||
| Option rebuildIndexesOpt = new Option("rebuildIndexes", | ||
| "Detect and rebuild corrupt indexes in the metastore backend DB (Postgres only)."); |
There was a problem hiding this comment.
I think we are supporting all DB's, we can remove this "Postgres only" otherwise it can confuse.
There was a problem hiding this comment.
Yes, somehow missed this after my POC with postgres only. Thanks for noticing!
| } | ||
|
|
||
| @Override | ||
| public @NotNull String toString() { |
There was a problem hiding this comment.
Do we need @NotNull annotation here ? I think, record will never return null.
There was a problem hiding this comment.
Removed it.
|



What changes were proposed in this pull request?
Support
-rebuildIndexesthrough schematool for Postgres, Oracle, MySql/MariaDB, and MSSQLWhy are the changes needed?
Gives users the ability to drop and recreate indexes easily through schematool.
Does this PR introduce any user-facing change?
Yes, adds a new option to schematool
How was this patch tested?