# H2 Database Corruption

**URL:** <https://ask.lenses.io/t/h2-database-corruption/396>\
**Category:** General\
**Created:** [July 1, 2025, 9:17am UTC](https://ask.lenses.io/t/h2-database-corruption/396 "2025-07-01T09:17:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![iMajna](https://dub1.discourse-cdn.com/flex017/user_avatar/ask.lenses.io/imajna/32/116_2.png) [@iMajna](https://ask.lenses.io/u/iMajna)\
**Post date:** [July 1, 2025, 9:17am UTC](https://ask.lenses.io/t/h2-database-corruption/396/1 "2025-07-01T09:17:25Z")

</div>

After patching several of our Kubernetes servers, I noticed that Lenses won’t start up any longer and the container continually crash-loops. When I look at the logs I noticed the following error message just before the pod is killed:

```auto
Caused by: org.h2.jdbc.JdbcSQLNonTransientConnectionException: File corrupted while reading record: null. Possible solution: use the recovery tool [90030-199]

```

I’m not sure how to use a recovery tool on the db file(s) or if there’s another way to restore it so Lenses will be able to successfully start up.

---

<div class="post-metadata">

**Author:** ![iMajna](https://dub1.discourse-cdn.com/flex017/user_avatar/ask.lenses.io/imajna/32/116_2.png) [@iMajna](https://ask.lenses.io/u/iMajna)\
**Post date:** [July 1, 2025, 9:20am UTC](https://ask.lenses.io/t/h2-database-corruption/396/2 "2025-07-01T09:20:50Z")

</div>

You can recover the database following the next steps

1. Bash into the Lenses pod
2. Stop Lenses process

```auto
supervisorctl stop lenses

```

1. Run Recover command

```bash
java -cp /opt/lenses/lib/h2-1.4.199.jar org.h2.tools.Recover -dir /data/lenses -db lensesdb

```

1. The previous command creates some files with the data to restore

```bash
java -cp /opt/lenses/lib/h2-1.4.199.jar org.h2.tools.RunScript -url jdbc:h2:/data/lenses/lenses_new -script /data/lenses/lensesdb.h2.sql

```

1. Replace the old file

```bash
rm /data/lenses/lenses.mv.db mv /data/lenses/lenses_new.mv.db /data/lenses/lensesdb.mv.db

```

1. Restart lenses

```auto
supervisorctl start lenses

```

If you still see the error such as

```auto
root@lenses / $ java -cp /opt/lenses/lib/h2-1.4.199.jar org.h2.tools.Recover -dir /data/storage -db lensesdb
Exception in thread "main" java.lang.IllegalStateException: File corrupted in chunk 10847521, expected page length 4..3072, got 942813497 [1.4.199/6]
        at org.h2.mvstore.DataUtils.newIllegalStateException(DataUtils.java:883)
        at org.h2.mvstore.MVStore.readBufferForPage(MVStore.java:1055)
        at org.h2.mvstore.MVStore.readPage(MVStore.java:2186)
        at org.h2.mvstore.MVMap.readPage(MVMap.java:554)
        at org.h2.mvstore.Page$NonLeaf.getChildPage(Page.java:1086)
        at org.h2.mvstore.Cursor.hasNext(Cursor.java:53)
        at org.h2.mvstore.MVStore.readStoreHeader(MVStore.java:793)
        at org.h2.mvstore.MVStore.<init>(MVStore.java:401)
        at org.h2.mvstore.MVStore$Builder.open(MVStore.java:3343)
        at org.h2.mvstore.MVStoreTool.info(MVStoreTool.java:347)
        at org.h2.tools.Recover.process(Recover.java:344)
        at org.h2.tools.Recover.runTool(Recover.java:195)
        at org.h2.tools.Recover.main(Recover.java:158)
root@lenses / $ 

```

Try to download **h2-1.4.200.jar** from Maven and used it instead to perform the same _Recover_ command with that version.  
Afterwards you can reuse \*\* h2-1.4.199\*\* to perform RunScript and to create new database file.
