"freeCount expected" db corruption

22 views
Skip to first unread message

gshkolnik

unread,
Aug 12, 2008, 3:39:00 PM8/12/08
to H2 Database
Hi,

We recently started getting the "freeCount expected" error after
upgrading to H2 version 1.0.76.

...
Caused by: java.lang.RuntimeException: freeCount expected 0, got: 448
at org/h2/message/Message.getInternalError (Message.java:179)
at org/h2/store/Storage.refillFreeList (Storage.java:247)
at org/h2/store/Storage.allocate (Storage.java:254)
at org/h2/store/Storage.addRecord (Storage.java:182)
at org/h2/index/ScanIndex.add (ScanIndex.java:123)
at org/h2/table/TableData.addRow (TableData.java:108)
... 15 more

Our jdbc url is:
jdbc:h2:rundir\db
\db;LOG=2;MAX_LOG_SIZE=1;DB_CLOSE_DELAY=-1;TRACE_MAX_FILE_SIZE=1,username=sa,password=

If needed I can provide the database files. They are about 260K
zipped.

In another post here, it is mentioned that "It is not critical at
runtime if freeCount is incorrect". So, is there a way to configure
the database, so that this check is not performed (at least for the
time being). Also, is it possible for us to maybe detect this
condition and somehow repair the database?

Thank you,
- Gene

Thomas Mueller

unread,
Aug 12, 2008, 9:45:13 PM8/12/08
to h2-da...@googlegroups.com
Hi,

> We recently started getting the "freeCount expected" error after
> upgrading to H2 version 1.0.76.

> If needed I can provide the database files. They are about 260K
> zipped.

Is this problem reproducible always? If yes it would be great if you
could send me the database files.

> In another post here, it is mentioned that "It is not critical at
> runtime if freeCount is incorrect". So, is there a way to configure
> the database, so that this check is not performed (at least for the
> time being).

You can disable the CHECK setting, see
http://www.h2database.com/javadoc/org/h2/constant/SysProperties.html#h2.check
(see also the top of the page on how to disable it).

> Also, is it possible for us to maybe detect this
> condition and somehow repair the database?

There is no need to repair the database really. The space will be
reclaimed when the database is re-opened. It is just an annoying
exception. I will fix this in the next release (next week).

Regards,
Thomas

gshkolnik

unread,
Aug 13, 2008, 9:52:51 AM8/13/08
to H2 Database
Thank you for your reply. I uploaded the db files: groups.google.com/
group/h2-database/web/db.zip

I am somewhat reluctant to disable the asserts altogether, but if
that's the only recourse I'll obviously do it. If we were to perform
frequent checkpoints, do you think it would help in making sure that
the 'freeCount' maintains its correct value?

Thank you,
- Gene

On Aug 12, 9:45 pm, "Thomas Mueller" <thomas.tom.muel...@gmail.com>
wrote:
> Hi,
>
> > We recently started getting the "freeCount expected" error after
> > upgrading to H2 version 1.0.76.
> > If needed I can provide the database files. They are about 260K
> > zipped.
>
> Is this problem reproducible always? If yes it would be great if you
> could send me the database files.
>
> > In another post here, it is mentioned that "It is not critical at
> > runtime if freeCount is incorrect". So, is there a way to configure
> > the database, so that this check is not performed (at least for the
> > time being).
>
> You can disable the CHECK setting, seehttp://www.h2database.com/javadoc/org/h2/constant/SysProperties.html#...

Thomas Mueller

unread,
Aug 15, 2008, 12:34:32 AM8/15/08
to h2-da...@googlegroups.com
Hi,

> Caused by: java.lang.RuntimeException: freeCount expected 0, got: 448
> at org/h2/message/Message.getInternalError (Message.java:179)
> at org/h2/store/Storage.refillFreeList (Storage.java:247)
> at org/h2/store/Storage.allocate (Storage.java:254)
> at org/h2/store/Storage.addRecord (Storage.java:182)
> at org/h2/index/ScanIndex.add (ScanIndex.java:123)
> at org/h2/table/TableData.addRow (TableData.java:108)
> ... 15 more
>
> Our jdbc url is:
> jdbc:h2:rundir\db
> \db;LOG=2;MAX_LOG_SIZE=1;DB_CLOSE_DELAY=-1;TRACE_MAX_FILE_SIZE=1,username=sa,password=

Thanks! Unfortunately I couldn't reproduce this problem - do you have
a simple test case where this problem occurs?

> In another post here, it is mentioned that "It is not critical at
> runtime if freeCount is incorrect". So, is there a way to configure
> the database, so that this check is not performed (at least for the
> time being).

Yes, set the system property h2.check to false: java -Dh2.check=false
... or System.setProperty("h2.check", "false") before loading the
database driver.

> Also, is it possible for us to maybe detect this
> condition and somehow repair the database?

The database is not broken, there is no need to repair. It is
something in the code I like to fix.

Regards,
Thomas

Bruno Nyffeler

unread,
Sep 10, 2008, 6:58:48 AM9/10/08
to H2 Database
Hello Thomas.

> There is no need to repair the database really. The space will be
> reclaimed when the database is re-opened. It is just an annoying
> exception. I will fix this in the next release (next week).

Has this been fixed already (in 1.077 or 1.0.78)? I cannot see
anything in the change log.

And by looking into the code (Storage.java, line 246):

if (SysProperties.CHECK2 && freeCount > freeList.size()) {

should one not rather disable check2 instead of check?

Best regards,
Bruno

Thomas Mueller

unread,
Sep 12, 2008, 7:13:15 PM9/12/08
to h2-da...@googlegroups.com
Hi,

> Has this been fixed already (in 1.077 or 1.0.78)? I cannot see
> anything in the change log.

I forgot to write that in the changelog.

> if (SysProperties.CHECK2 && freeCount > freeList.size()) {

Before 2008-08-02, this was

> if (SysProperties.CHECK && freeCount > freeList.size()) {

> should one not rather disable check2 instead of check?

CHECK2 is disabled by default, except when running the unit tests.

Regards,
Thomas

Reply all
Reply to author
Forward
0 new messages