Why do I get org.hibernate.HibernateException: IOException occurred while reading a binary value

I found this exception in my logs, which I have never seen before, I use Hibernate 4.1.7

Does this mean that my database is corrupted, or is this a bug in Hibernate. I found a link to this error at http://lists.jboss.org/pipermail/hibernate-issues/2010-November/026487.html , but this concerned a much earlier version of sleep mode and was fixed for Hibernate 4.0

org.hiorg.hibernate.HibernateException: IOException occurred reading a binary value at org.hibernate.type.descriptor.java.DataHelper.extractBytes(DataHelper.java:187) at org.hibernate.type.descriptor.java.PrimitiveByteArrayTypeDescriptor.wrap(PrimitiveByteArrayTypeDescriptor.java:124) at org.hibernate.type.descriptor.java.PrimitiveByteArrayTypeDescriptor.wrap(PrimitiveByteArrayTypeDescriptor.java:41) at org.hibernate.type.descriptor.sql.BlobTypeDescriptor$5.doExtract(BlobTypeDescriptor.java:118) at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:65) at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:269) at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:265) at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:238) at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:357) at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2807) at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1545) at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1477) at org.hibernate.loader.Loader.getRow(Loader.java:1377) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:644) at org.hibernate.loader.Loader.doQuery(Loader.java:854) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:293) at org.hibernate.loader.Loader.doList(Loader.java:2382) at org.hibernate.loader.Loader.doList(Loader.java:2368) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2198) at org.hibernate.loader.Loader.list(Loader.java:2193) at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:122) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1618) at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:374) at com.jthink.songkong.db.SongCache.loadSongsFromDatabase(SongCache.java:57) at com.jthink.songkong.analyse.analyser.SongGroup.getSongs(SongGroup.java:48) at com.jthink.songkong.analyse.analyser.DiscogsSongGroupMatcher.call(DiscogsSongGroupMatcher.java:63) at com.jthink.songkong.analyse.analyser.DiscogsSongGroupMatcher.call(DiscogsSongGroupMatcher.java:28) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722) Caused by: java.io.IOException: org.h2.jdbc.JdbcSQLException: IO Exception: "Missing lob entry: 5587/4" [90028-172] at org.h2.message.DbException.convertToIOException(DbException.java:348) at org.h2.store.LobStorageBackend$LobInputStream.fillBuffer(LobStorageBackend.java:695) at org.h2.store.LobStorageBackend$LobInputStream.readFully(LobStorageBackend.java:668) at org.h2.store.LobStorageBackend$LobInputStream.read(LobStorageBackend.java:654) at org.hibernate.type.descriptor.java.DataHelper.extractBytes(DataHelper.java:179) ... 31 more Caused by: org.h2.jdbc.JdbcSQLException: IO Exception: "Missing lob entry: 5587/4" [90028-172] at org.h2.message.DbException.getJdbcSQLException(DbException.java:329) at org.h2.message.DbException.get(DbException.java:169) at org.h2.message.DbException.get(DbException.java:146) at org.h2.store.LobStorageBackend.readBlock(LobStorageBackend.java:203) at org.h2.store.LobStorageBackend$LobInputStream.fillBuffer(LobStorageBackend.java:692) ... 34 more 
+6
source share
3 answers

Let's start with the Hibernate document:

@Lob indicates that the property should be persisted in a Blob or a Clob depending on the property type: java.sql.Clob, Character[], char[] and java.lang.String will be persisted in a Clob. java.sql.Blob, Byte[], byte[] and serializable type will be persisted in a Blob.

For instance:

 @Lob public String getFullText() { return fullText; } @Lob public byte[] getFullCode() { return fullCode; } 

Knowing this, this may mean that the object is not in the database. It may have been deleted from the table, but this did not happen in the reference table. Let's say that blobs with id 5 were removed from the Blobs table, but in the users_blobs table the users_blobs link is called:

 | user_id | blob_id| | 4 | 5 | //This entry blob were delete but is still referenced by that table | 5 | 2 | 

If so, you should redefine your users_blobs restrictions (for example) so that it is deleted or null if the blob is removed.

In addition, this link may also be useful:

http://h2-database.66688.n3.nabble.com/IO-Exception-quot-Missing-lob-entry-1-0-quot-90028-171-when-trying-to-read-a-BLOB- longer-than-128-bye-td4026236.html

+3
source

This is definitely a database problem, not a sleeping one. You should look at the cause of the exception, which is the exception thrown inside the h2 database code.

 Caused by: org.h2.jdbc.JdbcSQLException: IO Exception: "Missing lob entry: 5587/4" [90028-172] at org.h2.message.DbException.getJdbcSQLException(DbException.java:329) at org.h2.message.DbException.get(DbException.java:169) at org.h2.message.DbException.get(DbException.java:146) at org.h2.store.LobStorageBackend.readBlock(LobStorageBackend.java:203) at org.h2.store.LobStorageBackend$LobInputStream.fillBuffer(LobStorageBackend.java:692) 

An online search for "database h2 No record with record" shows that this is a h2 error message and answers, like here: https://groups.google.com/forum/#!topic/h2-database/xey-czIhocM indicate that it is very likely that the database is corrupt.

If this happens more often, more research on how this happened would be appropriate. But this is best done in this h2 group, where database developers are active.

+1
source

It seems you are trying to load a previously registered data register, try synchronizing access to this sleeping DAO. Multiple thread applications must use one connection for each thread.

+1
source

Source: https://habr.com/ru/post/953547/


All Articles