You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered again the issue I reported in #506.
We are using Javers with Spring boot and H2 as the test database. Before each test we truncate all the tables and reset the sequences. We don't reinitialize the Spring context before each test because it is quite time consuming. Therefore, we need to reset any state/cache before each test, including the sequecne cache in SequenceAllocation.
Basically, if we don't clear the sequence cache, the following situation might happen (assuming 50 as the size of the sequence batch):
Before test A: spring context is initialized. Before test A: all tables are truncated and all sequences are reset In test A: sequence numbers 1 to 50 are cached and JaVers uses sequence 1 to 30. Before test B: all tables are truncated and all sequences are reset In test B: sequence numbers 31 to 50 are still in the cache. JaVers uses these values and ask the DB for the next batch of sequence numbers, which are again 1 to 50. JaVers uses these values but when it want to store a row in the DB with sequence number 31, an exception occurs since a row with this primary key already exists.
The text was updated successfully, but these errors were encountered:
Ok, now the problem description is clear.
We can add the mothod JaversSqlRepository.evictSequenceAllocation() but first, it
should be implemented in https://github.com/polyjdbc/polyjdbc
Are you eager to contribute?