Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

H2 db 'Chunk no longer exists' error

When I'm trying to add a new row to db "INSERT INTO invited_users VALUES('id', user_name')"

I'm getting this error:

General error: "java.lang.IllegalStateException: Chunk 2089 no longer exists [1.4.181/9]"

Probably it's some problems with db, because when I tried to add the same row to a new db - error disappeared.

Update Nov 20, 2014

Good news! I contacted developers of H2 db and find out that they will fix that bug in the next release. https://groups.google.com/forum/#!topic/h2-database/i_GHXExjotc

Update Dec 6, 2014

A simple workaround is to disable the MVStore by appending ";mv_store=false" to the database URL.

But, this trick will not work, if you need the old db. It creates new database, with .h2.db extension instead of .mv.db

To overcome this you need to create SQL script of your old database ".mv.db" (with Recover tool), and then run this script using "runscript ...".

like image 648
iceone213 Avatar asked Nov 13 '14 16:11

iceone213


People also ask

How do I connect to H2 local database?

Click Windows → type H2 Console → Click H2 console icon. Connect to the URL http://localhost:8082. At the time of connecting, the H2 database will ask for database registration as shown in the following screenshot.

Why H2 database is not used in production?

Mainly, H2 database can be configured to run as inmemory database, which means that data will not persist on the disk. Because of embedded database it is not used for production development, but mostly used for development and testing.


1 Answers

In version 1.4.182, there is probably something wrong with the mechanism that detects when a chunk is no longer referenced. Currently, this is reference counting garbage collection: by counting live pages and live space. If this reaches zero, a chunk can be overwritten after 45 seconds.

A simple workaround is to use the page store storage mechanism instead of mv_store by changing the database connection to use mv_store=false as a mitigation.

MV_STORE option is automatically enabled since version 1.4.177 Beta.

By default, the MV_STORE option is enabled, so it is using the new MVStore storage. The MVCC setting is by default set to the same values as the MV_STORE setting, so it is also enabled by default. For testing, both settings can be disabled by appending ";MV_STORE=FALSE" and/or ";MVCC=FALSE" to the database URL.

like image 195
Pier-Alexandre Bouchard Avatar answered Oct 01 '22 02:10

Pier-Alexandre Bouchard