[h2] ArrayIndexOutOfBoundsException with multiple Threads using h2-1.3.176
I get an unexpected IndexOutOfBounds-Exception in the LobStorageBackend when reading blobs from a table which gets concurrently updated from another thread (however the update is not performed on the blob-field). I attached a simple test case for that and I'm able to reproduce that quite reliable on MacOS and Android. Pastebin: http://pastebin.com/3N99rZNp The stack trace is: Exception in thread "main" java.util.concurrent.ExecutionException: org.h2.jdbc.JdbcSQLException: Eingabe/Ausgabe: "java.io.IOException: java.lang.ArrayIndexOutOfBoundsException: 0"; "lob: null table: -1 id: 1950" IO Exception: "java.io.IOException: java.lang.ArrayIndexOutOfBoundsException: 0"; "lob: null table: -1 id: 1950" [90031-176] at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222) at java.util.concurrent.FutureTask.get(FutureTask.java:83) at org.h2.samples.HelloWorld.main(HelloWorld.java:83) Caused by: org.h2.jdbc.JdbcSQLException: Eingabe/Ausgabe: " java.io.IOException: java.lang.ArrayIndexOutOfBoundsException: 0"; "lob: null table: -1 id: 1950" IO Exception: "java.io.IOException: java.lang.ArrayIndexOutOfBoundsException: 0"; "lob: null table: -1 id: 1950" [90031-176] at org.h2.message.DbException.getJdbcSQLException(DbException.java:344) at org.h2.message.DbException.get(DbException.java:167) at org.h2.message.DbException.convertIOException(DbException.java:329) at org.h2.value.ValueLobDb.getBytesNoCopy(ValueLobDb.java:329) at org.h2.value.ValueLobDb.getBytes(ValueLobDb.java:313) at org.h2.jdbc.JdbcResultSet.getBytes(JdbcResultSet.java:1056) at org.h2.samples.HelloWorld$1.call(HelloWorld.java:58) at org.h2.samples.HelloWorld$1.call(HelloWorld.java:1) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask( ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run( ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:695) Caused by: java.io.IOException: java.lang.ArrayIndexOutOfBoundsException: 0 at org.h2.message.DbException.convertToIOException(DbException.java:363) at org.h2.util.IOUtils.copy(IOUtils.java:181) at org.h2.util.IOUtils.readBytesAndClose(IOUtils.java:283) at org.h2.value.ValueLobDb.getBytesNoCopy(ValueLobDb.java:327) ... 9 more Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 at org.h2.store.LobStorageBackend$LobInputStream.fillBuffer( LobStorageBackend.java:787) at org.h2.store.LobStorageBackend$LobInputStream.readFully( LobStorageBackend.java:763) at org.h2.store.LobStorageBackend$LobInputStream.read( LobStorageBackend.java:754) at org.h2.util.IOUtils.copy(IOUtils.java:168) ... 11 more What can I do to avoid this problem? -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to h2-database+unsubscr...@googlegroups.com. To post to this group, send email to h2-database@googlegroups.com. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/d/optout. /* * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0, * and the EPL 1.0 (http://h2database.com/html/license.html). * Initial Developer: H2 Group */ package org.h2.samples; import java.io.ByteArrayInputStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; /** * A very simple class that shows how to load the driver, create a database, create a table, and insert some data. */ public class HelloWorld { /** * Called when ran from command line. * * @param args *ignored */ public static void main(String... args) throws Exception { Class.forName("org.h2.Driver"); final int threads = 4; final int entries = 2000; init(entries); ExecutorService executor = Executors.newFixedThreadPool(threads); List> futures = new ArrayList>(); for (int t = 0; t < threads; t++) { futures.add(executor.submit(new Callable() { @Override public Void call() throws Exception { Connection conn = DriverManager.getConnection("jdbc:h2:~/test"); PreparedStatement ps = conn.prepareStatement("SELECT id,data FROM blobs WHERE id=?"); for (int i = 0; i < entries; i++) { updateStamp(i, conn); ps.setInt(1, i); ResultSet rs = ps.executeQuery(); try {
Re: [h2] ArrayIndexOutOfBoundsException with multiple Threads using h2-1.3.176
Hi, I can reproduce the problem with version 1.3.x, or with version 1.4.x when disabling the MVStore (append ";mv_store=false" to the database URL). With version 1.4.x (beta), that is with the MVStore, it does not occur. I'm not quite sure what the problem is, it looks like the LOB is removed a bit too early. What is easy to change is the error message (it should say "Missing lob entry"), but I'm not sure how to best fix the problem. Regards, Thomas On Wed, Jul 9, 2014 at 9:40 PM, Torben Schinke wrote: > I get an unexpected IndexOutOfBounds-Exception in the LobStorageBackend > when reading blobs from a table which gets concurrently updated from > another thread (however the update is not performed on the blob-field). > > I attached a simple test case for that and I'm able to reproduce that > quite reliable on MacOS and Android. Pastebin: > http://pastebin.com/3N99rZNp > > The stack trace is: > > Exception in thread "main" java.util.concurrent.ExecutionException: > org.h2.jdbc.JdbcSQLException: Eingabe/Ausgabe: "java.io.IOException: > java.lang.ArrayIndexOutOfBoundsException: 0"; "lob: null table: -1 id: > 1950" > IO Exception: "java.io.IOException: > java.lang.ArrayIndexOutOfBoundsException: 0"; "lob: null table: -1 id: > 1950" [90031-176] > at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222) > at java.util.concurrent.FutureTask.get(FutureTask.java:83) > at org.h2.samples.HelloWorld.main(HelloWorld.java:83) > Caused by: org.h2.jdbc.JdbcSQLException: Eingabe/Ausgabe: " > java.io.IOException: java.lang.ArrayIndexOutOfBoundsException: 0"; "lob: > null table: -1 id: 1950" > IO Exception: "java.io.IOException: > java.lang.ArrayIndexOutOfBoundsException: 0"; "lob: null table: -1 id: > 1950" [90031-176] > at org.h2.message.DbException.getJdbcSQLException(DbException.java:344) > at org.h2.message.DbException.get(DbException.java:167) > at org.h2.message.DbException.convertIOException(DbException.java:329) > at org.h2.value.ValueLobDb.getBytesNoCopy(ValueLobDb.java:329) > at org.h2.value.ValueLobDb.getBytes(ValueLobDb.java:313) > at org.h2.jdbc.JdbcResultSet.getBytes(JdbcResultSet.java:1056) > at org.h2.samples.HelloWorld$1.call(HelloWorld.java:58) > at org.h2.samples.HelloWorld$1.call(HelloWorld.java:1) > at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) > at java.util.concurrent.FutureTask.run(FutureTask.java:138) > at java.util.concurrent.ThreadPoolExecutor$Worker.runTask( > ThreadPoolExecutor.java:895) > at java.util.concurrent.ThreadPoolExecutor$Worker.run( > ThreadPoolExecutor.java:918) > at java.lang.Thread.run(Thread.java:695) > > Caused by: java.io.IOException: java.lang.ArrayIndexOutOfBoundsException: > 0 > at org.h2.message.DbException.convertToIOException(DbException.java:363) > at org.h2.util.IOUtils.copy(IOUtils.java:181) > at org.h2.util.IOUtils.readBytesAndClose(IOUtils.java:283) > at org.h2.value.ValueLobDb.getBytesNoCopy(ValueLobDb.java:327) > > ... 9 more > > Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 > at org.h2.store.LobStorageBackend$LobInputStream.fillBuffer( > LobStorageBackend.java:787) > at org.h2.store.LobStorageBackend$LobInputStream.readFully( > LobStorageBackend.java:763) > at org.h2.store.LobStorageBackend$LobInputStream.read( > LobStorageBackend.java:754) > at org.h2.util.IOUtils.copy(IOUtils.java:168) > > ... 11 more > > What can I do to avoid this problem? > > -- > You received this message because you are subscribed to the Google Groups > "H2 Database" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to h2-database+unsubscr...@googlegroups.com. > To post to this group, send email to h2-database@googlegroups.com. > Visit this group at http://groups.google.com/group/h2-database. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to h2-database+unsubscr...@googlegroups.com. To post to this group, send email to h2-database@googlegroups.com. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/d/optout.
Re: [h2] ArrayIndexOutOfBoundsException with multiple Threads using h2-1.3.176
I have seen this on 1.3.175 in the customer's logs. Config: MVCC=TRUE;MULTI_THREADED=0;LOCK_MODE=3;LOCK_TIMEOUT=2; Here's a stacktrace: 2016-07-25T17:09:43,158 [ERROR][System.err] Caused by: org.h2.jdbc.JdbcSQLException: IO Exception: "java.io.IOException: java.lang.ArrayIndexOutOfBoundsException: 0"; "lob: null table: -1 id: 9100" [90031-175] 2016-07-25T17:09:43,158 [ERROR][System.err] at org.h2.message.DbException.getJdbcSQLException(DbException.java:332) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.h2.message.DbException.get(DbException.java:161) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.h2.message.DbException.convertIOException(DbException.java:318) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.h2.value.ValueLobDb.getBytesNoCopy(ValueLobDb.java:340) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.h2.value.ValueLobDb.getBytes(ValueLobDb.java:324) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.h2.jdbc.JdbcResultSet.getBytes(JdbcResultSet.java:1042) 2016-07-25T17:09:43,158 [ERROR][System.err] at com.mchange.v2.c3p0.impl.NewProxyResultSet.getBytes(NewProxyResultSet.java:659) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$2.doExtract(VarbinaryTypeDescriptor.java:70) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:267) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:263) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:253) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:338) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2969) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.hibernate.loader.plan.exec.process.internal.EntityReferenceInitializerImpl.loadFromResultSet(EntityReferenceInitializerImpl.java:324) 2016-07-25T17:09:43,158 [ERROR][System.err] ... 111 more 2016-07-25T17:09:43,158 [ERROR][System.err] Caused by: java.io.IOException: java.lang.ArrayIndexOutOfBoundsException: 0 2016-07-25T17:09:43,158 [ERROR][System.err] at org.h2.message.DbException.convertToIOException(DbException.java:351) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.h2.util.IOUtils.copy(IOUtils.java:177) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.h2.util.IOUtils.readBytesAndClose(IOUtils.java:277) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.h2.value.ValueLobDb.getBytesNoCopy(ValueLobDb.java:338) 2016-07-25T17:09:43,158 [ERROR][System.err] ... 122 more 2016-07-25T17:09:43,158 [ERROR][System.err] Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 2016-07-25T17:09:43,158 [ERROR][System.err] at org.h2.store.LobStorageBackend$LobInputStream.fillBuffer(LobStorageBackend.java:777) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.h2.store.LobStorageBackend$LobInputStream.readFully(LobStorageBackend.java:753) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.h2.store.LobStorageBackend$LobInputStream.read(LobStorageBackend.java:744) 2016-07-25T17:09:43,158 [ERROR][System.err] at org.h2.util.IOUtils.copy(IOUtils.java:164) On Friday, July 11, 2014 at 3:31:09 PM UTC+3, Thomas Mueller Graf wrote: > > Hi, > > I can reproduce the problem with version 1.3.x, or with version 1.4.x when > disabling the MVStore (append ";mv_store=false" to the database URL). With > version 1.4.x (beta), that is with the MVStore, it does not occur. > > I'm not quite sure what the problem is, it looks like the LOB is removed a > bit too early. What is easy to change is the error message (it should say > "Missing lob entry"), but I'm not sure how to best fix the problem. > > Regards, > Thomas > > > > > > On Wed, Jul 9, 2014 at 9:40 PM, Torben Schinke > wrote: > >> I get an unexpected IndexOutOfBounds-Exception in the LobStorageBackend >> when reading blobs from a table which gets concurrently updated from >> another thread (however the update is not performed on the blob-field). >> >> I attached a simple test case for that and I'm able to reproduce that >> quite reliable on MacOS and Android. Pastebin: >> http://pastebin.com/3N99rZNp >> >> The stack trace is: >> >> Exception in thread "main" java.util.concurrent.ExecutionException: >> org.h2.jdbc.JdbcSQLException: Eingabe/Ausgabe: "java.io.IOException: >> java.lang.ArrayIndexOutOfBoundsException: 0"; "lob: null table: -1 id: >> 1950" >> IO Exception: "java.io.IOException: >> java.lang.ArrayIndexOutOfBoundsException: 0"; "lob: null table: -1 id: >> 1950" [90031-176] >> at java.util.concurrent.FutureTask$Sync.