Batch order_inserts: flush during transaction causes incorrect insert ordering and subsequent constraint violation

Description

A flush during a transaction can cause the org.hibernate.engine.spi.ActionQueue.InsertActionSorter#sort implementation to produce an incorrect ordering with subsequent constraint violation.

A simple test case is attached.

Environment

None

Activity

Show:
AndersW
November 10, 2017, 1:04 AM

I cloned since I'm not sure the right approach is to reopen it (plus, I don't have permissions to do that).

This is for the second test case, which I'll create a pull request for.

AndersW
November 10, 2017, 1:40 AM
AndersW
November 10, 2017, 3:16 AM

BTW, if you prefer to reopen and continue tracking this issue there, then please dispose of this issue any way you want.

Vlad Mihalcea
November 13, 2017, 8:52 AM

Fixed with a bubble-sort-like approach.

Gail Badner
March 20, 2018, 1:52 AM

Fixed in 5.1 branch as well.

Assignee

Vlad Mihalcea

Reporter

AndersW

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure