Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

org.mariadb.jdbc.internal.util.dao.QueryException: Failed to add the foreign key constraint. Missing index for constraint

Highlighted

org.mariadb.jdbc.internal.util.dao.QueryException: Failed to add the foreign key constraint. Missing index for constraint

New Contributor

While installing hortonworks Schema Registry, when I run
`./bootstrap/bootstrap-storage.sh`

I get error:
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Menlo; color: #000000; background-color: #171717; background-color: rgba(23, 23, 23, 0.6)} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Menlo; color: #000000; background-color: #171717; background-color: rgba(23, 23, 23, 0.6); min-height: 15.0px} span.s1 {font-variant-ligatures: no-common-ligatures} span.Apple-tab-span {white-space:pre}

Using Configuration file: ./bootstrap/../conf/registry.yaml

######## SQL Query:-- Copyright 2016 Hortonworks.

--

-- Licensed under the Apache License, Version 2.0 (the "License")

######## Query executed

######## SQL Query:-- you may not use this file except in compliance with the License.

-- You may obtain a copy of the License at

--

--http://www.apache.org/licenses/LICENSE-2.0

--

-- Unless required by applicable law or agreed to in writing, software

-- distributed under the License is distributed on an "AS IS" BASIS,

-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

-- See the License for the specific language governing permissions and

-- limitations under the License.

-- THE NAMES OF THE TABLE COLUMNS MUST MATCH THE NAMES OF THE CORRESPONDING CLASS MODEL FIELDS

CREATE TABLE IF NOT EXISTS schema_metadata_info (

idBIGINT AUTO_INCREMENT NOT NULL,

typeVARCHAR(256)NOT NULL,

schemaGroup VARCHAR(256)NOT NULL,

nameVARCHAR(256)NOT NULL,

compatibility VARCHAR(256)NOT NULL,

description TEXT,

evolveBOOLEAN NOT NULL,

timestamp BIGINTNOT NULL,

PRIMARY KEY (name),

UNIQUE KEY (id)

)

######## Query executed

######## SQL Query:CREATE TABLE IF NOT EXISTS schema_version_info (

id BIGINT AUTO_INCREMENT NOT NULL,

descriptionTEXT,

schemaText TEXTNOT NULL,

fingerprintTEXTNOT NULL,

versionINT NOT NULL,

schemaMetadataId BIGINTNOT NULL,

timestampBIGINTNOT NULL,

name VARCHAR(256)NOT NULL,

UNIQUE KEY (id),

UNIQUE KEY `UK_METADATA_ID_VERSION_FK` (schemaMetadataId, version),

PRIMARY KEY (name, version),

FOREIGN KEY (schemaMetadataId, name) REFERENCES schema_metadata_info (id, name)

)

Exception in thread "main" java.sql.SQLException: (conn:21) Failed to add the foreign key constraint. Missing index for constraint 'schema_version_info_ibfk_1' in the referenced table 'schema_metadata_info'

Query is : CREATE TABLE IF NOT EXISTS schema_version_info (

id BIGINT AUTO_INCREMENT NOT NULL,

descriptionTEXT,

schemaText TEXTNOT NULL,

fingerprintTEXTNOT NULL,

versionINT NOT NULL,

schemaMetadataId BIGINTNOT NULL,

timestampBIGINTNOT NULL,

name VARCHAR(256)NOT NULL,

UNIQUE KEY (id),

UNIQUE KEY `UK_METADATA_ID_VERSION_FK` (schemaMetadataId, version),

PRIMARY KEY (name, version),

FOREIGN KEY (schemaMetadataId, name) REFERENCES schema_metadata_info (id, name)

)

at org.mariadb.jdbc.internal.util.ExceptionMapper.get(ExceptionMapper.java:145)

at org.mariadb.jdbc.internal.util.ExceptionMapper.getException(ExceptionMapper.java:101)

at org.mariadb.jdbc.internal.util.ExceptionMapper.throwAndLogException(ExceptionMapper.java:77)

at org.mariadb.jdbc.MariaDbStatement.executeQueryEpilog(MariaDbStatement.java:224)

at org.mariadb.jdbc.MariaDbStatement.executeInternal(MariaDbStatement.java:258)

at org.mariadb.jdbc.MariaDbStatement.execute(MariaDbStatement.java:271)

at com.hortonworks.registries.storage.tool.SQLScriptRunner.runScript(SQLScriptRunner.java:98)

at com.hortonworks.registries.storage.tool.TablesInitializer.doExecute(TablesInitializer.java:198)

at com.hortonworks.registries.storage.tool.TablesInitializer.doExecuteCreate(TablesInitializer.java:175)

at com.hortonworks.registries.storage.tool.TablesInitializer.main(TablesInitializer.java:162)

Caused by: org.mariadb.jdbc.internal.util.dao.QueryException: Failed to add the foreign key constraint. Missing index for constraint 'schema_version_info_ibfk_1' in the referenced table 'schema_metadata_info'

Query is : CREATE TABLE IF NOT EXISTS schema_version_info (

id BIGINT AUTO_INCREMENT NOT NULL,

descriptionTEXT,

schemaText TEXTNOT NULL,

fingerprintTEXTNOT NULL,

versionINT NOT NULL,

schemaMetadataId BIGINTNOT NULL,

timestampBIGINTNOT NULL,

name VARCHAR(256)NOT NULL,

UNIQUE KEY (id),

UNIQUE KEY `UK_METADATA_ID_VERSION_FK` (schemaMetadataId, version),

PRIMARY KEY (name, version),

FOREIGN KEY (schemaMetadataId, name) REFERENCES schema_metadata_info (id, name)

)

at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.getResult(AbstractQueryProtocol.java:1114)

at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.executeQuery(AbstractQueryProtocol.java:137)

at org.mariadb.jdbc.MariaDbStatement.executeInternal(MariaDbStatement.java:249)

... 5 more