Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to disable or clear SequenceAllocation in PolyJDBC #532

Closed
mdii opened this issue Apr 10, 2017 · 4 comments
Closed

Possibility to disable or clear SequenceAllocation in PolyJDBC #532

mdii opened this issue Apr 10, 2017 · 4 comments
Labels

Comments

@mdii
Copy link
Contributor

mdii commented Apr 10, 2017

Hello,

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.

@bartoszwalacik
Copy link
Member

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?

@mdii
Copy link
Contributor Author

mdii commented Apr 12, 2017

Sure, I can create the corresponding PRs.

@bartoszwalacik
Copy link
Member

Ok, so now we have the new feature in polyjdbc. Feel free to create corresponding PR to javers

mdii added a commit to mdii/javers that referenced this issue Apr 24, 2017
mdii added a commit to mdii/javers that referenced this issue Apr 25, 2017
mdii added a commit to mdii/javers that referenced this issue Apr 25, 2017
bartoszwalacik added a commit that referenced this issue May 6, 2017
…ation-cache

#532 possibility to clear SequenceAllocation cache
@bartoszwalacik
Copy link
Member

released in 3.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants