Skip to content

Collection not being reachable when call a custom query inside a @Transactional method (Spring-Data-Couchbase 5.0.0-M6) #1569

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

Closed
PRodrigues-eb opened this issue Sep 30, 2022 · 6 comments · Fixed by #1571
Labels
type: bug A general bug

Comments

@PRodrigues-eb
Copy link

On our repository classes we have the following query methods:

public interface AccountRepository extends CouchbaseRepository<ClientOperationsAccount, String> {

    Optional<ClientOperationsAccount> findBySalesforceId(String salesforceId);
    
    Optional<ClientOperationsAccount> findByEnterpriseAccountId(String enterpriseAccountId);
}

If we call any of them outside a @transactional method it works well, but if it be called inside a @transactional method we got the following error:

Keyspace not found in CB datastore: default:client-operations-account - cause: No bucket named client-operations-account

Seems that it's not pointing to the configured bucket and scope when it is called inside a @transactional method, interestingly it only happen to custom query methods.

Exception:

Caused by: org.springframework.data.couchbase.transaction.error.TransactionSystemUnambiguousException: Transaction has failed with cause 'com.couchbase.client.core.error.IndexFailureException: The server reported an issue with the underlying index {"completed":true,"coreId":"0xb8671a600000001","errors":[{"code":12003,"message":"Keyspace not found in CB datastore: default:client-operations-account - cause: No bucket named client-operations-account","retry":false}],"httpStatus":500,"idempotent":false,"lastDispatchedFrom":"127.0.0.1:56741","lastDispatchedTo":"localhost:8093","requestId":124,"requestType":"QueryRequest","retried":0,"service":{"operationId":"query","statement":"SELECT `_class`, META(`client-operations-account`).`id` AS __id, `enterpriseAccountId`, `salesforceId`, `bullhornId`, `accountName`, `businessType`, `currentServiceLevel`, `accountDescription`, `industry`, `inheritedAccount`, `invoiceName`, `accountActivatedDate`, `legacyId`, `accountParentId`, `website`, `wmbeAccount`, `shippingAddress`, `accountBranch`, `accountBrand`, `accountFinancials`, `accountSetup`, `brandSpecificRollups`, META(`client-operations-account`).`cas` AS __cas, `createdAt`, `updatedAt`, `createdBy`, `updatedBy` FROM `client-operations-account` WHERE `_class` = \"com.employbridge.account.manager.model.ClientOperationsAccount\" AND `enterpriseAccountId` = $1","target":"NodeIdentifier{address=localhost, managerPort=8091}","type":"query"},"timeoutMs":25993,"timings":{"dispatchMicros":54512,"totalDispatchMicros":54512,"totalMicros":55329}}'
	at org.springframework.data.couchbase.transaction.CouchbaseCallbackTransactionManager.convert(CouchbaseCallbackTransactionManager.java:139)
	at org.springframework.data.couchbase.transaction.CouchbaseCallbackTransactionManager.executeNewTransaction(CouchbaseCallbackTransactionManager.java:130)
	at org.springframework.data.couchbase.transaction.CouchbaseCallbackTransactionManager.execute(CouchbaseCallbackTransactionManager.java:83)
	at org.springframework.data.couchbase.transaction.CouchbaseTransactionInterceptor.invokeWithinTransaction(CouchbaseTransactionInterceptor.java:81)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:755)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:706)
	at com.employbridge.account.manager.service.impl.ClientOperationsAccountServiceImpl$$SpringCGLIB$$0.update(<generated>)
	at com.employbridge.account.manager.kafka.SalesforceAccountListener.tryToUpdateAccount(SalesforceAccountListener.java:146)
	... 55 common frames omitted
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 30, 2022
@mikereiche
Copy link
Collaborator

mikereiche commented Oct 3, 2022

I see the issue. Fixing...

@mikereiche mikereiche added the type: bug A general bug label Oct 3, 2022
mikereiche added a commit that referenced this issue Oct 3, 2022
@mikereiche mikereiche removed the status: waiting-for-triage An issue we've not yet triaged label Oct 3, 2022
mikereiche added a commit that referenced this issue Oct 4, 2022
mikereiche added a commit that referenced this issue Oct 4, 2022
@maleficuss
Copy link

Hi, same problem happens for reactive repositories

@mikereiche
Copy link
Collaborator

@maleficuss - in what version? There fix was in the ReactiveOperation (which is called by the non-reactive operation).

@maleficuss
Copy link

@mikereiche sorry for resurrecting old post, when i saw the same case that i have i didnt even check date of the post :)

Im using 5.0.4

@mikereiche
Copy link
Collaborator

Ok - I think I just fixed this in #1745

@maleficuss
Copy link

@mikereiche thank you, I'm gonna try with that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants