Skip to content

Duplicate db entry causes the result upload to fail #21

@zguesmi

Description

@zguesmi

In integration tests, the worker fails with this error when it tries to push the result:

2021-08-31 10:24:45.313 ERROR 1 --- [         task-8] c.i.worker.executor.TaskManagerService   : Failed to upload result [chainTaskId:'0x534080c0504c69b799c3b2f8be7bc7aee69c69d9a6945072f76c07e472e46b80', cause:'RESULT_LINK_MISSING']

This exception appears in the result proxy logs:

2021-08-31 10:24:39.216  INFO 1 --- [io-13200-exec-6] c.i.resultproxy.proxy.ProxyController    : Result uploaded successfully [chainTaskId:0x534080c0504c69b799c3b2f8be7bc7aee69c69d9a6945072f76c07e472e46b80, uploadRequester:0x1a69b2eb604db8eba185df03ea4f5288dcbbd248, resultLink:/ipfs/QmQZqGJoSWWgjNs5gNAbNPs8D5qviMXqrqgKNZ8fg23ZU6]
2021-08-31 10:24:39.272 ERROR 1 --- [io-13200-exec-8] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.IncorrectResultSizeDataAccessException: Query { "$java" : Query: { "taskId" : "0x534080c0504c69b799c3b2f8be7bc7aee69c69d9a6945072f76c07e472e46b80"}, Fields: {}, Sort: {} } returned non unique result.] with root cause

org.springframework.dao.IncorrectResultSizeDataAccessException: Query { "$java" : Query: { "taskId" : "0x534080c0504c69b799c3b2f8be7bc7aee69c69d9a6945072f76c07e472e46b80"}, Fields: {}, Sort: {} } returned non unique result.
	at org.springframework.data.mongodb.core.ExecutableFindOperationSupport$ExecutableFindSupport.oneValue(ExecutableFindOperationSupport.java:134) ~[spring-data-mongodb-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
	at org.springframework.data.mongodb.repository.query.AbstractMongoQuery.lambda$getExecution$4(AbstractMongoQuery.java:153) ~[spring-data-mongodb-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
	at org.springframework.data.mongodb.repository.query.AbstractMongoQuery.doExecute(AbstractMongoQuery.java:126) ~[spring-data-mongodb-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
	at org.springframework.data.mongodb.repository.query.AbstractMongoQuery.execute(AbstractMongoQuery.java:101) ~[spring-data-mongodb-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:618) ~[spring-data-commons-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:605) ~[spring-data-commons-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
	at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) ~[spring-data-commons-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) ~[spring-aop-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.2.4.RELEASE.jar!/:5.2.4.RELEASE]
	at com.sun.proxy.$Proxy98.findByTaskId(Unknown Source) ~[na:na]
	at com.iexec.resultproxy.ipfs.task.IpfsNameService.getIpfsHashForTask(IpfsNameService.java:34) ~[classes!/:na]
	at com.iexec.resultproxy.proxy.ProxyController.getIpfsHashForTask(ProxyController.java:176) ~[classes!/:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]

How to fix:

Add @Unique to the field taskId of the model IpfsName here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions