General error: java.lang.RuntimeException: rowCount expected 30845 got 31428

860 views
Skip to first unread message

Carl Sayres

unread,
Nov 4, 2009, 4:31:57 AM11/4/09
to H2 Database
I deleted a few thousand rows, then tried to insert one. Got the
following exception:

11-04 04:17:11 jdbc[2]: SQLException
org.h2.jdbc.JdbcSQLException: General error:
java.lang.RuntimeException: rowCount expected 30845 got 31428
PLAYERSEASON.FK_PLAYERSEASON_1_INDEX_B; SQL statement:
insert into public.PlayerSeason (Id, PlayerId, SeasonId, TeamId,
Active, Number, Position, Salary) values (null, ?, ?, ?, ?, ?, ?, ?)
[50000-122]
at org.h2.message.Message.getSQLException(Message.java:106)
at org.h2.message.Message.convert(Message.java:283)
at org.h2.table.TableData.addRow(TableData.java:149)
at org.h2.command.dml.Insert.insertRows(Insert.java:119)
at org.h2.command.dml.Insert.update(Insert.java:82)
at org.h2.command.CommandContainer.update(CommandContainer.java:72)
at org.h2.command.Command.executeUpdate(Command.java:209)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal
(JdbcPreparedStatement.java:139)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdate
(JdbcPreparedStatement.java:128)
at org.hibernate.id.IdentityGenerator
$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:94)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert
(AbstractReturningDelegate.java:57)
at org.hibernate.persister.entity.AbstractEntityPersister.insert
(AbstractEntityPersister.java:2186)
at org.hibernate.persister.entity.AbstractEntityPersister.insert
(AbstractEntityPersister.java:2666)
at org.hibernate.action.EntityIdentityInsertAction.execute
(EntityIdentityInsertAction.java:71)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at
org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate
(AbstractSaveEventListener.java:321)
at org.hibernate.event.def.AbstractSaveEventListener.performSave
(AbstractSaveEventListener.java:204)
at
org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId
(AbstractSaveEventListener.java:130)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId
(DefaultSaveOrUpdateEventListener.java:210)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient
(DefaultSaveOrUpdateEventListener.java:195)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate
(DefaultSaveOrUpdateEventListener.java:117)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate
(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:
534)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:526)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:522)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.context.ThreadLocalSessionContext
$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:
342)
at $Proxy0.saveOrUpdate(Unknown Source)
at com.fastmodel.fastscout.stats.Stats.updatePlayerInfo(Stats.java:
731)
at com.fastmodel.fastscout.stats.Stats.updateTeamAndPlayerInfo
(Stats.java:667)
at com.fastmodel.fastscout.stats.Stats.main(Stats.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:
90)
Caused by: java.lang.RuntimeException: rowCount expected 30845 got
31428 PLAYERSEASON.FK_PLAYERSEASON_1_INDEX_B
at org.h2.message.Message.throwInternalError(Message.java:186)
at org.h2.table.TableData.checkRowCount(TableData.java:160)
at org.h2.table.TableData.addRow(TableData.java:131)
... 36 more

Thomas Mueller

unread,
Nov 7, 2009, 2:26:31 AM11/7/09
to h2-da...@googlegroups.com
Hi,

What is the database URL? What options do you use? Is this using the
page store file format?

Regards,
Thomas

Meni Hillel

unread,
Jan 30, 2015, 10:35:52 AM1/30/15
to h2-da...@googlegroups.com
I've encountered same issue.

Exception in thread "main" org.h2.jdbc.JdbcSQLException: General error: "java.lang.RuntimeException: rowCount expected 17483 got 93586 T65.I140" [50000-175]

How do I recover out of this?

Meni Hillel

unread,
Jan 30, 2015, 10:37:12 AM1/30/15
to h2-da...@googlegroups.com
My URL:

jdbc:h2:./vmiDCDB;MVCC=TRUE;LOCK_TIMEOUT=10000;

Meni Hillel

unread,
Jan 30, 2015, 11:09:15 AM1/30/15
to h2-da...@googlegroups.com
I was able to recover using recovery tool. Nice!

I repeated the large deletion operation and again encountered issue which does not make any sense. I have few table with referential integrity and I delete records 'backwards' first from detail tables and then header table (where foreign key exist) and that fails on following error.

org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "FK_TASK_PRED_ID: PUBLIC.TASK_PREDECESSOR FOREIGN KEY(PREDECESSOR_ID) REFERENCES PUBLIC.TASK(ID) (1421)"; SQL statement:
DELETE FROM TASK WHERE completed_timestamp <= '2014-10-30 08:03:25' [23503-175]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:332)
    at org.h2.message.DbException.get(DbException.java:172)
    at org.h2.message.DbException.get(DbException.java:149)
    at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:421)
    at org.h2.constraint.ConstraintReferential.checkRowRefTable(ConstraintReferential.java:438)
    at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:314)
    at org.h2.table.Table.fireConstraints(Table.java:894)
    at org.h2.table.Table.fireAfterRow(Table.java:911)
    at org.h2.command.dml.Delete.update(Delete.java:100)
    at org.h2.command.CommandContainer.update(CommandContainer.java:79)
    at org.h2.command.Command.executeUpdate(Command.java:253)
    at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:181)
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:156)
Reply all
Reply to author
Forward
0 new messages