我写了一个cordapp,它每10分钟启动一次可调度流程,每次记录两次事务。
经过一段时间的正确执行(既不是异常也不是错误),由于persistence.mv.db
报告了以下错误,persistence.trace.db
崩溃了:
2018-04-27 03:22:00 database: flush
org.h2.message.DbException: General error: "java.lang.IllegalStateException: Negative position -2904; p=123201377404004873, c=chunk:6d6cc,block:7fffffffffffffff,len:7fffffff,map:4b,max:9e8c40,next:7fffffffffffffff,pages:325,root:7fffffffffffffff,time:78ccfc8,version:6d6cc [1.4.194/6]" [50000-194]
at org.h2.message.DbException.get(DbException.java:168)
at org.h2.message.DbException.convert(DbException.java:295)
at org.h2.mvstore.db.MVTableEngine$1.uncaughtException(MVTableEngine.java:95)
at org.h2.mvstore.MVStore.panic(MVStore.java:378)
at org.h2.mvstore.MVStore.storeNow(MVStore.java:1052)
at org.h2.mvstore.MVStore.commitAndSave(MVStore.java:1039)
at org.h2.mvstore.MVStore.beforeWrite(MVStore.java:2218)
at org.h2.mvstore.MVMap.beforeWrite(MVMap.java:1051)
at org.h2.mvstore.MVMap.put(MVMap.java:122)
at org.h2.mvstore.db.TransactionStore.log(TransactionStore.java:282)
at org.h2.mvstore.db.TransactionStore$Transaction.log(TransactionStore.java:706)
at org.h2.mvstore.db.TransactionStore$TransactionMap.trySet(TransactionStore.java:1115)
at org.h2.mvstore.db.TransactionStore$TransactionMap.set(TransactionStore.java:1027)
at org.h2.mvstore.db.TransactionStore$TransactionMap.remove(TransactionStore.java:989)
at org.h2.mvstore.db.MVSecondaryIndex.remove(MVSecondaryIndex.java:242)
at org.h2.mvstore.db.MVTable.removeRow(MVTable.java:680)
at org.h2.command.dml.Delete.update(Delete.java:95)
at org.h2.command.CommandContainer.update(CommandContainer.java:101)
at org.h2.command.Command.executeUpdate(Command.java:258)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:160)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:146)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:204)
at org.hibernate.hql.internal.ast.exec.BasicExecutor.doExecute(BasicExecutor.java:90)
at org.hibernate.hql.internal.ast.exec.BasicExecutor.execute(BasicExecutor.java:59)
at org.hibernate.hql.internal.ast.exec.DeleteExecutor.execute(DeleteExecutor.java:110)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:428)
at org.hibernate.engine.query.spi.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:374)
at org.hibernate.internal.SessionImpl.executeUpdate(SessionImpl.java:1503)
at org.hibernate.query.internal.AbstractProducedQuery.doExecuteUpdate(AbstractProducedQuery.java:1522)
at org.hibernate.query.internal.AbstractProducedQuery.executeUpdate(AbstractProducedQuery.java:1500)
at net.corda.node.services.persistence.DBCheckpointStorage.removeCheckpoint(DBCheckpointStorage.kt:44)
at net.corda.node.services.statemachine.StateMachineManager.updateCheckpoint(StateMachineManager.kt:554)
at net.corda.node.services.statemachine.StateMachineManager.onExistingSessionMessage(StateMachineManager.kt:325)
at net.corda.node.services.statemachine.StateMachineManager.onSessionMessage(StateMachineManager.kt:296)
at net.corda.node.services.statemachine.StateMachineManager.access$onSessionMessage(StateMachineManager.kt:78)
at net.corda.node.services.statemachine.StateMachineManager$resumeRestoredFibers$2.invoke(StateMachineManager.kt:263)
at net.corda.node.services.statemachine.StateMachineManager$resumeRestoredFibers$2.invoke(StateMachineManager.kt:78)
at net.corda.node.services.messaging.NodeMessagingClient.callHandlers(NodeMessagingClient.kt:444)
at net.corda.node.services.messaging.NodeMessagingClient.access$callHandlers(NodeMessagingClient.kt:76)
at net.corda.node.services.messaging.NodeMessagingClient$deliver$1$1.invoke(NodeMessagingClient.kt:429)
at net.corda.node.services.messaging.NodeMessagingClient$deliver$1$1.invoke(NodeMessagingClient.kt:76)
at net.corda.node.utilities.CordaPersistence.inTopLevelTransaction(CordaPersistence.kt:84)
at net.corda.node.utilities.CordaPersistence.transaction(CordaPersistence.kt:75)
at net.corda.node.utilities.CordaPersistence.transaction(CordaPersistence.kt:65)
at net.corda.node.services.messaging.NodeMessagingClient$deliver$1.invoke(NodeMessagingClient.kt:421)
at net.corda.node.services.messaging.NodeMessagingClient$deliver$1.invoke(NodeMessagingClient.kt:76)
at net.corda.node.utilities.AffinityExecutor$fetchFrom$1.get(AffinityExecutor.kt:44)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$1$thread$1.run(AffinityExecutor.kt:69)
Caused by: org.h2.jdbc.JdbcSQLException: General error: "java.lang.IllegalStateException: Negative position -2904; p=123201377404004873, c=chunk:6d6cc,block:7fffffffffffffff,len:7fffffff,map:4b,max:9e8c40,next:7fffffffffffffff,pages:325,root:7fffffffffffffff,time:78ccfc8,version:6d6cc [1.4.194/6]" [50000-194]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
... 57 more
Caused by: java.lang.IllegalStateException: Negative position -2904; p=123201377404004873, c=chunk:6d6cc,block:7fffffffffffffff,len:7fffffff,map:4b,max:9e8c40,next:7fffffffffffffff,pages:325,root:7fffffffffffffff,time:78ccfc8,version:6d6cc [1.4.194/6]
at org.h2.mvstore.DataUtils.newIllegalStateException(DataUtils.java:765)
at org.h2.mvstore.MVStore.readPageChunkReferences(MVStore.java:1382)
at org.h2.mvstore.MVStore.collectReferencedChunks(MVStore.java:1332)
at org.h2.mvstore.MVStore.collectReferencedChunks(MVStore.java:1337)
at org.h2.mvstore.MVStore.collectReferencedChunks(MVStore.java:1337)
at org.h2.mvstore.MVStore.collectReferencedChunks(MVStore.java:1317)
at org.h2.mvstore.MVStore.freeUnusedChunks(MVStore.java:1276)
at org.h2.mvstore.MVStore.storeNowTry(MVStore.java:1063)
at org.h2.mvstore.MVStore.storeNow(MVStore.java:1050)
... 52 more
2018-04-27 03:22:00 jdbc[634]: exception
org.h2.jdbc.JdbcSQLException: File corrupted while reading record: "nio:/some/path/to/nodes/Node/persistence.mv.db". Possible solution: use the recovery tool; SQL statement:
delete from node_checkpoints where checkpoint_id=? [90030-194]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:168)
at org.h2.mvstore.db.MVTableEngine$Store.convertIllegalStateException(MVTableEngine.java:196)
at org.h2.mvstore.db.MVTable.convertException(MVTable.java:904)
at org.h2.mvstore.db.MVSecondaryIndex.remove(MVSecondaryIndex.java:248)
at org.h2.mvstore.db.MVTable.removeRow(MVTable.java:680)
at org.h2.command.dml.Delete.update(Delete.java:95)
at org.h2.command.CommandContainer.update(CommandContainer.java:101)
at org.h2.command.Command.executeUpdate(Command.java:258)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:160)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:146)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:204)
at org.hibernate.hql.internal.ast.exec.BasicExecutor.doExecute(BasicExecutor.java:90)
at org.hibernate.hql.internal.ast.exec.BasicExecutor.execute(BasicExecutor.java:59)
at org.hibernate.hql.internal.ast.exec.DeleteExecutor.execute(DeleteExecutor.java:110)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:428)
at org.hibernate.engine.query.spi.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:374)
at org.hibernate.internal.SessionImpl.executeUpdate(SessionImpl.java:1503)
at org.hibernate.query.internal.AbstractProducedQuery.doExecuteUpdate(AbstractProducedQuery.java:1522)
at org.hibernate.query.internal.AbstractProducedQuery.executeUpdate(AbstractProducedQuery.java:1500)
at net.corda.node.services.persistence.DBCheckpointStorage.removeCheckpoint(DBCheckpointStorage.kt:44)
at net.corda.node.services.statemachine.StateMachineManager.updateCheckpoint(StateMachineManager.kt:554)
at net.corda.node.services.statemachine.StateMachineManager.onExistingSessionMessage(StateMachineManager.kt:325)
at net.corda.node.services.statemachine.StateMachineManager.onSessionMessage(StateMachineManager.kt:296)
at net.corda.node.services.statemachine.StateMachineManager.access$onSessionMessage(StateMachineManager.kt:78)
at net.corda.node.services.statemachine.StateMachineManager$resumeRestoredFibers$2.invoke(StateMachineManager.kt:263)
at net.corda.node.services.statemachine.StateMachineManager$resumeRestoredFibers$2.invoke(StateMachineManager.kt:78)
at net.corda.node.services.messaging.NodeMessagingClient.callHandlers(NodeMessagingClient.kt:444)
at net.corda.node.services.messaging.NodeMessagingClient.access$callHandlers(NodeMessagingClient.kt:76)
at net.corda.node.services.messaging.NodeMessagingClient$deliver$1$1.invoke(NodeMessagingClient.kt:429)
at net.corda.node.services.messaging.NodeMessagingClient$deliver$1$1.invoke(NodeMessagingClient.kt:76)
at net.corda.node.utilities.CordaPersistence.inTopLevelTransaction(CordaPersistence.kt:84)
at net.corda.node.utilities.CordaPersistence.transaction(CordaPersistence.kt:75)
at net.corda.node.utilities.CordaPersistence.transaction(CordaPersistence.kt:65)
at net.corda.node.services.messaging.NodeMessagingClient$deliver$1.invoke(NodeMessagingClient.kt:421)
at net.corda.node.services.messaging.NodeMessagingClient$deliver$1.invoke(NodeMessagingClient.kt:76)
at net.corda.node.utilities.AffinityExecutor$fetchFrom$1.get(AffinityExecutor.kt:44)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$1$thread$1.run(AffinityExecutor.kt:69)
Caused by: java.lang.IllegalStateException: Negative position -2904; p=123201377404004873, c=chunk:6d6cc,block:7fffffffffffffff,len:7fffffff,map:4b,max:9e8c40,next:7fffffffffffffff,pages:325,root:7fffffffffffffff,time:78ccfc8,version:6d6cc [1.4.194/6]
at org.h2.mvstore.DataUtils.newIllegalStateException(DataUtils.java:765)
at org.h2.mvstore.MVStore.readPageChunkReferences(MVStore.java:1382)
at org.h2.mvstore.MVStore.collectReferencedChunks(MVStore.java:1332)
at org.h2.mvstore.MVStore.collectReferencedChunks(MVStore.java:1337)
at org.h2.mvstore.MVStore.collectReferencedChunks(MVStore.java:1337)
at org.h2.mvstore.MVStore.collectReferencedChunks(MVStore.java:1317)
at org.h2.mvstore.MVStore.freeUnusedChunks(MVStore.java:1276)
at org.h2.mvstore.MVStore.storeNowTry(MVStore.java:1063)
at org.h2.mvstore.MVStore.storeNow(MVStore.java:1050)
at org.h2.mvstore.MVStore.commitAndSave(MVStore.java:1039)
at org.h2.mvstore.MVStore.beforeWrite(MVStore.java:2218)
at org.h2.mvstore.MVMap.beforeWrite(MVMap.java:1051)
at org.h2.mvstore.MVMap.put(MVMap.java:122)
at org.h2.mvstore.db.TransactionStore.log(TransactionStore.java:282)
at org.h2.mvstore.db.TransactionStore$Transaction.log(TransactionStore.java:706)
at org.h2.mvstore.db.TransactionStore$TransactionMap.trySet(TransactionStore.java:1115)
at org.h2.mvstore.db.TransactionStore$TransactionMap.set(TransactionStore.java:1027)
at org.h2.mvstore.db.TransactionStore$TransactionMap.remove(TransactionStore.java:989)
at org.h2.mvstore.db.MVSecondaryIndex.remove(MVSecondaryIndex.java:242)
... 42 more
persistence.mv.db
的大小超过300MB。
拥有Corda v2,我该如何解决这个错误? persistence.mv.db的庞大规模是否与它有关?
是这个陈述(检查上面的错误)
delete from node_checkpoints where checkpoint_id=? [90030-194]
在重新发生此错误时恢复数据库很有用吗?我该怎么用?
答案 0 :(得分:0)
似乎数据库文件已损坏。有一个H2恢复工具,可以生成可以重放的sql脚本。您可以在此处找到更多信息:http://www.h2database.com/html/advanced.html#using_recover_tool。