Mass Indexer HSEARCH000058 ArrayIndexOutOfBoundsException

My Mass Indexer goes to 97.28%, not 100%

This is the initial error:

HSEARCH000058: Exception occurred java.lang.ArrayIndexOutOfBoundsException: Index 162 out of bounds for length 162

Apparently some entities cannot be loaded? Why can’t I index all the entities? What am I doing wrong? What can I improve?

Failing operation:
Loading and extracting entity data for entity 'Story' during mass indexing
**Entities that could not be indexed correctly:**
**Story#690 Story#691 Story#692 Story#693 Story#694 Story#695 Story#696 Story#697 Story#698 Story#699 Story#700 Story#701 Story#702 Story#703**
java.lang.ArrayIndexOutOfBoundsException: Index 162 out of bounds for length 162

I receive this error at the end of the stacktrace:

Preformatted text`Failed to load data from database with error: [Ljava.lang.StackTraceElement;@1b557402
12-03-2024 19:06:31.906 [main] INFO  com.islamophobia.io.config.search.HibernateSearchIndexBuild.onApplicationEvent - *********** Started Initializing Indexes ***********
12-03-2024 19:06:32.045 [Hibernate Search - Mass indexing - Story - ID loading - 0] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.addToTotalCount - HSEARCH000027: Mass indexing is going to index 514 entities.
12-03-2024 19:06:32.154 [Hibernate Search - Mass indexing - Story - Entity loading - 5] ERROR org.hibernate.search.engine.reporting.impl.LogFailureHandler.handle - HSEARCH000058: Exception occurred java.lang.ArrayIndexOutOfBoundsException: Index 162 out of bounds for length 162
Failing operation:
Loading and extracting entity data for entity 'Story' during mass indexing
Entities that could not be indexed correctly:
Story#690 Story#691 Story#692 Story#693 Story#694 Story#695 Story#696 Story#697 Story#698 Story#699 Story#700 Story#701 Story#702 Story#703
java.lang.ArrayIndexOutOfBoundsException: Index 162 out of bounds for length 162
        at org.hibernate.type.descriptor.java.EnumJavaType.fromShort(EnumJavaType.java:192)
        at org.hibernate.type.descriptor.java.EnumJavaType.wrap(EnumJavaType.java:116)
        at org.hibernate.type.descriptor.java.EnumJavaType.wrap(EnumJavaType.java:33)
        at org.hibernate.type.descriptor.jdbc.SmallIntJdbcType$2.doExtract(SmallIntJdbcType.java:87)
        at org.hibernate.type.descriptor.jdbc.BasicExtractor.extract(BasicExtractor.java:44)
        at org.hibernate.sql.results.jdbc.internal.JdbcValuesResultSetImpl.getCurrentRowValue(JdbcValuesResultSetImpl.java:302)
        at org.hibernate.sql.results.internal.RowProcessingStateStandardImpl.getJdbcValue(RowProcessingStateStandardImpl.java:119)
        at org.hibernate.sql.results.graph.basic.BasicResultAssembler.extractRawValue(BasicResultAssembler.java:52)
        at org.hibernate.sql.results.graph.basic.BasicResultAssembler.assemble(BasicResultAssembler.java:59)
        at org.hibernate.sql.results.graph.DomainResultAssembler.assemble(DomainResultAssembler.java:33)
        at org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.extractConcreteTypeStateValues(AbstractEntityInitializer.java:1081)
        at org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.initializeEntityInstance(AbstractEntityInitializer.java:838)
        at org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.initializeEntity(AbstractEntityInitializer.java:813)
        at org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.initializeInstance(AbstractEntityInitializer.java:799)
        at org.hibernate.sql.results.internal.InitializersList.initializeInstance(InitializersList.java:70)
        at org.hibernate.sql.results.internal.StandardRowReader.coordinateInitializers(StandardRowReader.java:109)
        at org.hibernate.sql.results.internal.StandardRowReader.readRow(StandardRowReader.java:86)
        at org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:181)
        at org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:33)
        at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.doExecuteQuery(JdbcSelectExecutorStandardImpl.java:209)
        at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.executeQuery(JdbcSelectExecutorStandardImpl.java:83)
        at org.hibernate.sql.exec.spi.JdbcSelectExecutor.list(JdbcSelectExecutor.java:76)
        at org.hibernate.sql.exec.spi.JdbcSelectExecutor.list(JdbcSelectExecutor.java:65)
        at org.hibernate.loader.ast.internal.MultiIdEntityLoaderStandard.loadEntitiesById(MultiIdEntityLoaderStandard.java:266)
        at org.hibernate.loader.ast.internal.MultiIdEntityLoaderStandard.performOrderedMultiLoad(MultiIdEntityLoaderStandard.java:161)
        at org.hibernate.loader.ast.internal.AbstractMultiIdEntityLoader.load(AbstractMultiIdEntityLoader.java:55)
        at org.hibernate.persister.entity.AbstractEntityPersister.multiLoad(AbstractEntityPersister.java:3824)
        at org.hibernate.internal.MultiIdentifierLoadAccessImpl.lambda$multiLoad$1(MultiIdentifierLoadAccessImpl.java:173)
        at org.hibernate.internal.MultiIdentifierLoadAccessImpl.perform(MultiIdentifierLoadAccessImpl.java:151)
        at org.hibernate.internal.MultiIdentifierLoadAccessImpl.multiLoad(MultiIdentifierLoadAccessImpl.java:173)
        at org.hibernate.search.mapper.orm.loading.impl.HibernateOrmMassEntityLoader.multiLoad(HibernateOrmMassEntityLoader.java:63)
        at org.hibernate.search.mapper.orm.loading.impl.HibernateOrmMassEntityLoader.load(HibernateOrmMassEntityLoader.java:49)
        at org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingEntityLoadingRunnable.runWithFailureHandler(PojoMassIndexingEntityLoadingRunnable.java:73)
        at org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingFailureHandledRunnable.run(PojoMassIndexingFailureHandledRunnable.java:38)
        at org.hibernate.search.util.common.impl.CancellableExecutionCompletableFuture$CompletingRunnable.run(CancellableExecutionCompletableFuture.java:70)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at java.base/java.lang.Thread.run(Thread.java:1583)
12-03-2024 19:06:32.253 [Hibernate Search - Mass indexing - Story - Entity loading - 4] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000030: Mass indexing progress: indexed 50 entities in 7 ms.
12-03-2024 19:06:32.253 [Hibernate Search - Mass indexing - Story - Entity loading - 4] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000031: Mass indexing progress: 9.73%. Mass indexing speed: 0.003184 documents/second since last message, 6714.293457 documents/second since start.
12-03-2024 19:06:32.274 [Hibernate Search - Mass indexing - Story - Entity loading - 3] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000030: Mass indexing progress: indexed 100 entities in 23 ms.
12-03-2024 19:06:32.274 [Hibernate Search - Mass indexing - Story - Entity loading - 3] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000031: Mass indexing progress: 19.46%. Mass indexing speed: 3129.243896 documents/second since last message, 4268.925293 documents/second since start.
12-03-2024 19:06:32.289 [Hibernate Search - Mass indexing - Story - Entity loading - 2] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000030: Mass indexing progress: indexed 150 entities in 37 ms.
12-03-2024 19:06:32.289 [Hibernate Search - Mass indexing - Story - Entity loading - 2] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000031: Mass indexing progress: 29.18%. Mass indexing speed: 3451.989746 documents/second since last message, 3956.791748 documents/second since start.
12-03-2024 19:06:32.298 [Hibernate Search - Mass indexing - Story - Entity loading - 6] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000030: Mass indexing progress: indexed 200 entities in 39 ms.
12-03-2024 19:06:32.298 [Hibernate Search - Mass indexing - Story - Entity loading - 6] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000031: Mass indexing progress: 38.91%. Mass indexing speed: 34052.984375 documents/second since last message, 5079.003906 documents/second since start.
12-03-2024 19:06:32.298 [Hibernate Search - Mass indexing - Story - Entity loading - 3] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000030: Mass indexing progress: indexed 250 entities in 41 ms.
12-03-2024 19:06:32.298 [Hibernate Search - Mass indexing - Story - Entity loading - 3] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000031: Mass indexing progress: 48.64%. Mass indexing speed: 21153.275391 documents/second since last message, 5989.243164 documents/second since start.
12-03-2024 19:06:32.298 [Hibernate Search - Mass indexing - Story - Entity loading - 2] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000030: Mass indexing progress: indexed 300 entities in 44 ms.
12-03-2024 19:06:32.298 [Hibernate Search - Mass indexing - Story - Entity loading - 2] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000031: Mass indexing progress: 58.37%. Mass indexing speed: 20074.677734 documents/second since last message, 6782.389160 documents/second since start.
12-03-2024 19:06:32.306 [Hibernate Search - Mass indexing - Story - Entity loading - 10] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000030: Mass indexing progress: indexed 350 entities in 47 ms.
12-03-2024 19:06:32.306 [Hibernate Search - Mass indexing - Story - Entity loading - 10] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000031: Mass indexing progress: 68.09%. Mass indexing speed: 16413.353516 documents/second since last message, 7402.941895 documents/second since start.
12-03-2024 19:06:32.306 [Hibernate Search - Mass indexing - Story - Entity loading - 7] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000030: Mass indexing progress: indexed 400 entities in 54 ms.
12-03-2024 19:06:32.306 [Hibernate Search - Mass indexing - Story - Entity loading - 7] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000031: Mass indexing progress: 77.82%. Mass indexing speed: 6624.183594 documents/second since last message, 7295.728516 documents/second since start.
12-03-2024 19:06:32.306 [Hibernate Search - Mass indexing - Story - Entity loading - 11] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000030: Mass indexing progress: indexed 450 entities in 57 ms.
12-03-2024 19:06:32.306 [Hibernate Search - Mass indexing - Story - Entity loading - 8] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000030: Mass indexing progress: indexed 500 entities in 57 ms.
12-03-2024 19:06:32.306 [Hibernate Search - Mass indexing - Story - Entity loading - 11] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000031: Mass indexing progress: 87.55%. Mass indexing speed: 18815.382813 documents/second since last message, 7828.265137 documents/second since start.
12-03-2024 19:06:32.306 [Hibernate Search - Mass indexing - Story - Entity loading - 8] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.printStatusMessage - HSEARCH000031: Mass indexing progress: 97.28%. Mass indexing speed: 141763.531250 documents/second since last message, 8645.030273 documents/second since start.
12-03-2024 19:06:32.768 [main] INFO  org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingLoggingMonitor.indexingCompleted - HSEARCH000028: Mass indexing complete. Indexed 514 entities.
12-03-2024 19:06:32.768 [main] WARN  com.islamophobia.io.config.search.HibernateSearchIndexBuild.onApplicationEvent - Failed to load data from database with error: [Ljava.lang.StackTraceElement;@1b557402
12-03-2024 19:06:32.768 [main] INFO  com.islamophobia.io.config.search.HibernateSearchIndexBuild.onApplicationEvent - Completed Indexing


As you can see from the stack trace, the error comes from ORM loading an entity from the database. You’ll have to look at your entity. In particular, it seems that you have an enum in it, and most likely, it was modified (maybe some enum constants were removed?). Or maybe the DB records were modified manually?

Thanks for the hint. Looking back, I did add some enums to my test data. It seems like the enums somehow became out of synch. i.e. Category marked with value: 162 (the last enum in my enum class and the error: Index 162 out of bounds for length 162) should actually be 161, since I only have 161 enums. I think somehow some of the data was marked with enum “162” but I don’t understand exactly how. I eventually had 161 enums, unless maybe one more was added, and then test data was produced, and later deleted.

I duplicated the issue when I updated a record to enum value 162 but it was failing to fetch data.

For now, I refreshed the test data with my master DB, and it seems to work.