ActionQueue#InsertActionSorter fails to generate right order

Description

After migration from 4.2.x to 5.2.9 batching susbsystem stops working we got

1 2 08:46:59,871 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-53) ERROR: duplicate key value violates unique constraint "pk_purchase_document" Details: Key (id_purchase_document)=(266985) already exists.

Test case
https://github.com/MirekSz/hibernate-HHH-11634
In screenshots you can see what is wrong. In action queue there are 3 elements with the same id (hash = 5167) which generates after all inserting 3 times elements with the same id (with hibernate.order_inserts false it works)

Config:
hibernate.order_inserts true
hibernate.jdbc.batch_size 10

I also try SNAPSHOT VER after but the same error occurs

Environment

Hibernate 5.2.9, PostgreSQL

Status

Assignee

Vlad Mihalcea

Reporter

Mirek

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

4.2.19
4.3.10

Components

Affects versions

5.2.9

Priority

Critical