nitrite-java icon indicating copy to clipboard operation
nitrite-java copied to clipboard

Random crashes with exception "Fatal Exception: java.lang.IllegalStateException: Chunk 55267 not found"

Open lahiruchandima opened this issue 6 years ago • 8 comments

I randomly get below exceptions reported in my android app which uses nitrite 3.3.0.

   Fatal Exception: java.lang.IllegalStateException: Chunk 55267 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.Page$NonLeaf.getChildPage(Page.java:1043)
   at org.h2.mvstore.CursorPos.traverseDown(CursorPos.java:58)
   at org.h2.mvstore.MVMap.operate(MVMap.java:1804)
   at org.h2.mvstore.MVMap.putIfAbsent(MVMap.java:564)
   at org.dizitart.no2.store.NitriteMVMap.putIfAbsent(NitriteMVMap.java:105)
   at org.dizitart.no2.internals.DataService.insert(DataService.java:84)
   at org.dizitart.no2.internals.DataService.update(DataService.java:135)
   at org.dizitart.no2.internals.NitriteService.update(NitriteService.java:373)
   at org.dizitart.no2.internals.DefaultNitriteCollection.update(DefaultNitriteCollection.java:322)
   at org.dizitart.no2.objects.DefaultObjectRepository.update(DefaultObjectRepository.java:141)
   at org.dizitart.no2.objects.DefaultObjectRepository.update(DefaultObjectRepository.java:126)
   at com.my.app.DatabaseHelper.persistReceipt(DatabaseHelper.java:619)
   ...
   ...
   Caused by java.lang.IllegalStateException: Chunk 55194 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.Page$NonLeaf.getChildPage(Page.java:1043)
   at org.h2.mvstore.Cursor.hasNext(Cursor.java:53)
   at java.util.LinkedHashSet.<init>(LinkedHashSet.java:81)
   at org.dizitart.no2.filters.NotFilter.matchedSet(NotFilter.java:41)
   at org.dizitart.no2.filters.NotFilter.apply(NotFilter.java:52)
   at org.dizitart.no2.objects.filters.NotObjectFilter.apply(NotObjectFilter.java:51)
   at org.dizitart.no2.internals.SearchService.find(SearchService.java:67)
   at org.dizitart.no2.internals.DataService.remove(DataService.java:211)
   at org.dizitart.no2.internals.NitriteService.remove(NitriteService.java:384)
   at org.dizitart.no2.internals.DefaultNitriteCollection.remove(DefaultNitriteCollection.java:360)
   at org.dizitart.no2.objects.DefaultObjectRepository.remove(DefaultObjectRepository.java:176)
   at org.dizitart.no2.objects.DefaultObjectRepository.remove(DefaultObjectRepository.java:170)
   at com.my.app.DatabaseHelper.removeReceipts(DatabaseHelper.java:666)
   ...
   ...

I reported this issue in h2-database in following issue. The response from them was this could be due to not using registerVersionUsage() and deregisterVersionUsage(). I couldn't find these methods when I searched nitrite code, so this is a possibility.

https://github.com/h2database/h2database/issues/2590#issuecomment-735391116

If using registerVersionUsage() and deregisterVersionUsage() could affect performance, let the uses of nitrite configure whether it could be used or not.

lahiruchandima avatar Nov 30 '20 03:11 lahiruchandima

I'll take a look

anidotnet avatar Nov 30 '20 18:11 anidotnet

Code changes should be available in 3.4.3-SNAPSHOT. Please verify if that solves the issue or not.

anidotnet avatar Dec 01 '20 11:12 anidotnet

@anidotnet Unfortunately it is not easily re-producible this. Actually I tried to re-produce it by doing concurrent reads, writes and updates in high rates, but couldn't recreate it locally.

I get these crash reports randomly from android crash reporting of my app.

Thanks for fixing this anyway. If you can provide 3.4.3 release, I can upgrade to it. It is too risky for me to link the prod version to a snapshot.

lahiruchandima avatar Dec 01 '20 12:12 lahiruchandima

@anidotnet Can you please let us know roughly when we would be able to expect 3.4.3 to be released?

lahiruchandima avatar Dec 04 '20 01:12 lahiruchandima

As soon as possible.

anidotnet avatar Dec 04 '20 04:12 anidotnet

As soon as possible.

Thank you

lahiruchandima avatar Dec 04 '20 05:12 lahiruchandima

Version 3.4.3 is released now.

anidotnet avatar Dec 12 '20 11:12 anidotnet

Great! Thank you.

lahiruchandima avatar Dec 12 '20 13:12 lahiruchandima