[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-9595?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16297165#comment-16297165
 ] 

ASF GitHub Bot commented on CLOUDSTACK-9595:
--------------------------------------------

rhtyd commented on a change in pull request #1762: CLOUDSTACK-9595 Transactions 
are not getting retried in case of datab…
URL: https://github.com/apache/cloudstack/pull/1762#discussion_r157830379
 
 

 ##########
 File path: server/src/com/cloud/network/IpAddressManagerImpl.java
 ##########
 @@ -836,35 +835,51 @@ public IPAddressVO doInTransaction(TransactionStatus 
status) throws Insufficient
     @DB
     @Override
     public void markPublicIpAsAllocated(final IPAddressVO addr) {
-
-        Transaction.execute(new TransactionCallbackNoReturn() {
-            @Override
-            public void doInTransactionWithoutResult(TransactionStatus status) 
{
-                Account owner = 
_accountMgr.getAccount(addr.getAllocatedToAccountId());
-                synchronized (this) {
+        synchronized (_allocatedLock) {
+            Transaction.execute(new TransactionCallbackNoReturn() {
+                @Override
+                public void doInTransactionWithoutResult(TransactionStatus 
status) {
+                    Account owner = 
_accountMgr.getAccount(addr.getAllocatedToAccountId());
                     if (_ipAddressDao.lockRow(addr.getId(), true) != null) {
                         IPAddressVO userIp = 
_ipAddressDao.findById(addr.getId());
                         if (userIp.getState() == IpAddress.State.Allocating || 
addr.getState() == IpAddress.State.Free) {
                             addr.setState(IpAddress.State.Allocated);
-                            _ipAddressDao.update(addr.getId(), addr);
-                            // Save usage event
-                            if (owner.getAccountId() != 
Account.ACCOUNT_ID_SYSTEM) {
-                                VlanVO vlan = 
_vlanDao.findById(addr.getVlanId());
-                                String guestType = 
vlan.getVlanType().toString();
-                                if (!isIpDedicated(addr)) {
-                                    
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_ASSIGN, 
owner.getId(), addr.getDataCenterId(), addr.getId(),
-                                            addr.getAddress().toString(),
-                                            addr.isSourceNat(), guestType, 
addr.getSystem(), addr.getClass().getName(), addr.getUuid());
-                                }
-                                if (updateIpResourceCount(addr)) {
-                                    
_resourceLimitMgr.incrementResourceCount(owner.getId(), ResourceType.public_ip);
+                            if (_ipAddressDao.update(addr.getId(), addr)) {
 
 Review comment:
   @yvsubhash I've found regressions in some tests, specifically around private 
gw tests where failures look like this:
   ```
   2017-12-19 22:53:00,817 DEBUG [c.c.a.t.Request] 
(AgentManager-Handler-20:null) (logid:) Seq 1-4815473901565903002: Processing:  
{ Ans: , MgmtId: 2485222984626, via: 1, Ver: v1, Flags: 10, 
[{"com.cloud.agent.api.routing.GroupAnswer":{"results":["null - success: 
Creating file in VR, with ip: 169.254.1.135, file: 
ip_associations.json.82a129d8-a849-4a63-af8b-3b885abd3b32","null - failed: 
[INFO] update_config.py :: Processing incoming file => 
ip_associations.json.82a129d8-a849-4a63-af8b-3b885abd3b32[INFO] Processing JSON 
file ip_associations.json.82a129d8-a849-4a63-af8b-3b885abd3b32Traceback (most 
recent call last):  File \"/opt/cloud/bin/update_config.py\", line 143, in 
<module>    process_file()  File \"/opt/cloud/bin/update_config.py\", line 57, 
in process_file    finish_config()  File \"/opt/cloud/bin/update_config.py\", 
line 45, in finish_config    returncode = configure.main(sys.argv)  File 
\"/opt/cloud/bin/configure.py\", line 1006, in main    
config.address().process()  File \"/opt/cloud/bin/cs/CsAddress.py\", line 104, 
in process    ip = CsIP(dev, self.config)  File 
\"/opt/cloud/bin/cs/CsAddress.py\", line 261, in __init__    self.dnum = 
hex(int(dev[3:]))ValueError: invalid literal for int() with base 10: 
'None'"],"result":false,"wait":0}}] }      2017-12-19 22:53:00,818 DEBUG 
[c.c.a.t.Request] (API-Job-Executor-47:ctx-52e4a845 job-76 ctx-b4b917c1) 
(logid:a5289d87) Seq 1-4815473901565903002: Received:  { Ans: , MgmtId: 
2485222984626, via: 1(centos7-kvm1), Ver: v1, Flags: 10, { GroupAnswer } }
   ```
   On deeper analysis, I found that `nic_dev_id` was not passed to a VPC router 
with no VMs, one network and a private way via a ip_associations.json and it 
caused interface to have ethNone defined in ips.json instead of eth2 etc. (this 
is similar to https://issues.apache.org/jira/browse/CLOUDSTACK-9759). Since, 
the only change in master is your PR I suspect there is some regression and 
that patch you've submitted here may be different that you private fork/branch. 
/cc @rafaelweingartner 
   
   For example, in this code if update fails for some reason it should throw an 
exception or log?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Transactions are not getting retried in case of database deadlock errors
> ------------------------------------------------------------------------
>
>                 Key: CLOUDSTACK-9595
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9595
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>    Affects Versions: 4.8.0
>            Reporter: subhash yedugundla
>             Fix For: 4.8.1
>
>
> Customer is seeing occasional error 'Deadlock found when trying to get lock; 
> try restarting transaction' messages in their management server logs.  It 
> happens regularly at least once a day.  The following is the error seen 
> 2015-12-09 19:23:19,450 ERROR [cloud.api.ApiServer] 
> (catalina-exec-3:ctx-f05c58fc ctx-39c17156 ctx-7becdf6e) unhandled exception 
> executing api command: [Ljava.lang.String;@230a6e7f
> com.cloud.utils.exception.CloudRuntimeException: DB Exception on: 
> com.mysql.jdbc.JDBC4PreparedStatement@74f134e3: DELETE FROM 
> instance_group_vm_map WHERE instance_group_vm_map.instance_id = 941374
>       at com.cloud.utils.db.GenericDaoBase.expunge(GenericDaoBase.java:1209)
>       at sun.reflect.GeneratedMethodAccessor360.invoke(Unknown Source)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:606)
>       at 
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
>       at 
> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
>       at 
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
>       at 
> com.cloud.utils.db.TransactionContextInterceptor.invoke(TransactionContextInterceptor.java:34)
>       at 
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
>       at 
> org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
>       at 
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
>       at 
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
>       at com.sun.proxy.$Proxy237.expunge(Unknown Source)
>       at 
> com.cloud.vm.UserVmManagerImpl$2.doInTransactionWithoutResult(UserVmManagerImpl.java:2593)
>       at 
> com.cloud.utils.db.TransactionCallbackNoReturn.doInTransaction(TransactionCallbackNoReturn.java:25)
>       at com.cloud.utils.db.Transaction$2.doInTransaction(Transaction.java:57)
>       at com.cloud.utils.db.Transaction.execute(Transaction.java:45)
>       at com.cloud.utils.db.Transaction.execute(Transaction.java:54)
>       at 
> com.cloud.vm.UserVmManagerImpl.addInstanceToGroup(UserVmManagerImpl.java:2575)
>       at 
> com.cloud.vm.UserVmManagerImpl.updateVirtualMachine(UserVmManagerImpl.java:2332)



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to