Project

General

Profile

bug #9058

Hibernate loggs error when creating schema on MySQL due to failing index creation

Added by Andreas Müller 5 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Highest
Category:
cdmlib
Target version:
Start date:
06/09/2020
Due date:
% Done:

100%

Severity:
normal
Found in Version:

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

Related to Edit - feature request #8464: Make AuthorityBases unique New 08/14/2019
Related to Edit - feature request #9025: allow for creating a new schema in empty dbs via the remote login dialog Closed 05/20/2020
Copied to Edit - feature request #9086: Throw exception during schema generation if an exception occurrs New 06/20/2020

Associated revisions

Revision 15bf6961 (diff)
Added by Andreas Müller 5 months ago

fix #9058 fix failing index creation for ordinary MySQL key indexes and remove combined unique key for AuthorityBase

History

#1 Updated by Andreas Müller 5 months ago

  • Description updated (diff)

#2 Updated by Andreas Müller 5 months 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

#4 Updated by Andreas Müller 5 months ago

#5 Updated by Andreas Müller 5 months ago

  • Related to feature request #9025: allow for creating a new schema in empty dbs via the remote login dialog added

#6 Updated by Andreas Müller 5 months 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

#7 Updated by Andreas Kohlbecker 4 months 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());               
        }

    }
});

#8 Updated by Andreas Müller 4 months ago

  • Copied to feature request #9086: Throw exception during schema generation if an exception occurrs added

#9 Updated by Andreas Müller 4 months 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?

#10 Updated by Andreas Kohlbecker 4 months 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!

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 40 MB)