Pearl1594 opened a new issue, #10825:
URL: https://github.com/apache/cloudstack/issues/10825

   ### problem
   
   When attempting to assign / move a VM to another account, it fails with the 
following exception:
   
   ```
   2025-05-07 10:34:32,616 WARN  [c.c.u.d.SequenceFetcher] 
(SequenceFetcher-25:[]) (logid:) Caught this exception when running: 
HikariProxyPreparedStatement@430665016 wrapping 
com.mysql.cj.jdbc.ServerPreparedStatement[584]: SELECT mac_address_seq FROM 
op_networks WHERE id = 239 FOR UPDATE 
com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait 
timeout exceeded; try restarting transaction
        at 
com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:124)
        at 
com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
        at 
com.mysql.cj.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:555)
        at 
com.mysql.cj.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:339)
        at 
com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:972)
        at 
com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
        at 
com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
        at 
com.cloud.utils.db.SequenceFetcher$Fetcher.call(SequenceFetcher.java:130)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:840)
   
   2025-05-07 10:34:32,617 WARN  [c.c.u.d.SequenceFetcher] 
(SequenceFetcher-25:[]) (logid:) Unable to get a sequence: 
HikariProxyPreparedStatement@1642184383 wrapping 
com.mysql.cj.jdbc.ServerPreparedStatement[585]: UPDATE op_networks SET 
mac_address_seq=** NOT SPECIFIED **+1 WHERE id=239
   2025-05-07 10:34:32,618 DEBUG [c.c.u.d.T.Transaction] 
(SequenceFetcher-25:[]) (logid:) Rolling back the transaction: Time = 600605 
Name =  Sequence; called by 
-TransactionLegacy.rollback:896-TransactionLegacy.removeUpTo:839-TransactionLegacy.close:663-SequenceFetcher$Fetcher.call:160-FutureTask.run:264-ThreadPoolExecutor.runWorker:1136-ThreadPoolExecutor$Worker.run:635-Thread.run:840
   2025-05-07 10:34:32,619 DEBUG [c.c.u.d.T.Transaction] 
(qtp698741991-20:[ctx-f59193f4, ctx-7a18cbc9]) (logid:c06a70ed) Rolling back 
the transaction: Time = 603627 Name =  qtp698741991-20; called by 
-TransactionLegacy.rollback:896-TransactionLegacy.removeUpTo:839-TransactionLegacy.close:663-Transaction.execute:36-Transaction.execute:45-UserVmManagerImpl.moveVmToUser:7445-NativeMethodAccessorImpl.invoke0:-2-NativeMethodAccessorImpl.invoke:77-DelegatingMethodAccessorImpl.invoke:43-Method.invoke:569-AopUtils.invokeJoinpointUsingReflection:344-ReflectiveMethodInvocation.invokeJoinpoint:198
   2025-05-07 10:34:32,623 WARN  [o.a.c.m.w.WebhookServiceImpl] 
(qtp698741991-20:[ctx-f59193f4, ctx-7a18cbc9]) (logid:c06a70ed) Skipping 
delivering event Event {"description":"{\"details\":\"Network Id: 
239\",\"event\":\"VM.MOVE\",\"status\":\"Completed\"}","eventId":null,"eventType":"VM.MOVE","eventUuid":null,"resourceType":"VirtualMachine","resourceUUID":null}
 to any webhook as account ID is missing
   2025-05-07 10:34:32,623 WARN  [o.a.c.f.e.EventDistributorImpl] 
(qtp698741991-20:[ctx-f59193f4, ctx-7a18cbc9]) (logid:c06a70ed) Failed to 
publish event [category: ActionEvent, type: VM.MOVE] on bus webhookEventBus
   2025-05-07 10:34:32,641 ERROR [o.a.c.a.c.a.v.AssignVMCmd] 
(qtp698741991-20:[ctx-f59193f4, ctx-7a18cbc9]) (logid:c06a70ed) Failed to move 
VM [108]. java.lang.NullPointerException: Cannot invoke 
"java.lang.Long.longValue()" because the return value of 
"com.cloud.utils.db.SequenceFetcher.getNextSequence(java.lang.Class, 
javax.persistence.TableGenerator, Object)" is null
        at 
com.cloud.network.dao.NetworkDaoImpl.getNextAvailableMacAddress(NetworkDaoImpl.java:434)
        at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:569)
        at 
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
        at 
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
        at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
        at 
com.cloud.utils.db.TransactionContextInterceptor.invoke(TransactionContextInterceptor.java:34)
        at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
        at 
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
        at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
        at 
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
        at jdk.proxy3/jdk.proxy3.$Proxy70.getNextAvailableMacAddress(Unknown 
Source)
        at 
com.cloud.network.NetworkModelImpl.getNextAvailableMacAddressInNetwork(NetworkModelImpl.java:602)
        at 
com.cloud.network.guru.GuestNetworkGuru.allocate(GuestNetworkGuru.java:474)
        at 
com.cloud.network.guru.ExternalGuestNetworkGuru.allocate(ExternalGuestNetworkGuru.java:281)
        at 
org.apache.cloudstack.engine.orchestration.NetworkOrchestrator.checkForRaceAndAllocateNic(NetworkOrchestrator.java:1080)
        at 
org.apache.cloudstack.engine.orchestration.NetworkOrchestrator.allocateNic(NetworkOrchestrator.java:1137)
        at 
org.apache.cloudstack.engine.orchestration.NetworkOrchestrator.addRequestedNicToNicListWithDeviceNumberAndRetrieveDefaultDevice(NetworkOrchestrator.java:918)
        at 
org.apache.cloudstack.engine.orchestration.NetworkOrchestrator.allocate(NetworkOrchestrator.java:891)
        at 
com.cloud.vm.UserVmManagerImpl.allocateNetworksForVm(UserVmManagerImpl.java:7853)
        at 
com.cloud.vm.UserVmManagerImpl.updateAdvancedTypeNetworkForVm(UserVmManagerImpl.java:7827)
        at 
com.cloud.vm.UserVmManagerImpl.updateVmNetwork(UserVmManagerImpl.java:7678)
        at 
com.cloud.vm.UserVmManagerImpl.executeStepsToChangeOwnershipOfVm(UserVmManagerImpl.java:7595)
   
   ```
   
   This issue occurs because the createGuestNetwork operation is executed 
inside a nested transaction. Since the outer (parent) transaction hasn’t 
completed, the network created for the destination account hasn’t been 
committed to the database yet. As a result, when the system attempts to fetch 
the next MAC address for this new network, it fails with a 
NullPointerException, as the network does not yet exist in the database.
   
   
   
   ### versions
   
   The versions of ACS, hypervisors, storage, network etc..
   
   ### The steps to reproduce the bug
   
   1.
   2.
   3.
   ...
   
   
   ### What to do about it?
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@cloudstack.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to