Skip to content

Commit

Permalink
[KYUUBI apache#6066] Fix PostgreSQL metastore migration script failur…
Browse files Browse the repository at this point in the history
…e if indexes already exist

# 🔍 Description
## Issue References 🔗

This pull request is a small fix for apache#5674

## Describe Your Solution 🔧

PostgreSQL support as backend for metadata store was added in apache#6027. If we choose it and run schema init scripts several times, then the following errors will be logged: `Error executing sql: CREATE UNIQUE INDEX unique_identifier_index ON metadata(identifier), with params: . ERROR: relation "unique_identifier_index" already exists`. This PR adds lacking `IF NOT EXISTS` to db indexes creation ddls in the PostgreSQL metastore init script.

## Types of changes 🔖

- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Test Plan 🧪

#### Behavior Without This Pull Request ⚰️

#### Behavior With This Pull Request 🎉

#### Related Unit Tests

---

# Checklist 📝

- [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)

Closes apache#6066 from tigrulya-exe/feature/5674-postgresql-metadata-backend.

Closes apache#6066

bb6487c [Tigran Manasyan] Fix PostgreSQL metastore migration script failure if indexes already exist

Authored-by: Tigran Manasyan <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
  • Loading branch information
tigrulya-exe authored and zhaohehuhu committed Mar 21, 2024
1 parent 7a13234 commit b6a2880
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ COMMENT ON COLUMN metadata.end_time IS 'the metadata end time';
COMMENT ON COLUMN metadata.priority IS 'the application priority, high value means high priority';
COMMENT ON COLUMN metadata.peer_instance_closed IS 'closed by peer kyuubi instance';

CREATE UNIQUE INDEX unique_identifier_index ON metadata(identifier);
CREATE INDEX user_name_index ON metadata(user_name);
CREATE INDEX engine_type_index ON metadata(engine_type);
CREATE INDEX create_time_index ON metadata(create_time);
CREATE INDEX priority_create_time_index ON metadata(priority DESC, create_time ASC);
CREATE UNIQUE INDEX IF NOT EXISTS unique_identifier_index ON metadata(identifier);
CREATE INDEX IF NOT EXISTS user_name_index ON metadata(user_name);
CREATE INDEX IF NOT EXISTS engine_type_index ON metadata(engine_type);
CREATE INDEX IF NOT EXISTS create_time_index ON metadata(create_time);
CREATE INDEX IF NOT EXISTS priority_create_time_index ON metadata(priority DESC, create_time ASC);

0 comments on commit b6a2880

Please sign in to comment.