Illegal seek

88 views
Skip to first unread message

Matti Linnanvuori

unread,
Jan 10, 2022, 7:37:37 AM1/10/22
to H2 Database

When I try to run a script that uses H2 version 2.0.206 and executes a SELECT statement, I get the following error. There is a Java server running the database. The operating system is Red Hat Enterprise Linux 7.9.

Exception in thread "main" org.h2.message.DbException: IO Exception: "java.io.IOException: Illegal seek" [90028-206]

at org.h2.message.DbException.get(DbException.java:216)

at org.h2.message.DbException.convertIOException(DbException.java:459)

at org.h2.util.ScriptReader.readStatement(ScriptReader.java:101)

at org.h2.tools.RunScript.process(RunScript.java:205)

at org.h2.tools.RunScript.process(RunScript.java:194)

at org.h2.tools.RunScript.process(RunScript.java:321)

at org.h2.tools.RunScript.runTool(RunScript.java:144)

at org.h2.tools.RunScript.main(RunScript.java:71)

Caused by: org.h2.jdbc.JdbcSQLNonTransientException: IO Exception: "java.io.IOException: Illegal seek" [90028-206]

at org.h2.message.DbException.getJdbcSQLException(DbException.java:573)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:496)

... 8 more

Caused by: java.io.IOException: Illegal seek

at sun.nio.ch.FileDispatcherImpl.seek0(Native Method)

at sun.nio.ch.FileDispatcherImpl.seek(FileDispatcherImpl.java:76)

at sun.nio.ch.FileChannelImpl.position(FileChannelImpl.java:264)

at sun.nio.ch.ChannelInputStream.available(ChannelInputStream.java:116)

at java.io.BufferedInputStream.read(BufferedInputStream.java:353)

at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)

at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)

at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)

at java.io.InputStreamReader.read(InputStreamReader.java:184)

at org.h2.util.ScriptReader.readBuffer(ScriptReader.java:293)

at org.h2.util.ScriptReader.read(ScriptReader.java:266)

at org.h2.util.ScriptReader.readStatementLoop(ScriptReader.java:107)

at org.h2.util.ScriptReader.readStatement(ScriptReader.java:99)

... 5 more


Evgenij Ryazanov

unread,
Jan 10, 2022, 9:50:24 AM1/10/22
to H2 Database
Hello!

How value of -script parameter looks like? It is a regular file, pipe, or some other special object?

I cannot reproduce this issue with regular files, but BufferedInputStream, unfortunately, may fail if underlying InputStream thrown exceptions from its available() method.
Maybe H2 should use BufferedReader over InputStreamReader over InputStream instead of InputStreamReader over BufferedInputStream over InputStream.

Matti Linnanvuori

unread,
Jan 11, 2022, 1:36:36 AM1/11/22
to H2 Database
The script is like the following.

URL="jdbc:h2:/opt/app/var/db/session-db;AUTO_SERVER=TRUE"

set -f

echo "$1" | java -cp "$JAR" org.h2.tools.RunScript -url "$URL" -user '' -password '' -script /dev/stdin -showResults
Reply all
Reply to author
Forward
0 new messages