Listen:
By using postgres as a metastore database it could be happen that "drop table xyz" hangs and Postgres is showing LOCKS with UPDATE. This happen since some tables are missing and can be fixed by using:
create index "IDXS_FK1" on "IDXS" using btree ("SD_ID");
create index "IDXS_FK2" on "IDXS" using btree ("INDEX_TBL_ID");
create index "IDXS_FK3" on "IDXS" using btree ("ORIG_TBL_ID");
CREATE TABLE "ROLES" (
"ROLE_ID" bigint NOT NULL,
"CREATE_TIME" int NOT NULL,
"OWNER_NAME" varchar(128) DEFAULT NULL,
"ROLE_NAME" varchar(128) DEFAULT NULL,
PRIMARY KEY ("ROLE_ID"),
CONSTRAINT "ROLEENTITYINDEX" UNIQUE ("ROLE_NAME")
) ;
CREATE TABLE "ROLE_MAP" (
"ROLE_GRANT_ID" bigint NOT NULL,
"ADD_TIME" int NOT NULL,
"GRANT_OPTION" smallint NOT NULL,
"GRANTOR" varchar(128) DEFAULT NULL,
"GRANTOR_TYPE" varchar(128) DEFAULT NULL,
"PRINCIPAL_NAME" varchar(128) DEFAULT NULL,
"PRINCIPAL_TYPE" varchar(128) DEFAULT NULL,
"ROLE_ID" bigint DEFAULT NULL,
PRIMARY KEY ("ROLE_GRANT_ID"),
CONSTRAINT "USERROLEMAPINDEX" UNIQUE ("PRINCIPAL_NAME","ROLE_ID","GRANTOR","GRANTOR_TYPE"),
CONSTRAINT "ROLE_MAP_FK1" FOREIGN KEY ("ROLE_ID") REFERENCES "ROLES" ("ROLE_ID")
) ;
CREATE TABLE "GLOBAL_PRIVS" (
"USER_GRANT_ID" bigint NOT NULL,
"CREATE_TIME" int NOT NULL,
"GRANT_OPTION" smallint NOT NULL,
"GRANTOR" varchar(128) DEFAULT NULL,
"GRANTOR_TYPE" varchar(128) DEFAULT NULL,
"PRINCIPAL_NAME" varchar(128) DEFAULT NULL,
"PRINCIPAL_TYPE" varchar(128) DEFAULT NULL,
"USER_PRIV" varchar(128) DEFAULT NULL,
PRIMARY KEY ("USER_GRANT_ID"),
CONSTRAINT "GLOBALPRIVILEGEINDEX" UNIQUE ("PRINCIPAL_NAME","PRINCIPAL_TYPE","USER_PRIV","GRANTOR","GRANTOR_TYPE")
) ;
CREATE TABLE "DB_PRIVS" (
"DB_GRANT_ID" bigint NOT NULL,
"CREATE_TIME" int NOT NULL,
"DB_ID" bigint DEFAULT NULL,
"GRANT_OPTION" smallint NOT NULL,
"GRANTOR" varchar(128) DEFAULT NULL,
"GRANTOR_TYPE" varchar(128) DEFAULT NULL,
"PRINCIPAL_NAME" varchar(128) DEFAULT NULL,
"PRINCIPAL_TYPE" varchar(128) DEFAULT NULL,
"DB_PRIV" varchar(128) DEFAULT NULL,
PRIMARY KEY ("DB_GRANT_ID"),
CONSTRAINT "DBPRIVILEGEINDEX" UNIQUE ("DB_ID","PRINCIPAL_NAME","PRINCIPAL_TYPE","DB_PRIV","GRANTOR","GRANTOR_TYPE"),
CONSTRAINT "DB_PRIVS_FK1" FOREIGN KEY ("DB_ID") REFERENCES "DBS" ("DB_ID")
) ;
CREATE TABLE "PART_PRIVS" (
"PART_GRANT_ID" bigint NOT NULL,
"CREATE_TIME" int NOT NULL,
"GRANT_OPTION" smallint NOT NULL,
"GRANTOR" varchar(128) DEFAULT NULL,
"GRANTOR_TYPE" varchar(128) DEFAULT NULL,
"PART_ID" bigint DEFAULT NULL,
"PRINCIPAL_NAME" varchar(128) DEFAULT NULL,
"PRINCIPAL_TYPE" varchar(128) DEFAULT NULL,
"PART_PRIV" varchar(128) DEFAULT NULL,
PRIMARY KEY ("PART_GRANT_ID"),
CONSTRAINT "PART_PRIVS_FK1" FOREIGN KEY ("PART_ID") REFERENCES "PARTITIONS" ("PART_ID")
) ;
create index "PARTPRIVILEGEINDEX" on "PART_PRIVS" using btree ("PART_ID","PRINCIPAL_NAME","PRINCIPAL_TYPE","PART_PRIV","GRANTOR","GRANTOR_TYPE");
CREATE TABLE "PART_COL_PRIVS" (
"PART_COLUMN_GRANT_ID" bigint NOT NULL,
"COLUMN_NAME" varchar(128) DEFAULT NULL,
"CREATE_TIME" int NOT NULL,
"GRANT_OPTION" smallint NOT NULL,
"GRANTOR" varchar(128) DEFAULT NULL,
"GRANTOR_TYPE" varchar(128) DEFAULT NULL,
"PART_ID" bigint DEFAULT NULL,
"PRINCIPAL_NAME" varchar(128) DEFAULT NULL,
"PRINCIPAL_TYPE" varchar(128) DEFAULT NULL,
"PART_COL_PRIV" varchar(128) DEFAULT NULL,
PRIMARY KEY ("PART_COLUMN_GRANT_ID"),
CONSTRAINT "PART_COL_PRIVS_FK1" FOREIGN KEY ("PART_ID") REFERENCES "PARTITIONS" ("PART_ID")
);
create index "PARTITIONCOLUMNPRIVILEGEINDEX" on "PART_COL_PRIVS" using btree ("PART_ID","COLUMN_NAME","PRINCIPAL_NAME","PRINCIPAL_TYPE","PART_COL_PRIV","GRANTOR","GRANTOR_TYPE")
Paste this into the pgsql CLI on your metastore database (psql -h <HOSTNAME> -d metastore -U hiveuser -W) and you should be able to drop tables.
create index "IDXS_FK1" on "IDXS" using btree ("SD_ID");
create index "IDXS_FK2" on "IDXS" using btree ("INDEX_TBL_ID");
create index "IDXS_FK3" on "IDXS" using btree ("ORIG_TBL_ID");
CREATE TABLE "ROLES" (
"ROLE_ID" bigint NOT NULL,
"CREATE_TIME" int NOT NULL,
"OWNER_NAME" varchar(128) DEFAULT NULL,
"ROLE_NAME" varchar(128) DEFAULT NULL,
PRIMARY KEY ("ROLE_ID"),
CONSTRAINT "ROLEENTITYINDEX" UNIQUE ("ROLE_NAME")
) ;
CREATE TABLE "ROLE_MAP" (
"ROLE_GRANT_ID" bigint NOT NULL,
"ADD_TIME" int NOT NULL,
"GRANT_OPTION" smallint NOT NULL,
"GRANTOR" varchar(128) DEFAULT NULL,
"GRANTOR_TYPE" varchar(128) DEFAULT NULL,
"PRINCIPAL_NAME" varchar(128) DEFAULT NULL,
"PRINCIPAL_TYPE" varchar(128) DEFAULT NULL,
"ROLE_ID" bigint DEFAULT NULL,
PRIMARY KEY ("ROLE_GRANT_ID"),
CONSTRAINT "USERROLEMAPINDEX" UNIQUE ("PRINCIPAL_NAME","ROLE_ID","GRANTOR","GRANTOR_TYPE"),
CONSTRAINT "ROLE_MAP_FK1" FOREIGN KEY ("ROLE_ID") REFERENCES "ROLES" ("ROLE_ID")
) ;
CREATE TABLE "GLOBAL_PRIVS" (
"USER_GRANT_ID" bigint NOT NULL,
"CREATE_TIME" int NOT NULL,
"GRANT_OPTION" smallint NOT NULL,
"GRANTOR" varchar(128) DEFAULT NULL,
"GRANTOR_TYPE" varchar(128) DEFAULT NULL,
"PRINCIPAL_NAME" varchar(128) DEFAULT NULL,
"PRINCIPAL_TYPE" varchar(128) DEFAULT NULL,
"USER_PRIV" varchar(128) DEFAULT NULL,
PRIMARY KEY ("USER_GRANT_ID"),
CONSTRAINT "GLOBALPRIVILEGEINDEX" UNIQUE ("PRINCIPAL_NAME","PRINCIPAL_TYPE","USER_PRIV","GRANTOR","GRANTOR_TYPE")
) ;
CREATE TABLE "DB_PRIVS" (
"DB_GRANT_ID" bigint NOT NULL,
"CREATE_TIME" int NOT NULL,
"DB_ID" bigint DEFAULT NULL,
"GRANT_OPTION" smallint NOT NULL,
"GRANTOR" varchar(128) DEFAULT NULL,
"GRANTOR_TYPE" varchar(128) DEFAULT NULL,
"PRINCIPAL_NAME" varchar(128) DEFAULT NULL,
"PRINCIPAL_TYPE" varchar(128) DEFAULT NULL,
"DB_PRIV" varchar(128) DEFAULT NULL,
PRIMARY KEY ("DB_GRANT_ID"),
CONSTRAINT "DBPRIVILEGEINDEX" UNIQUE ("DB_ID","PRINCIPAL_NAME","PRINCIPAL_TYPE","DB_PRIV","GRANTOR","GRANTOR_TYPE"),
CONSTRAINT "DB_PRIVS_FK1" FOREIGN KEY ("DB_ID") REFERENCES "DBS" ("DB_ID")
) ;
CREATE TABLE "PART_PRIVS" (
"PART_GRANT_ID" bigint NOT NULL,
"CREATE_TIME" int NOT NULL,
"GRANT_OPTION" smallint NOT NULL,
"GRANTOR" varchar(128) DEFAULT NULL,
"GRANTOR_TYPE" varchar(128) DEFAULT NULL,
"PART_ID" bigint DEFAULT NULL,
"PRINCIPAL_NAME" varchar(128) DEFAULT NULL,
"PRINCIPAL_TYPE" varchar(128) DEFAULT NULL,
"PART_PRIV" varchar(128) DEFAULT NULL,
PRIMARY KEY ("PART_GRANT_ID"),
CONSTRAINT "PART_PRIVS_FK1" FOREIGN KEY ("PART_ID") REFERENCES "PARTITIONS" ("PART_ID")
) ;
create index "PARTPRIVILEGEINDEX" on "PART_PRIVS" using btree ("PART_ID","PRINCIPAL_NAME","PRINCIPAL_TYPE","PART_PRIV","GRANTOR","GRANTOR_TYPE");
CREATE TABLE "PART_COL_PRIVS" (
"PART_COLUMN_GRANT_ID" bigint NOT NULL,
"COLUMN_NAME" varchar(128) DEFAULT NULL,
"CREATE_TIME" int NOT NULL,
"GRANT_OPTION" smallint NOT NULL,
"GRANTOR" varchar(128) DEFAULT NULL,
"GRANTOR_TYPE" varchar(128) DEFAULT NULL,
"PART_ID" bigint DEFAULT NULL,
"PRINCIPAL_NAME" varchar(128) DEFAULT NULL,
"PRINCIPAL_TYPE" varchar(128) DEFAULT NULL,
"PART_COL_PRIV" varchar(128) DEFAULT NULL,
PRIMARY KEY ("PART_COLUMN_GRANT_ID"),
CONSTRAINT "PART_COL_PRIVS_FK1" FOREIGN KEY ("PART_ID") REFERENCES "PARTITIONS" ("PART_ID")
);
create index "PARTITIONCOLUMNPRIVILEGEINDEX" on "PART_COL_PRIVS" using btree ("PART_ID","COLUMN_NAME","PRINCIPAL_NAME","PRINCIPAL_TYPE","PART_COL_PRIV","GRANTOR","GRANTOR_TYPE")
Paste this into the pgsql CLI on your metastore database (psql -h <HOSTNAME> -d metastore -U hiveuser -W) and you should be able to drop tables.
Comments
Post a Comment