microstream icon indicating copy to clipboard operation
microstream copied to clipboard

Inconsistent element count commig after store call

Open helenoalves opened this issue 2 years ago • 2 comments

Hi Microstream Team,

I`m using microstream and receiving this error on the log from time to time: Inconsistent element count: specified 2 vs. iterated 8756688418745

For sure, with a different number of specified and iterated. It happens on the part of code that I call store method of one collection.

I made several changes to this collection, such as removing and adding elements in a map that contains two nested Queues as values.

This is the microstream part of the code I have found this error:

https://github.com/microstream-one/microstream/blob/d589e94ceb3f6d69f4d955b6244c411d454e3847/persistence/binary/src/main/java/one/microstream/persistence/binary/types/Binary.java#L2009

I need two answers about it:

  1. How can I reproduce it in Unit Testing?
  2. Is there some approach that I should follow to overcome this issue? As calling storeRoot every time I change the root collection.

Looking forward to your support.

helenoalves avatar Dec 27 '23 22:12 helenoalves

Hello, Do you access the collection from multiple threads? If so, it is very likely that another thread modified the collection while Microstream did the store operation. The required synchronization can’t be done by Microstream and must be done by the application.

hg-ms avatar Jan 09 '24 11:01 hg-ms

I got it! It can be a probable cause. Besides that, I have found that I was trying to store an empty collection in that case. So, I isolated the case and caught the BinaryPersistenceException.

I am happy to hear one response. Thanks

helenoalves avatar Jan 09 '24 11:01 helenoalves