# WSREP detected deadlock/conflict

**URL:** <https://forums.percona.com/t/wsrep-detected-deadlock-conflict/6376>\
**Category:** Percona XtraDB Cluster 5.x\
**Created:** [May 24, 2018, 4:42am UTC](https://forums.percona.com/t/wsrep-detected-deadlock-conflict/6376 "2018-05-24T04:42:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bshah](https://avatars.discourse-cdn.com/v4/letter/b/91b2a8/32.png) [@bshah](https://forums.percona.com/u/bshah)\
**Post date:** [May 24, 2018, 4:42am UTC](https://forums.percona.com/t/wsrep-detected-deadlock-conflict/6376/1 "2018-05-24T04:42:56Z")

</div>

I am getting WSREP detected deadlock/conflict with Percona latest version. I am using spring boot app to save my entity but some time this conflict occurs. It occurs at many places. Since I am testing I do not have much data but I hit database couple of times.  
This is the log from node1 & node2

```auto
018-05-23T11:36:28.362290Z 127478 [Note] WSREP: --------- CONFLICT DETECTED --------
2018-05-23T11:36:28.362338Z 127478 [Note] WSREP: cluster conflict due to certification failure for threads:

2018-05-23T11:36:28.362348Z 127478 [Note] WSREP: Victim thread: 
THD: 127478, mode: local, state: executing, conflict: cert failure, seqno: 2381
SQL: commit

```

This is the exception from spring boot app

```auto

org.springframework.orm.jpa.JpaSystemException: com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: WSREP detected deadlock/conflict and aborted the transaction. Try restarting the transaction; nested exception is javax.persistence.PersistenceException: com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: WSREP detected deadlock/conflict and aborted the transaction. Try restarting the transaction at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:418) at org.springframework.orm.jpa.DefaultJpaDialect.translateExceptionIfPossible(DefaultJpaDialect.java:122) at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:521) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730) at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:504) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:292) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) at com.sun.proxy.$Proxy153.save 

```

---

<div class="post-metadata">

**Author:** ![krunalbauskar](https://avatars.discourse-cdn.com/v4/letter/k/439d5e/32.png) [@krunalbauskar](https://forums.percona.com/u/krunalbauskar)\
**Post date:** [June 28, 2018, 12:54am UTC](https://forums.percona.com/t/wsrep-detected-deadlock-conflict/6376/2 "2018-06-28T00:54:05Z")

</div>

Galera/PXC uses optimistic locking. This means, 2 nodes can modify the same object at the same time but first to commit to group channel wins. If n2 has committed first and say trx originating from n2 needs to be applied to n1 and n1 has modified the same object then active/local trx on n1 needs to force aborted.
