[hibernate-issues] [JIRA] (HHH-10683) Pooled id generation optimizer is causing ids from sequences to be reused

Liam Clarke (JIRA) jira at hibernate.atlassian.net
Thu Mar 19 23:29:29 EDT 2020


Liam Clarke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Ae4789ac7-8bbf-43b2-9359-440079abf2fb ) *commented* on HHH-10683 ( https://hibernate.atlassian.net/browse/HHH-10683?atlOrigin=eyJpIjoiZWI1ZDRjNDE5MmJmNDVmMDkyYTkyZDMzZGFmYjUyNjAiLCJwIjoiaiJ9 )

Re: Pooled id generation optimizer is causing ids from sequences to be reused ( https://hibernate.atlassian.net/browse/HHH-10683?atlOrigin=eyJpIjoiZWI1ZDRjNDE5MmJmNDVmMDkyYTkyZDMzZGFmYjUyNjAiLCJwIjoiaiJ9 )

I’ve just hit this issue in Hibernate 5.4.12 Final (upgraded from Hibernate 4.3.x) against Postgres, same symptom - Hibernate attempts to insert a PK that is the DBs’s nextval - allocationSize (which defaults to 50 on the JPA @SequenceGenerator annotation). We didn’t have the same issue with Hibernate 4.3

insert into BACKFILL (HTML, IS_USED, ID) values (NULL, 'FALSE', 12029) was aborted: ERROR: duplicate key value violates unique constraint

...

psql (11.5 (Debian 11.5-3.pgdg90+1))
Type "help" for help.

test=> select nextval('backfill_seq');
nextval
---------
  12079
(1 row)

Setting hibernate.id.optimizer.pooled.prefer_lo to true as mentioned by the original reporter also fixed the issue for me. I will try to attach a unit test to reproduce when I get time.

( https://hibernate.atlassian.net/browse/HHH-10683#add-comment?atlOrigin=eyJpIjoiZWI1ZDRjNDE5MmJmNDVmMDkyYTkyZDMzZGFmYjUyNjAiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-10683#add-comment?atlOrigin=eyJpIjoiZWI1ZDRjNDE5MmJmNDVmMDkyYTkyZDMzZGFmYjUyNjAiLCJwIjoiaiJ9 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100122- sha1:52999ef )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200320/c2dd290e/attachment.html 


More information about the hibernate-issues mailing list