You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Volume snapshot listing failing when originating primary pool removed #3264
2019-04-05 13:48:39,507 ERROR [c.c.a.ApiServer] (qtp788117692-12:ctx-817b96c3 ctx-5c399d14) (logid:9277d33d) unhandled exception executing api command: [Ljava.lang.String;@2829384
java.lang.NullPointerException
at org.apache.cloudstack.storage.snapshot.StorageSystemSnapshotStrategy.canHandle(StorageSystemSnapshotStrategy.java:978)
at org.apache.cloudstack.storage.helper.StorageStrategyFactoryImpl$3.canHandle(StorageStrategyFactoryImpl.java:72)
at org.apache.cloudstack.storage.helper.StorageStrategyFactoryImpl$3.canHandle(StorageStrategyFactoryImpl.java:69)
at org.apache.cloudstack.storage.helper.StorageStrategyFactoryImpl.bestMatch(StorageStrategyFactoryImpl.java:95)
at org.apache.cloudstack.storage.helper.StorageStrategyFactoryImpl.getSnapshotStrategy(StorageStrategyFactoryImpl.java:69)
at org.apache.cloudstack.storage.snapshot.SnapshotObject.isRevertable(SnapshotObject.java:134)
at com.cloud.api.ApiResponseHelper.createSnapshotResponse(ApiResponseHelper.java:536)
at org.apache.cloudstack.api.command.user.snapshot.ListSnapshotsCmd.execute(ListSnapshotsCmd.java:117)
at com.cloud.api.ApiDispatcher.dispatch(ApiDispatcher.java:150)
at com.cloud.api.ApiServer.queueCommand(ApiServer.java:732)
Possible workarounds without deleting the snapshot:
Remove the entry on snapshot_store_ref with store_role = Primary for conflicting snapshot.
Update the pool_id column on snapshot_store_ref for conflicting snapshot to a non-removed pool id.
Create disk and create snapshot for it [There are 2 entries in snapshot_store_ref]
Put originating primary storage pool on maintenance and try to force remove Error: (HTTP 530, error code 4250) Cannot delete pool Primary as there are associated non-destroyed vols for this pool
Destroy created disk or migrate created disk to a different primary storage It deletes snapshot entry from snapshot_store_ref where store_role=Primary
Removing primary storage pool and list snapshots thereafter doesn't give NPE.
@shwstppr that's fine, no need. Can you however do a manual static code analysis and add defensive checks that avoid/handle potential NPEs if any:
2019-04-05 13:48:39,507 ERROR [c.c.a.ApiServer] (qtp788117692-12:ctx-817b96c3 ctx-5c399d14) (logid:9277d33d) unhandled exception executing api command: [Ljava.lang.String;@2829384
java.lang.NullPointerException
at org.apache.cloudstack.storage.snapshot.StorageSystemSnapshotStrategy.canHandle(StorageSystemSnapshotStrategy.java:978)
at org.apache.cloudstack.storage.helper.StorageStrategyFactoryImpl$3.canHandle(StorageStrategyFactoryImpl.java:72)
at org.apache.cloudstack.storage.helper.StorageStrategyFactoryImpl$3.canHandle(StorageStrategyFactoryImpl.java:69)
at org.apache.cloudstack.storage.helper.StorageStrategyFactoryImpl.bestMatch(StorageStrategyFactoryImpl.java:95)
at org.apache.cloudstack.storage.helper.StorageStrategyFactoryImpl.getSnapshotStrategy(StorageStrategyFactoryImpl.java:69)
at org.apache.cloudstack.storage.snaps
2020-02-07 17:29:46,777 DEBUG [c.c.a.ApiServlet] (qtp504527234-13:ctx-f0fb97c1) (logid:507c01c5) ===START=== 10.2.2.233 -- GET apiKey=LIN6rqXuaJwMPfGYFh13qDwYz5VNNz1J2J6qIOWcd3oLQOq0WtD4CwRundBL6rzXToa3lQOC_vKjI3nkHtiD8Q&command=listSnapshots&id=1a63b5d5-25ad-41c4-80c7-388050cbaf47&response=json&signature=7d%2FoaRsxGhOx1vLpqKZULO9aFTc%3D
2020-02-07 17:29:46,785 DEBUG [c.c.a.ApiServer] (qtp504527234-13:ctx-f0fb97c1 ctx-84cdffe8) (logid:507c01c5) CIDRs from which account 'Acct[70becd07-4980-11ea-952a-1e00b30107e1-admin]' is allowed to perform API calls: 0.0.0.0/0,::/0
2020-02-07 17:29:46,803 ERROR [c.c.a.ApiServer] (qtp504527234-13:ctx-f0fb97c1 ctx-84cdffe8 ctx-337c9a51) (logid:507c01c5) unhandled exception executing api command: [Ljava.lang.String;@772bb72a
java.lang.NullPointerException
at org.apache.cloudstack.storage.snapshot.StorageSystemSnapshotStrategy.canHandle(StorageSystemSnapshotStrategy.java:982)
at org.apache.cloudstack.storage.helper.StorageStrategyFactoryImpl$3.canHandle(StorageStrategyFactoryImpl.java:72)
at org.apache.cloudstack.storage.helper.StorageStrategyFactoryImpl$3.canHandle(StorageStrategyFactoryImpl.java:69)
at org.apache.cloudstack.storage.helper.StorageStrategyFactoryImpl.bestMatch(StorageStrategyFactoryImpl.java:95)
at org.apache.cloudstack.storage.helper.StorageStrategyFactoryImpl.getSnapshotStrategy(StorageStrategyFactoryImpl.java:69)
at org.apache.cloudstack.storage.snapshot.SnapshotObject.isRevertable(SnapshotObject.java:134)
at com.cloud.api.ApiResponseHelper.createSnapshotResponse(ApiResponseHelper.java:552)
at org.apache.cloudstack.api.command.user.snapshot.ListSnapshotsCmd.execute(ListSnapshotsCmd.java:117)
at com.cloud.api.ApiDispatcher.dispatch(ApiDispatcher.java:156)
at com.cloud.api.ApiServer.queueCommand(ApiServer.java:759)
at com.cloud.api.ApiServer.handleRequest(ApiServer.java:583)
at com.cloud.api.ApiServlet.processRequestInContext(ApiServlet.java:310)
at com.cloud.api.ApiServlet$1.run(ApiServlet.java:130)
at org.apache.cloudstack.managed.context.impl.DefaultManagedContext$1.call(DefaultManagedContext.java:56)
at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.callWithContext(DefaultManagedContext.java:103)
at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.runWithContext(DefaultManagedContext.java:53)
at com.cloud.api.ApiServlet.processRequest(ApiServlet.java:127)
at com.cloud.api.ApiServlet.doGet(ApiServlet.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:686)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:791)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:852)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:527)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:530)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:347)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:256)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:247)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:382)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:708)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:626)
at java.lang.Thread.run(Thread.java:748)
2020-02-07 17:29:46,806 DEBUG [c.c.a.ApiServlet] (qtp504527234-13:ctx-f0fb97c1 ctx-84cdffe8 ctx-337c9a51) (logid:507c01c5) ===END=== 10.2.2.233 -- GET apiKey=LIN6rqXuaJwMPfGYFh13qDwYz5VNNz1J2J6qIOWcd3oLQOq0WtD4CwRundBL6rzXToa3lQOC_vKjI3nkHtiD8Q&command=listSnapshots&id=1a63b5d5-25ad-41c4-80c7-388050cbaf47&response=json&signature=7d%2FoaRsxGhOx1vLpqKZULO9aFTc%3D
2020-02-07 17:29:48,072 DEBUG [c.c.a.m.AgentManagerImpl] (AgentManager-Handler-7:null) (logid:) SeqA 7-5096: Processing Seq 7-5096: { Cmd , MgmtId: -1, via: 7, Ver: v1, Flags: 11, [{"com.cloud.agent.api.ConsoleProxyLoadReportCommand":{"_proxyVmId":1,"_loadInfo":"{\n "connections": []\n}","wait":0}}] }
2020-02-07 17:29:48,076 DEBUG [c.c.a.m.AgentManagerImpl] (AgentManager-Handler-7:null) (logid:) SeqA 7-5096: Sending Seq 7-5096: { Ans: , MgmtId: 32988352022497, via: 7, Ver: v1, Flags: 100010, [{"com.cloud.agent.api.AgentControlAnswer":{"result":true,"wait":0}}] }
2020-02-07 17:29:48,400 DEBUG [c.c.a.ApiServlet] (qtp504527234-20:ctx-2b2cb631) (logid:56a35fa0) ===START=== 10.2.2.233 -- GET apiKey=LIN6rqXuaJwMPfGYFh13qDwYz5VNNz1J2J6qIOWcd3oLQOq0WtD4CwRundBL6rzXToa3lQOC_vKjI3nkHtiD8Q&command=listSnapshots&response=json&signature=Ko6ONMB%2FT3U3UQdfiytAXUOGcjw%3D
2020-02-07 17:29:48,405 DEBUG [c.c.a.ApiServer] (qtp504527234-20:ctx-2b2cb631 ctx-8e2267f0) (logid:56a35fa0) CIDRs from which account 'Acct[70becd07-4980-11ea-952a-1e00b30107e1-admin]' is allowed to perform API calls: 0.0.0.0/0,::/0
2020-02-07 17:29:48,421 ERROR [c.c.a.ApiServer] (qtp504527234-20:ctx-2b2cb631 ctx-8e2267f0 ctx-4b6cab92) (logid:56a35fa0) unhandled exception executing api command: [Ljava.lang.String;@5fc1e40f
java.lang.NullPointerException
at org.apache.cloudstack.storage.snapshot.StorageSystemSnapshotStrategy.canHandle(StorageSystemSnapshotStrategy.java:982)
at org.apache.cloudstack.storage.helper.StorageStrategyFactoryImpl$3.canHandle(StorageStrategyFactoryImpl.java:72)
at org.apache.cloudstack.storage.helper.StorageStrategyFactoryImpl$3.canHandle(StorageStrategyFactoryImpl.java:69)
at org.apache.cloudstack.storage.helper.StorageStrategyFactoryImpl.bestMatch(StorageStrategyFactoryImpl.java:95)
at org.apache.cloudstack.storage.helper.StorageStrategyFactoryImpl.getSnapshotStrategy(StorageStrategyFactoryImpl.java:69)
at org.apache.cloudstack.storage.snapshot.SnapshotObject.isRevertable(SnapshotObject.java:134)
at com.cloud.api.ApiResponseHelper.createSnapshotResponse(ApiResponseHelper.java:552)
at org.apache.cloudstack.api.command.user.snapshot.ListSnapshotsCmd.execute(ListSnapshotsCmd.java:117)
at com.cloud.api.ApiDispatcher.dispatch(ApiDispatcher.java:156)
at com.cloud.api.ApiServer.queueCommand(ApiServer.java:759)
at com.cloud.api.ApiServer.handleRequest(ApiServer.java:583)
at com.cloud.api.ApiServlet.processRequestInContext(ApiServlet.java:310)
at com.cloud.api.ApiServlet$1.run(ApiServlet.java:130)
at org.apache.cloudstack.managed.context.impl.DefaultManagedContext$1.call(DefaultManagedContext.java:56)
at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.callWithContext(DefaultManagedContext.java:103)
at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.runWithContext(DefaultManagedContext.java:53)
at com.cloud.api.ApiServlet.processRequest(ApiServlet.java:127)
at com.cloud.api.ApiServlet.doGet(ApiServlet.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:686)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:791)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:852)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:527)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:530)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:347)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:256)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:247)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:382)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:708)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:626)
at java.lang.Thread.run(Thread.java:748)
2020-02-07 17:29:48,433 DEBUG [c.c.a.ApiServlet] (qtp504527234-20:ctx-2b2cb631 ctx-8e2267f0 ctx-4b6cab92) (logid:56a35fa0) ===END=== 10.2.2.233 -- GET apiKey=LIN6rqXuaJwMPfGYFh13qDwYz5VNNz1J2J6qIOWcd3oLQOq0WtD4CwRundBL6rzXToa3lQOC_vKjI3nkHtiD8Q&command=listSnapshots&response=json&signature=Ko6ONMB%2FT3U3UQdfiytAXUOGcjw%3D
Alright, a bit more digging tells me this is NOT a bug - but a consequence of bad DB hacking
As follows:
Tested on 4.11.2 (and master)
this exception happens when the pool is marked as removed (has "removed" date set) AND when there is at least one reference in the snapshots_store_ref table that says a "snapshot exists on this primary storage". Similar error would probably be raised if there are volume references but pool was marked as removed. This is "when" this issue/exception happens>
BUT
When you go and delete a storage via ACS GUI/API (i.e. before that manually remove any volumes/VMs from this storage via ACS) - then if there are snapshots references in the snapshots_store_ref table, those references will be properly removed (i.e. whole records are deleted where store_role="Primary" and store_id=) so the user can not even get into this situation that he is left with orphaned references in snapshot_store_ref table.
A proposed workaround for anyone facing these issues (i.e. have DB inconsistency or has hacked DB in a wrong way) is to simply remove any references from the snapshot_store_ref table
delete from snapshot_store_ref table where store_role="Primary" and store_id=<id-of-removed-store>
@shwstppr @rhtyd - I would propose closing this issue altogether.
Activity
nvazquez commentedon Apr 5, 2019
Error is NullPointerException on
StorageSubsystemSnapshotStrategy, as the pool is removed, this line returns an empty pool: https://github.com/apache/cloudstack/blob/4.11.2.0/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java#L976Possible workarounds without deleting the snapshot:
snapshot_store_refwith store_role = Primary for conflicting snapshot.snapshot_store_reffor conflicting snapshot to a non-removed pool id.yadvr commentedon Jun 7, 2019
@shwstppr can you pick this up?
shwstppr commentedon Jul 3, 2019
working on this
shwstppr commentedon Jul 4, 2019
Unable to reproduce this on the master,
Error: (HTTP 530, error code 4250) Cannot delete pool Primary as there are associated non-destroyed vols for this poolIt deletes snapshot entry from
snapshot_store_refwherestore_role=PrimaryRemoving primary storage pool and list snapshots thereafter doesn't give NPE.
Any pointers here @nvazquez
yadvr commentedon Jul 10, 2019
@shwstppr how about if you remove the volume as well (but not its full snapshots) and then delete the primary storage pool?
DaanHoogland commentedon Jan 29, 2020
@shwstppr did you abandon this? any intermediate results?
shwstppr commentedon Jan 30, 2020
@DaanHoogland was not able to reproduce this earlier. Let me try again today
yadvr commentedon Jan 30, 2020
@shwstppr if nothing else, you can still follow the code where NPE was seen and make code around that defensive.
yadvr commentedon Feb 6, 2020
Ping @shwstppr @DaanHoogland @andrijapanicsb
shwstppr commentedon Feb 7, 2020
@rhtyd @DaanHoogland tried to reproduce with 4.13 but couldn't
Should I try with 4.11?
yadvr commentedon Feb 7, 2020
@shwstppr that's fine, no need. Can you however do a manual static code analysis and add defensive checks that avoid/handle potential NPEs if any:
Otherwise, let's close this as not reproducible.
andrijapanicsb commentedon Feb 7, 2020
@shwstppr @rhtyd The issue is still present and reproducible on both 4.11.2 and master - just tested.
Before "deleting" storage:
After "deleting" the storage:
And the same exception in logs:
andrijapanicsb commentedon Feb 7, 2020
Alright, a bit more digging tells me this is NOT a bug - but a consequence of bad DB hacking
As follows:
Tested on 4.11.2 (and master)
BUT
When you go and delete a storage via ACS GUI/API (i.e. before that manually remove any volumes/VMs from this storage via ACS) - then if there are snapshots references in the snapshots_store_ref table, those references will be properly removed (i.e. whole records are deleted where store_role="Primary" and store_id=) so the user can not even get into this situation that he is left with orphaned references in snapshot_store_ref table.
A proposed workaround for anyone facing these issues (i.e. have DB inconsistency or has hacked DB in a wrong way) is to simply remove any references from the snapshot_store_ref table
delete from snapshot_store_ref table where store_role="Primary" and store_id=<id-of-removed-store>@shwstppr @rhtyd - I would propose closing this issue altogether.
andrijapanicsb commentedon Feb 7, 2020
Closing this one.