Inconsistent element count commig after store call
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:
- How can I reproduce it in Unit Testing?
- 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.
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.
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