sismics / docs

Lightweight document management system packed with all the features you can expect from big expensive solutions
https://teedy.io
GNU General Public License v2.0
1.98k stars 489 forks source link

Database error - chunk not found #669

Closed professor-farnsworth closed 1 year ago

professor-farnsworth commented 1 year ago

Hello! First thanks for this awesome software, I've been using it for years and love it.

So I am getting database errors (below) when the container is starting up. I'm using the default database engine, using this to start the container: docker run --name docs --restart unless-stopped -v /mypath:/data -d -p 4246:8080 -e DOCS_BASE_URL=https://myurl sismics/docs:latest

Don't know if this an H2 error and not really anything to do with the code here. I see from the stacktrace calls to things like "addIndex", so don't know if there's some other issue going on here. I don't know if this is enough to go on.... Does anyone have any ideas or things I can try? I have some backups, but would prefer to not lose data. If there isn't any sort of fix, would it be possible to get the data/documents back out of the system?

General error: "java.lang.IllegalStateException: Chunk 10496 not found [1.4.200/9]" [50000-200] at org.h2.message.DbException.getJdbcSQLException(DbException.java:505) at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) at org.h2.message.DbException.get(DbException.java:194) at org.h2.message.DbException.convert(DbException.java:347) at org.h2.engine.Database.openDatabase(Database.java:333) at org.h2.engine.Database.(Database.java:301) at org.h2.engine.Engine.openSession(Engine.java:74) at org.h2.engine.Engine.openSession(Engine.java:192) at org.h2.engine.Engine.createSessionAndValidate(Engine.java:171) at org.h2.engine.Engine.createSession(Engine.java:166) at org.h2.engine.Engine.createSession(Engine.java:29) at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:340) at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:173) at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:152) at org.h2.Driver.connect(Driver.java:69) at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1176) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1163) at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44) at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1908) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696) Caused by: java.lang.IllegalStateException: Chunk 10496 not found [1.4.200/9] at org.h2.mvstore.DataUtils.newIllegalStateException(DataUtils.java:950) at org.h2.mvstore.MVStore.getChunk(MVStore.java:1230) at org.h2.mvstore.MVStore.readBufferForPage(MVStore.java:1214) at org.h2.mvstore.MVStore.readPage(MVStore.java:2209) at org.h2.mvstore.MVMap.readPage(MVMap.java:672) at org.h2.mvstore.MVMap.readOrCreateRootPage(MVMap.java:688) at org.h2.mvstore.MVMap.setRootPos(MVMap.java:682) at org.h2.mvstore.MVStore.openMap(MVStore.java:576) at org.h2.mvstore.MVStore.openMap(MVStore.java:535) at org.h2.mvstore.tx.TransactionStore.openMap(TransactionStore.java:534) at org.h2.mvstore.tx.Transaction.openMap(Transaction.java:544) at org.h2.mvstore.db.MVSecondaryIndex.(MVSecondaryIndex.java:71) at org.h2.mvstore.db.MVTable.addIndex(MVTable.java:366) at org.h2.command.ddl.CreateIndex.update(CreateIndex.java:107) at org.h2.engine.MetaRecord.execute(MetaRecord.java:60) at org.h2.engine.Database.open(Database.java:759) at org.h2.engine.Database.openDatabase(Database.java:307) at org.h2.engine.Database.(Database.java:301) at org.h2.engine.Engine.openSession(Engine.java:74) at org.h2.engine.Engine.openSession(Engine.java:192) at org.h2.engine.Engine.createSessionAndValidate(Engine.java:171) at org.h2.engine.Engine.createSession(Engine.java:166) at org.h2.engine.Engine.createSession(Engine.java:29) at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:340) at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:173) at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:152) at org.h2.Driver.connect(Driver.java:69) at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1176) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1163) at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44) at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1908) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696) 2023-03-21 20:03:50.653:INFO:oejs.AbstractConnector:main: Started ServerConnector@71c1ca1{HTTP/1.1, (http/1.1)}{0.0.0.0:8080} 2023-03-21 20:03:50.654:INFO:oejs.Server:main: Started @121786ms

jendib commented 1 year ago

It seems to be data corruption in your H2 data files. I very highly suggest you to migrate to PostgreSQL for a production system.

professor-farnsworth commented 1 year ago

So seeing as it appears a connection to the database can't be opened, probably no good way to migrate to postrgres..... so screwed? Guess I'll have to accept the data loss and move on?

jendib commented 1 year ago

You can try opening an issue on the h2 database project, they may have processes to recover data.

professor-farnsworth commented 1 year ago

So I restored my entire /data directory from a backup from a few days back and I pulled v1.11 and everything worked fine. When I upgraded and pulled latest, I started getting that error again. Going back to v1.11 still shows the error. Is it possible something in the newest version corrupts the database? I understandably don't want to give a copy of the database, but can I provide logs or anything to help chase the issue? I re-restored my data and I will stay on v1.11 for now.

Also, do you guys have a guide for migrating from H2 to postgres?

jendib commented 1 year ago

In the latest version I upgraded h2 from 1.4.199 to 1.4.200. I innocently though that a minor version would be data compatible but apparently it's not. I will revert this upgrade and re-release 1.11

jendib commented 1 year ago

I realized that the dependency upgrade in NOT in 1.11, so you upgraded to the development version? Anyway the upgrade is reverted.

professor-farnsworth commented 1 year ago

I had the container setup using "latest", and watchtower auto-pulled it in the last few days. I'm guessing that's the development version? Is there a stable tag? Or just stay on the last version and manually test upgrades?

jendib commented 1 year ago

That's right, latest is rebuilt from the master branch. You should stay on numbered versions, and I could add a stable tag for sure.

professor-farnsworth commented 1 year ago

Awesome, thanks for the help and looking at this!