Details
-
Bug
-
Status: Closed (View Workflow)
-
P3
-
Resolution: Done
-
3.7.0
-
-
eHoldings Sprint 117
-
1
-
Spitfire
-
R2 2021 Bugfix
-
OTHER
Description
mod-kb-ebsco-java 3.7.0 fails to create schema in multi tenant environment where older version is enable on another tenant. . Observed missing relations on schema for newly created Iris tenant.
During tenant init, we see this error:
TION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('MODKBEKBJ-444@@remove-duplicate-check-on-access-types-mappings', 'dmtkachenko', 'liquibase/tenant/scripts/v3.5.2/alter-access-type-mapping-table.xml', NOW(), 86, '8:a443a2e8e4f3eb9ae2149e05356f97f2', 'sql', '', 'EXECUTED', NULL, NULL, '3.8.9', '4382890806') 17:28:11 [] [] [] [] INFO Slf4jLogger SELECT count(1) FROM pg_constraint WHERE conname = 'access_types_mapping_pkey' AND contype = 'p' 17:28:11 [] [] [] [] INFO Slf4jLogger ALTER TABLE holycross_mod_kb_ebsco_java.access_types_mappings DROP CONSTRAINT access_types_mapping_pkey 17:28:11 [] [] [] [] ERROR Slf4jLogger Change Set liquibase/tenant/scripts/v3.5.2/alter-access-type-mapping-table.xml::MODKBEKBJ-452@@rename-access-types-mappings-primary-key::dmtkachenko failed. Error: ERROR: constraint "access_types_mapping_pkey" of relation "access_types_mappings" does not exist [Failed SQL: (0) ALTER TABLE holycross_mod_kb_ebsco_java.access_types_mappings DROP CONSTRAINT access_types_mapping_pkey] 17:28:11 [] [] [] [] INFO Slf4jLogger Successfully released change log lock 17:28:11 [] [] [] [] ERROR LiquibaseUtil Error while initializing schema holycross_mod_kb_ebsco_java for tenant holycross liquibase.exception.MigrationFailedException: Migration failed for change set liquibase/tenant/scripts/v3.5.2/alter-access-type-mapping-table.xml::MODKBEKBJ-452@@rename-access-types-mappings-primary-key::dmtkachenko: Reason: liquibase.exception.DatabaseException: ERROR: constraint "access_types_mapping_pkey" of relation "access_types_mappings" does not exist [Failed SQL: (0) ALTER TABLE holycross_mod_kb_ebsco_java.access_types_mappings DROP CONSTRAINT access_types_mapping_pkey]
It appears that the alter-access-types-mappings-primary-key migration is trying to run even though there is no constraint to be dropped/updated because it's a new tenant. This condition is giving a false positive because a constraint exists for a different tenant: https://github.com/folio-org/mod-kb-ebsco-java/blob/241655d0fc215b880a6696ee978af5867fc8afe4/src/main/resources/liquibase/tenant/scripts/v3.5.2/alter-access-type-mapping-table.xml#L19
I can see this by running the test myself, and getting the corresponding schema name from the the pg_constraint table:
shared_test=> select * from pg_constraint ; shared_test=> SELECT count(1) FROM pg_constraint shared_test-> WHERE conname = 'access_types_mapping_pkey' shared_test-> AND contype = 'p'; -[ RECORD 1 ] count | 1
shared_test=> select n.nspname as schema_name, t.relname as table_name, c.conname as constraint_name from pg_constraint c join pg_class t on c.conrelid = t.oid join pg_namespace n on t.relnamespace = n.oid where c.conname = 'access_types_mapping_pkey'; -[ RECORD 1 ]---+-------------------------- schema_name | sim_mod_kb_ebsco_java table_name | access_types_mappings constraint_name | access_types_mapping_pkey
Can the condition be updated to only call the migration if the constraint exists for the same tenant?