Thomas,
1. It would be terrific if I could use an H2-provided set of tests to test
a pluggable file system!
Now, when I run TestFileSystem.main() *without* even having register()'ed
my FilePath subclass, I get the following:
Exception in thread "main" java.lang.AssertionError: Expected an exception
of type
IOException to be thrown, but the method under test threw an exception of
type
NonWritableChannelException (see in the 'Caused by' for the exception that
was thrown)
at org.h2.test.utils.AssertThrows$1.verify(AssertThrows.java:39)
at org.h2.test.utils.AssertThrows.<init>(AssertThrows.java:106)
at org.h2.test.utils.AssertThrows.<init>(AssertThrows.java:30)
at org.h2.test.unit.TestFileSystem$18.<init>(TestFileSystem.java:542)
at org.h2.test.unit.TestFileSystem.testSimple(TestFileSystem.java:542)
at org.h2.test.unit.TestFileSystem.testFileSystem(TestFileSystem.java:383)
at org.h2.test.unit.TestFileSystem.test(TestFileSystem.java:60)
at org.h2.test.unit.TestFileSystem.main(TestFileSystem.java:55)
at MyTest.main(MyTest.java:41)
Caused by: java.nio.channels.NonWritableChannelException
at sun.nio.ch.FileChannelImpl.truncate(FileChannelImpl.java:325)
at java.io.RandomAccessFile.setLength(RandomAccessFile.java:905)
at org.h2.store.fs.FileDisk.truncate(FilePathDisk.java:419)
at org.h2.test.unit.TestFileSystem$18.test(TestFileSystem.java:545)
at org.h2.test.utils.AssertThrows.<init>(AssertThrows.java:103)
... 7 more
Is this normal? Is some setup required to get the TestFileSystem class
going?
2. Btw, I managed to step through some of the H2 code for my original
file-size problem. What's happening is, during the DB-connection close the
following DBException ...
org.h2.message.DbException: File corrupted while reading record:
"wrong checksum". Possible solution: use the recovery tool [90030-174]
... is getting thrown in the PageStore.compact(int, int) method.
This failure to compact the DB file kinda gives me some clue at least as to
why the file-size is going on increasing. (Open connection reserves file
space, and close connection is supposed to compact it.)
On Monday, April 28, 2014 11:17:54 AM UTC+5:30, Thomas Mueller wrote:
>
> Hi,
>
> There is a special test for file systems, it's probably easier and more
> reliable to test a new file system implementation that way instead of using
> the database engine to test it. The test class is
> "org.h2.test.unit.TestFileSystem".
>
> Registering a file system is usually done using a static "register"
> method, as in FilePathZip2.register() (see the source code there).
>
> Tell us if you need help!
>
> By the way, Java 7 supports a file system abstraction, and my plan is to
> use that in the future, when Java 6 no longer needs to be supported.
>
> Regards,
> Thomas
>
> On Sunday, April 27, 2014, PN <[email protected] <javascript:>> wrote:
>
>> Hi,
>>
>> I'm trying to run H2 off of a pluggable filesystem that I've written with
>> some success so far.
>>
>> While I can issue a simple select query (such as, *"select * from
>> INFORMATION_SCHEMA.tables"*) and get back the query results just fine,
>> I'm observing a couple problem from H2's side (though not necessarily due
>> to H2 squarely!).
>>
>>
>> *Problem 1:* The size of the .h2.db file keeps increasing, in increments
>> of 1 to 2MB, merely with a database connection-open and -close -- even
>> without any select query involved. Here's the program I'm using:
>>
>> public class MyFilePath extends FilePath {
>> // ...
>> }
>> FileSystem fs = null;
>> Connection conn = null;
>> try {
>> // <Setup 'env' here...>
>> fs = (FooFileSystem) FileSystems.newFileSystem(URI.create("foo:/"), env);
>>
>> FilePath.register(new MyFilePath("foo:/"));
>>
>> *// Question: Btw, where do I register my FileBase subclass? *
>>
>> conn = DriverManager.getConnection("jdbc:h2:foo:/abc;CIPHER=AES", "user",
>> "password");
>> } catch(Exception x) {
>> x.printStackTrace();
>> } finally {
>> if (conn != null) conn.close();
>> if(fs != null) fs.close();
>> }
>>
>>
>> And here's the pattern of size-increases upon each run of the above
>> program:
>>
>>
>> ===================================================
>> Run #: Database file size (bytes)
>> ===================================================
>> 129024 (initial)
>> 1 2226176 (increase by: 2097152, or 2 MB)
>> 2 3274752 (increase by: 1048576, or 1 MB)
>> 3 5371904 (increase by: 2097152, or 2 MB)
>> 4 5371904 (increase by: 0, or 0 MB)
>> 5 7469056 (increase by: 2097152, or 2 MB)
>> 6 7469056 (increase by: 0, or 0 MB)
>> 7 10614784 (increase by: 3145728, or 3 MB)
>> ===================================================
>>
>>
>>
>> *Question 1*: Could someone help narrow down the portion of H2
>> codebase that I should step through in the debugger to troubleshoot this
>> problem? For example, knowing what H2 conceptually does during connection
>> open and/or close would help. Note that, outside of H2 database access, I
>> can copy regular files from/to this filesystem using Java API just fine,
>> with the source and destination file sizes and contents always matching.
>> Only that, I'm not sure what 'pattern' of Java API usage H2 is employing to
>> be causing this problem to manifest!
>>
>> *Question 2*: How and where do I register my FileBase subclass with
>> H2? I didn't find this mentioned in the documentation (at
>> http://www.h2database.com/html/advanced.html#file_system).
>>
>>
>> *Problem 2:* At the time of connection close, I'm getting the following
>> exception in the .trace.db file:
>>
>> 04-27 09:11:47 database: close
>> org.h2.message.DbException: File corrupted while reading record: "wrong
>> checksum". Possible solution: use the recovery tool [90030-174]
>> at org.h2.message.DbException.get(DbException.java:172)
>> at org.h2.message.DbException.get(DbException.java:149)
>> at org.h2.store.PageStore.getPage(PageStore.java:746)
>> at org.h2.store.PageStore.compact(PageStore.java:700)
>> at org.h2.store.PageStore.compact(PageStore.java:528)
>> at org.h2.engine.Database.closeOpenFilesAndUnlock(Database.java:1241)
>> at org.h2.engine.Database.close(Database.java:1191)
>> at org.h2.engine.Database.removeSession(Database.java:1069)
>> at org.h2.engine.Session.close(Session.java:666)
>> at org.h2.jdbc.JdbcConnection.close(JdbcConnection.java:366)
>> at H2Test.main(H2Test.java:70)
>> Caused by: org.h2.jdbc.JdbcSQLException: File corrupted while reading
>> record: "wrong checksum". Possible solution: use the recovery tool
>> [90030-174]
>> at org.h2.message.DbException.getJdbcSQLException(DbException.java:332)
>> ... 11 more
>>
>> *Question 3*: Is there a quick and easy way to figure out what could
>> possibly be causing this exception? Could Problem 2 (causing an improper
>> database shutdown) be causing Problem 1?
>>
>>
>> Many thanks,
>> /PN
>>
>> --
>> 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 [email protected].
>> To post to this group, send email to [email protected].
>> 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.