| Summary: | cannot control delete order with unitofwork deleteobject(object) | ||||||
|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | john.vandale | ||||
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | david.minsky, john.vandale, peter.krogh | ||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 183811 [details]
fix orders deletes by PK sort order if specified in config
Checked into trunk (2.2) at revision: 8568 The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
Build Identifier: Deadlocks can occur when trying to delete a collection of objects using uow.deleteObject(objectToBeDeleted). In this reported use case the mapping of this object is one table without any relationship. The primary key is set in all objectToBeDeleted instances. It is impossible to have a deterministic order for generated delete SQL. DELETE is executed neither in the order in which the application calls deleteObject or in a PK value ordered fashion. Deadlocks may occur when concurrent delete/update are executed on the database. Whether or not a deadlock occurs a non-ordered delete sequence occurs every time. Reproducible: Sometimes Steps to Reproduce: Write an application which deletes objects e.g.: long[] ids = {800, 801, 802, 803, 804, 805, 806, 807, 808, 809}; UnitOfWork uow = getSession().acquireUnitOfWork(); uow.setShouldOrderUpdates(true); for (int i = 0; i < ids.length; i++) { Employee employee = new Employee(); employee.setId(new java.math.BigDecimal(ids[i])); Employee registeredEmployee = (Employee) uow.registerExistingObject(employee); uow.deleteObject(registeredEmployee); } uow.commit(); You will see the deletes seem to be in a random order e.g.: DELETE FROM EMPLOYEE WHERE (CNT_ID = ?)bind => [804] DELETE FROM EMPLOYEE WHERE (CNT_ID = ?)bind => [806] DELETE FROM EMPLOYEE WHERE (CNT_ID = ?)bind => [808] DELETE FROM EMPLOYEE WHERE (CNT_ID = ?)bind => [807] DELETE FROM EMPLOYEE WHERE (CNT_ID = ?)bind => [802] DELETE FROM EMPLOYEE WHERE (CNT_ID = ?)bind => [800] DELETE FROM EMPLOYEE WHERE (CNT_ID = ?)bind => [803] DELETE FROM EMPLOYEE WHERE (CNT_ID = ?)bind => [801] DELETE FROM EMPLOYEE WHERE (CNT_ID = ?)bind => [809] DELETE FROM EMPLOYEE WHERE (CNT_ID = ?)bind => [805]