Tmr / h2database

Automatically exported from code.google.com/p/h2database
0 stars 0 forks source link

Database corruption when using MULTI_THREADED=1 #539

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The database becomes corrupted occasionally when running H2 in multi threaded 
mode.

This has been discussed on the forum: 
https://groups.google.com/forum/#!topic/h2-database/MEYujXqbZYI

What steps will reproduce the problem?
(simple SQL scripts or simple standalone applications are preferred)
1. Start the attached application. It continously adds/deletes rows to/from 
some tables while other statements perform queries on these tables.

What is the expected output? What do you see instead?
The application should run fine without problems forever.

With 1.3.174 usually after ~10 minutes an exception is thrown:
General error: "java.lang.RuntimeException: Undo entry not written"; SQL 
statement:

What version of the product are you using? On what operating system, file
system, and virtual machine?
Linux 3.6 kernel, H2 1.3.174

Do you know a workaround?
Do not use H2 in multi threaded mode.

What is your use case, meaning why do you need this feature?
Some queries in my application need quite a long time which means users with 
small quick queries have to wait for this long running queries. Using the 
database in non multi threaded mode is possible but slows down the overall 
performance.

Original issue reported on code.google.com by u.wiel...@gematronik.com on 9 Jan 2014 at 9:16

Attachments:

GoogleCodeExporter commented 9 years ago
This issue also occurs in our application, but not very frequently. Even the 
rare occurences are big issue for us, because it requires re-filling the 
database with all data from our primary data storage. This procedure takes 
about 30 hours in our production environment.

We are using multi-threaded mode as well for performance reasons (same as 
mentioned by the author of this issue).

Last occurences happened with version 1.3.172 on CentOS 6.3.

We were not able to reproduce the issue in developer's workspace on Windows 7 
using the attached code.

Original comment by radek.kr...@gmail.com on 3 Feb 2014 at 12:36

GoogleCodeExporter commented 9 years ago
H2MultiThreadTest1: I tested before, but was not able to reproduce then. Now I 
tested again and got the exception("Undo entry not written"). I will 
investigate.

I also tried with the MVStore (append ";MV_STORE=TRUE" to the database URL), in 
the current trunk, and so far could not see a problem. But the MVStore is not 
ready for production yet.

Original comment by thomas.t...@gmail.com on 21 Feb 2014 at 5:10

GoogleCodeExporter commented 9 years ago
The problem seens to be: between writing the undo entry and writing the change, 
a checkpoint is written. This is unexpected, and therefore an exception is 
thrown. I'm not sure yet how to best solve this (I would like to avoid 
additional synchronization or locking), but I'm working on it.

Original comment by thomas.t...@gmail.com on 22 Feb 2014 at 6:52

GoogleCodeExporter commented 9 years ago
Please note this is only an issue for H2 version 1.3.x. With version 1.4.x, 
this code path is not used.

Original comment by thomas.t...@gmail.com on 16 Apr 2014 at 5:14

GoogleCodeExporter commented 9 years ago
The issue with "undo entry not written" still rarely occurs with version 
1.4.180. Last occurrence produced the following stacktrace. Other information 
from my comment #1 are still valid.

2014-07-23 11:33:51,457 [TP-Processor7 | u:xxx | sql: SELECT * FROM WORKITEM 
WHERE C_TYPE='defect' AND NOT C_SEVERITY='critical'] ERROR 
com.polarion.platform.sql.internal.runtime.Database  - General error: 
"java.lang.RuntimeException: Undo entry not written" [50000-180]
org.h2.jdbc.JdbcSQLException: General error: "java.lang.RuntimeException: Undo 
entry not written" [50000-180]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
    at org.h2.message.DbException.get(DbException.java:168)
    at org.h2.message.DbException.convert(DbException.java:295)
    at org.h2.message.DbException.toSQLException(DbException.java:268)
    at org.h2.message.TraceObject.logAndConvert(TraceObject.java:352)
    at org.h2.jdbc.JdbcResultSet.next(JdbcResultSet.java:125)
...
Caused by: java.lang.RuntimeException: Undo entry not written
    at org.h2.message.DbException.throwInternalError(DbException.java:242)
    at org.h2.store.PageLog.addUndo(PageLog.java:501)
    at org.h2.store.PageStore.free(PageStore.java:1254)
    at org.h2.store.PageStore.free(PageStore.java:1237)
    at org.h2.index.PageDataIndex.remove(PageDataIndex.java:372)
    at org.h2.table.RegularTable.removeChildrenAndResources(RegularTable.java:723)
    at org.h2.result.ResultTempTable.dropTable(ResultTempTable.java:222)
    at org.h2.result.ResultTempTable.close(ResultTempTable.java:191)
    at org.h2.result.LocalResult.close(LocalResult.java:390)
    at org.h2.jdbc.JdbcResultSet.nextRow(JdbcResultSet.java:3234)
    at org.h2.jdbc.JdbcResultSet.next(JdbcResultSet.java:123)
    ... 78 more 

Original comment by radek.kr...@gmail.com on 23 Jul 2014 at 1:17