Defect #1473
closedManually deleted contract slice causes failure of reconcilation
100%
Description
Version: 9.3.4
Steps to reproduce:- Synchronize time slices from HR system
- Manually delete one of the synchronized slices
- Run the reconcilation of slices
- The reconcilation fails when it starts to process missing accounts (after all existing are successfully processed). The deleted slice falls to "Unknown state". No other missing accounts are processed.
The reason is that the AccContractSliceAccount and AccAccount are not deleted together with manually deleted slice.
The problem occurs only for manually deleted slices. Deleting contract slices by reconcilation works fine.
The error in the reconcilation log:
2019-01-27T00:24:59.738+01:00: System entity (33a9e372-0781-4816-be20-57f7b5ac0c38) for this UID (9999_0_2019_1_25) was found. We try to find account for this system entity ------------------------- 2019-01-27T00:24:59.742+01:00: org.springframework.orm.jpa.JpaObjectRetrievalFailureException: Unable to find eu.bcvsolutions.idm.core.model.entity.IdmContractSlice with id d95bcc96-f0e4-4486-8d92-63a2146a008c; nested exception is javax.persistence.EntityNotFoundException: Unable to find eu.bcvsolutions.idm.core.model.entity.IdmContractSlice with id d95bcc96-f0e4-4486-8d92-63a2146a008c ..... ------------------------- 2019-01-27T00:24:59.743+01:00: Operation count for [UNKNOWN] is [1] ------------------------- 2019-01-27T00:24:59.744+01:00: org.springframework.orm.jpa.JpaObjectRetrievalFailureException: Unable to find eu.bcvsolutions.idm.core.model.entity.IdmContractSlice with id d95bcc96-f0e4-4486-8d92-63a2146a008c; nested exception is javax.persistence.EntityNotFoundException: Unable to find eu.bcvsolutions.idm.core.model.entity.IdmContractSlice with id d95bcc96-f0e4-4486-8d92-63a2146a008c at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:389)
Updated by Alena Peterová almost 6 years ago
Workaround which works for me: When I want to delete slice manually, I must first delete its account and the Account in the system.
SQL script to find and delete accounts, which are linked to non-existent slices:
select aa.uid, csa.contract_slice_id from acc_account aa join acc_contract_slice_account csa on csa.account_id = aa.id left join idm_contract_slice cs on csa.contract_slice_id=cs.id where cs.id is null; select csa.id from acc_contract_slice_account csa left join idm_contract_slice cs on csa.contract_slice_id=cs.id where cs.id is null; delete from acc_account where id in (select aa.id from acc_account aa join acc_contract_slice_account csa on csa.account_id = aa.id left join idm_contract_slice cs on csa.contract_slice_id=cs.id where cs.id is null); delete from acc_contract_slice_account where id in (select csa.id from acc_contract_slice_account csa left join idm_contract_slice cs on csa.contract_slice_id=cs.id where cs.id is null);
Updated by Vít Švanda almost 6 years ago
- Status changed from New to In Progress
- Assignee changed from Radek Tomiška to Vít Švanda
- Target version set to Opal (9.4.0)
Updated by Vít Švanda almost 6 years ago
It is my fault. I modified conditionl for start SliceDeleteProcessor in ACC module. Because we don´t wont delete the slice account, when core slice is only marked to delete (this acc processor is call before delete slice procesor).
Problem is in condition (should be invert).
Workaround: disable the "accContractSliceDeleteProcessor"
and create new with code from:
Fix commit: https://github.com/bcvsolutions/CzechIdMng/commit/bf2d5d62e135643a26d65be1d6d2b2cf16021e6c
Test commit: https://github.com/bcvsolutions/CzechIdMng/commit/1b10a4c38563756c2d2d527b4f819c1d97ec3664
Updated by Vít Švanda almost 6 years ago
- Status changed from In Progress to Needs feedback
- Assignee changed from Vít Švanda to Radek Tomiška
Updated by Radek Tomiška almost 6 years ago
- Status changed from Needs feedback to Resolved
- Assignee changed from Radek Tomiška to Vít Švanda
- % Done changed from 0 to 100
I did test and review, it works, thx!
Note: one line of production code and 57 lines of test code :)