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:
Vlad Mihalcea
November 9, 2017, 12:19 AM

Looking forward to getting your new test case. We have several tests to check all associations, but the number of possible combinations is, indeed, large.

If you have a better solution, feel free to send us a Pull Request as well.

AndersW
November 9, 2017, 12:39 AM

I've got a partial solution based on a depth first topological sort, but it doesn't pass all tests either, so needs some work...

AndersW
November 9, 2017, 12:39 AM

But I'll finish the new test case first.

AndersW
November 10, 2017, 1:10 AM

I've got a new test case ready – see https://hibernate.atlassian.net/browse/HHH-12086 (pull request on its way).

Gail Badner
March 20, 2018, 1:55 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