alfio-event / alfio-event/alf.io

cleanupExpiredPendingReservation - ERROR: update or delete on table "tickets_reservation" violates foreign key constraint "ticket_tickets_reservation_id_fkey" on table "ticket"

Đang mở
#848 4 bình luận 0 reaction 1 người được giao Được @cbellone nhận Xem trên GitHub
bug
Ngôn ngữ chính
Java
Star
1.6k
Fork
396
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**Describe the bug**
It seems that the `cleanupExpiredPendingReservation` is failing trying to cleaning up some not finished reservations.

**To Reproduce**
Don't know how to reproduce it, sorry 😅

**Expected behavior**
What we should expect is probably let the job continue and not fail, because starting from then, all the "pending" Reservations are not going to be cancelled and ***they will remain forever*** in the system.

**Screenshots**
![image](https://user-images.githubusercontent.com/2370634/70668075-d4c8cb80-1c72-11ea-88d6-232d29ea195b.png)

**Stacktrace **
```
rg.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [delete from tickets_reservation where id in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; ERROR: update or delete on table "tickets_reservation" violates foreign key constraint "ticket_tickets_reservation_id_fkey" on table "ticket"
2019-12-11T23:41:14+01:00 22:41:14.081 [scheduling-1] ERROR org.springframework.scheduling.support.TaskUtils$LoggingErrorHandler - Unexpected error occurred in scheduled task.
2019-12-11T23:41:14+01:00 at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:246) ~[spring-jdbc-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) ~[spring-jdbc-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 Detail: Key is still referenced from table "ticket".; nested exception is org.postgresql.util.PSQLException: ERROR: update or delete on table "tickets_reservation" violates foreign key constraint "ticket_tickets_reservation_id_fkey" on table "ticket"
2019-12-11T23:41:14+01:00 Detail: Key is still referenced from table "ticket".
2019-12-11T23:41:14+01:00 at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:632) ~[spring-jdbc-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1442) ~[spring-jdbc-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:861) ~[spring-jdbc-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:882) ~[spring-jdbc-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at com.sun.proxy.$Proxy89.remove(Unknown Source) ~[?:?]
2019-12-11T23:41:14+01:00 at alfio.manager.TicketReservationManager.cleanupExpiredReservations(TicketReservationManager.java:1008) ~[classes!/:?]
2019-12-11T23:41:14+01:00 at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.update(NamedParameterJdbcTemplate.java:320) ~[spring-jdbc-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at ch.digitalfondue.npjt.QueryType$2.apply(QueryType.java:109) ~[npjt-extra-1.1.5.jar!/:?]
2019-12-11T23:41:14+01:00 at ch.digitalfondue.npjt.QueryFactory$3.invoke(QueryFactory.java:229) ~[npjt-extra-1.1.5.jar!/:?]
2019-12-11T23:41:14+01:00 at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749) ~[spring-aop-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at alfio.manager.TicketReservationManager$$FastClassBySpringCGLIB$$e08939fb.invoke() ~[classes!/:?]
2019-12-11T23:41:14+01:00 at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88) ~[spring-aop-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at jdk.internal.reflect.GeneratedMethodAccessor62.invoke(Unknown Source) ~[?:?]
2019-12-11T23:41:14+01:00 at alfio.config.RowLevelSecurity$RoleAndOrganizationsAspect.setRoleAndVariable(RowLevelSecurity.java:139) ~[classes!/:?]
2019-12-11T23:41:14+01:00 at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
2019-12-11T23:41:14+01:00 at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
2019-12-11T23:41:14+01:00 at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) ~[spring-aop-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644) ~[spring-aop-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633) ~[spring-aop-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175) ~[spring-aop-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) ~[spring-tx-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295) ~[spring-tx-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93) ~[spring-aop-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at alfio.manager.TicketReservationManager$$EnhancerBySpringCGLIB$$4598fa5.cleanupExpiredReservations() ~[classes!/:?]
2019-12-11T23:41:14+01:00 at jdk.internal.reflect.GeneratedMethodAccessor76.invoke(Unknown Source) ~[?:?]
2019-12-11T23:41:14+01:00 at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) ~[spring-aop-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
2019-12-11T23:41:14+01:00 at alfio.job.Jobs.cleanupExpiredPendingReservation(Jobs.java:180) ~[classes!/:?]
2019-12-11T23:41:14+01:00 at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84) ~[spring-context-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
2019-12-11T23:41:14+01:00 at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
2019-12-11T23:41:14+01:00 at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) [?:?]
2019-12-11T23:41:14+01:00 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
2019-12-11T23:41:14+01:00 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
2019-12-11T23:41:14+01:00 at java.lang.Thread.run(Thread.java:834) [?:?]
2019-12-11T23:41:14+01:00 at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) [?:?]
2019-12-11T23:41:14+01:00 Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "tickets_reservation" violates foreign key constraint "ticket_tickets_reservation_id_fkey" on table "ticket"
2019-12-11T23:41:14+01:00 at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308) ~[postgresql-42.2.5.jar!/:42.2.5]
2019-12-11T23:41:14+01:00 at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) ~[postgresql-42.2.5.jar!/:42.2.5]
2019-12-11T23:41:14+01:00 Detail: Key is still referenced from table "ticket".
2019-12-11T23:41:14+01:00 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440) ~[postgresql-42.2.5.jar!/:42.2.5]
2019-12-11T23:41:14+01:00 at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183) ~[postgresql-42.2.5.jar!/:42.2.5]
2019-12-11T23:41:14+01:00 at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365) ~[postgresql-42.2.5.jar!/:42.2.5]
2019-12-11T23:41:14+01:00 at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:120) ~[postgresql-42.2.5.jar!/:42.2.5]
2019-12-11T23:41:14+01:00 at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61) ~[HikariCP-3.3.1.jar!/:?]
2019-12-11T23:41:14+01:00 at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java) ~[HikariCP-3.3.1.jar!/:?]
2019-12-11T23:41:14+01:00 at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143) ~[postgresql-42.2.5.jar!/:42.2.5]
2019-12-11T23:41:14+01:00 at org.springframework.jdbc.core.JdbcTemplate.lambda$update$0(JdbcTemplate.java:866) ~[spring-jdbc-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
2019-12-11T23:41:14+01:00 ... 39 more
```

**Version:**
v.2.0-M2-SNAPSHOT

**Desktop (please complete the following information):**
N/A

**Smartphone (please complete the following information):**
N/A

**Additional context**
Add any other context about the problem here.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.