bug #9058
closedHibernate loggs error when creating schema on MySQL due to failing index creation
100%
Description
Errors are like:
ERROR [main][or.hi.to.hb.SchemaExport:484] - HHH000389: Unsuccessful: create index agentTitleCacheIndex on AgentBase (titleCache) ERROR SchemaExport:485 - Specified key was too long; max key length is 1000 bytes
Related issues
Updated by Andreas Müller almost 4 years ago
- Status changed from New to In Progress
- % Done changed from 0 to 40
Strange is that on some systems this is only logged as warning while others do throw an exception. I did not yet find out if/how this can be configured in MySQL.
Probably it is only a problem on ISAM as InnoDB allows larger indexes if innodb_large_prefix is enabled.
However, the problem can be solved by using a prefix a column prefix key part (https://dev.mysql.com/doc/refman/8.0/en/create-index.html#create-index-column-prefixes).
But the problem is that hibernate in the current version does not support this.
Therefore I created a new IndexExporter (MySqlIsamIndexExporter) which extends the StandardIndexExporter and which is used by the MySQL5MyISAMUtf8Dialect.
This seems to solve the problem.
Only open issues are
- adapt the uniqueKey on AuthorityBase accordingly which spans 4 columns and is a uniquekey => done in #8464
- make it possible to activate holdOnError flag in
SchemaExport
to allow throwing Exceptions if problems occur during SchemaExport, otherwise Users don't get informed in cretain contexts - (related) create schema ddl for tests
Updated by Andreas Müller almost 4 years ago
Updated by Andreas Müller almost 4 years ago
- Related to feature request #8464: Make AuthorityBases unique added
Updated by Andreas Müller almost 4 years ago
- Related to feature request #9025: allow for creating a new schema in empty dbs via the remote login dialog added
Updated by Andreas Müller almost 4 years ago
- Status changed from In Progress to Resolved
- Assignee changed from Andreas Müller to Andreas Kohlbecker
- Priority changed from New to Highest
- % Done changed from 40 to 50
Updated by Andreas Kohlbecker almost 4 years ago
- Assignee changed from Andreas Kohlbecker to Andreas Müller
make it possible to activate holdOnError flag in SchemaExport to allow throwing Exceptions if problems occur during SchemaExport, otherwise Users don't get informed in certain contexts
This seems quite complicated since the SessionFactory
is a final class, but you could try something else:
Create a looging appender org.apache.log4j.Appender
for the logging framework being in use, currently this is log4j and register this apppender. The appender will receive the logging event issued via LOG.unsuccessfulCreate( sqlCommand );
from the logger created as CoreLogging.messageLogger( SchemaExport.class );
. The appender could directly notify the UI when an according LogginEvent is coming in:
SomeEventBus uiEventBus = getUiEventBus();
Logger logger = Logger.getLogger(SchemaExport.class);
logger.addAppender(new AppenderSkeleton() {
@Override
public boolean requiresLayout() {
return false;
}
@Override
public void close() {
// TODO Auto-generated method stub
}
@Override
protected void append(LoggingEvent event) {
if(event.getMessage().toString().startsWith("Unsuccessful: create index")) {
uiEventBus.notify(event.getMessage().toString());
}
}
});
Updated by Andreas Müller almost 4 years ago
- Copied to feature request #9086: Throw exception during schema generation if an exception occurrs added
Updated by Andreas Müller almost 4 years ago
- Status changed from Resolved to Feedback
- Assignee changed from Andreas Müller to Andreas Kohlbecker
I copied the exception handling to a new ticket #9086.
I think the real issue of this ticket (exceptions are thrown in MySQL schema generation) should be solved. Do you agree?
Updated by Andreas Kohlbecker almost 4 years ago
- Status changed from Feedback to Closed
- Assignee changed from Andreas Kohlbecker to Andreas Müller
- % Done changed from 50 to 100
yes in deed!