eu-federation-gateway-service/efgs-federation-gateway

CallbackTask deletion runs into SQL error

f11h opened this issue · 0 comments

f11h commented

Describe the bug

After a callback has been successfully sent to subscriber the CallbackTask will be deleted and the following CallbackTask will be activated (setting "notBefore" property to null).

In some cases the deletion of the CallbackTask runs into a SQL error:

org.springframework.orm.ObjectOptimisticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; statement executed: delete from callback_task where id=?;
nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; statement executed: delete from callback_task where id=?,
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:340),
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:255),
at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:538),
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:743),
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711),
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:633),
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:3
...

Expected behaviour

Callback ist sent -> notBefore-property of following task set to NULL --> CallbackTask deleted.
--> No error messages

Steps to reproduce the issue

  1. Subscribe for callback
  2. Upload keys (for creating at least 2 batches)
  3. CallbackTasks will be created by EFGS
  4. Callback will be executed
  5. See error log when CallbackTask will be deleted

Possible Fix

The methods CallbackTaskExecutor are decorated with @Transactional. The annotations are kind of useless because these methods were only called by same class. To make these annotations having an impact on the behaviour we need to move them out of the CallbackTaskExecutor class. (Like we did it with DiagnosisKeyBatchService --> TransactionalDiagnosisKeyBatchService)

Additional context

At the moment we cannot reliable reproduce the bug.