Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete Patient Permanently RS service results in misleading Delete x instances of study log messages and fails with ConstraintViolationException #4075

Closed
vrindanayak opened this issue May 30, 2023 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@vrindanayak
Copy link
Member

Describe the bug
Delete Patient Permanently RS service fails with ConstraintViolationException

2023-05-30 08:22:41,656 INFO  [org.dcm4chee.arc.delete.impl.DeletionServiceImpl] (default task-3) Successfully delete Study[pk=295, uid=1.2.276.0.7230010.3.1.2.895706167.1.1681304887.578845, id=2898766] from database
2023-05-30 08:22:41,706 INFO  [org.dcm4chee.arc.patient.impl.PatientServiceEJB] (default task-3) Successfully removed Patient[pk=406, id=[-489416941], name=Schneider^Sophia] from database along with any of its MPPS, MWLs and UPS

2023-05-30 08:22:41,712 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-3) ERROR: update or delete on table "patient" violates foreign key constraint "fk_e3fdaqhw7u60trs5aspf4sna9" on table "study"
  Detail: Key (pk)=(406) is still referenced from table "study".
2023-05-30 08:22:41,715 INFO  [org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl] (default task-3) HHH000010: On release of batch it still contained JDBC statements
2023-05-30 08:22:41,725 ERROR [org.hibernate.internal.ExceptionMapperStandardImpl] (default task-3) HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement]
2023-05-30 08:22:41,726 WARN  [com.arjuna.ats.arjuna] (default task-3) ARJUNA012125: TwoPhaseCoordinator.beforeCompletion - failed for SynchronizationImple< 0:ffffc0a802df:1ed6ebab:647595c6:25c9, org.wildfly.transaction.client.AbstractTransaction$AssociatingSynchronization@387fc447 >: javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
..........
at deployment.dcm4chee-arc-ear-5.30.0-psql.ear.dcm4chee-arc-patient-5.30.0.jar//org.dcm4chee.arc.patient.impl.PatientServiceEJB$Proxy$_$$_Weld$EnterpriseProxy$.deletePatient(Unknown Source)
	at deployment.dcm4chee-arc-ear-5.30.0-psql.ear.dcm4chee-arc-patient-5.30.0.jar//org.dcm4chee.arc.patient.impl.PatientServiceImpl.deletePatient(PatientServiceImpl.java:250)
	at deployment.dcm4chee-arc-ear-5.30.0-psql.ear.dcm4chee-arc-patient-5.30.0.jar//org.dcm4chee.arc.patient.impl.PatientServiceImpl$Proxy$_$$_WeldClientProxy.deletePatient(Unknown Source)
	at deployment.dcm4chee-arc-ear-5.30.0-psql.ear.dcm4chee-arc-delete-5.30.0.jar//org.dcm4chee.arc.delete.impl.DeletionServiceImpl.deletePatient(DeletionServiceImpl.java:187)
	at deployment.dcm4chee-arc-ear-5.30.0-psql.ear.dcm4chee-arc-delete-5.30.0.jar//org.dcm4chee.arc.delete.impl.DeletionServiceImpl$Proxy$_$$_WeldClientProxy.deletePatient(Unknown Source)
	at deployment.dcm4chee-arc-ear-5.30.0-psql.ear.dcm4chee-arc-war-5.30.0-unsecure.war//org.dcm4chee.arc.iocm.rs.PamRS.deletePatient(PamRS.java:192)
	at deployment.dcm4chee-arc-ear-5.30.0-psql.ear.dcm4chee-arc-war-5.30.0-unsecure.war//org.dcm4chee.arc.iocm.rs.PamRS$Proxy$_$$_WeldSubclass.deletePatient(Unknown Source)
	at deployment.dcm4chee-arc-ear-5.30.0-psql.ear.dcm4chee-arc-war-5.30.0-unsecure.war//org.dcm4chee.arc.iocm.rs.PamRS$Proxy$_$$_WeldClientProxy.deletePatient(Unknown Source)
..........
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "patient" violates foreign key constraint "fk_e3fdaqhw7u60trs5aspf4sna9" on table "study"
  Detail: Key (pk)=(406) is still referenced from table "study".

To Reproduce
Steps to reproduce the behavior:

  1. Store study with 1863 instances
  2. Configure Allow Delete Patient and Allow Delete Study permanently to ALWAYS
  3. Keep Delete Study Chunk Size configured to default 100
  4. See error in server_deleteStudyChunkSize_100.log
  5. Misleading Delete x instances of study log
    2023-05-30 08:22:17,541 DEBUG [org.dcm4chee.arc.delete.impl.DeletionServiceEJB] (default task-3) Deleted 98 instances of Study[pk=295]
    2023-05-30 08:22:17,547 DEBUG [org.dcm4chee.arc.delete.impl.DeletionServiceImpl] (default task-3) Deleted 100 instances of Study[pk=295, uid=1.2.276.0.7230010.3.1.2.895706167.1.1681304887.578845, id=2898766]
    

Expected behavior
Delete Patient Permanently RS service works as expected independent of the configured Delete Study Chunk Size

Related #2549

@vrindanayak vrindanayak added the bug Something isn't working label May 30, 2023
@vrindanayak vrindanayak added this to the 5.30.0 milestone May 30, 2023
gunterze added a commit that referenced this issue May 31, 2023
… instances of study log messages and fails with ConstraintViolationException fix #4075
vrindanayak added a commit that referenced this issue Jun 2, 2023
… misleading Delete x instances of study log messages and fails with ConstraintViolationException #4075
vrindanayak added a commit that referenced this issue Jun 2, 2023
… misleading Delete x instances of study log messages and fails with ConstraintViolationException #4075
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants