FAForever/faf-java-api

Posting map reviews fails

Brutus5000 opened this issue · 4 comments

Log from client:

2021-05-21 21:52:01.329  WARN 1592 --- [pool-3-thread-5] c.f.client.map.MapDetailController       : Review could not be saved

java.util.concurrent.CompletionException: org.springframework.web.client.HttpClientErrorException: 423 Locked: [{"errors":[{"detail":"could not execute statement"}]}]
	at org.springframework.aop.interceptor.AsyncExecutionAspectSupport.lambda$doSubmit$3(AsyncExecutionAspectSupport.java:279)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1764)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
	at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: org.springframework.web.client.HttpClientErrorException: 423 Locked: [{"errors":[{"detail":"could not execute statement"}]}]
	at org.springframework.web.client.HttpClientErrorException.create(HttpClientErrorException.java:145)
	at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:186)
	at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:125)
	at com.faforever.client.api.JsonApiErrorHandler.handleError(JsonApiErrorHandler.java:31)
	at org.springframework.security.oauth2.client.http.OAuth2ErrorHandler.handleError(OAuth2ErrorHandler.java:177)
	at org.springframework.web.client.ResponseErrorHandler.handleError(ResponseErrorHandler.java:63)
	at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:818)
	at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:776)
	at org.springframework.security.oauth2.client.OAuth2RestTemplate.doExecute(OAuth2RestTemplate.java:132)
	at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:710)
	at org.springframework.web.client.RestTemplate.postForEntity(RestTemplate.java:467)
	at com.faforever.client.api.FafApiAccessorImpl.post(FafApiAccessorImpl.java:672)
	at com.faforever.client.api.FafApiAccessorImpl.createMapVersionReview(FafApiAccessorImpl.java:452)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
	at com.sun.proxy.$Proxy74.createMapVersionReview(Unknown Source)
	at com.faforever.client.remote.FafService.saveMapVersionReview(FafService.java:423)
	at com.faforever.client.remote.FafService$$FastClassBySpringCGLIB$$6c91c77e.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
	at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
	at org.springframework.aop.interceptor.AsyncExecutionAspectSupport.lambda$doSubmit$3(AsyncExecutionAspectSupport.java:276)
	... 4 common frames omitted

do we have server logs?

No, I couldn't find anything (we have to many other errors being logged)

I was able to add reviews both on prod and on a local test instance so I am not sure where this error is coming from

Investigation showed that we can hit a duplicate key constraint if the user already posted a review. Seems that the client does not check this.

Error handling could be improved based on yahoo/elide#2205

In general this is not an API bug.