We are experiencing a weird behavior and would like to ask if someone has encountered a similar case before.
- We are using Hibernate 5.2.15.Final + SQL Server 2014 Standard Edition
- We are parsing text files and inserting them into the staging tables for further processing
- Each file is parsed and inserted in a single thread, using batches of 2k rows
- There can be multiple files being parsed at the same time - throttled by JMS listener (1 msg per file)
- We are using SQL Server Sequences with allocation/increase of 1000 configured on both Entity and Sequence
- We are not using Hibernate’s batching
7, The application is the only source of data for the stating tables so there is no possibility of some other process breaking the PKs
- We increase the parallelism level on SQL Server from 1 to 4
- We are getting lots of “Violation of PRIMARY KEY constraint” errors during the inserting to the staging tables
- We decrease the parallelism level back to 1
- Errors are gone and the data is inserted correctly.
Somehow the increased parallelism is breaking the sequence management either in SQL Server or in Hibernate. Does someone know what can be the cause or what to check?