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

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

niteshsarda commented on a change in pull request #2373: 
CLOUDSTACK-10202:createSnapshotPolicy API create multiple entries in DB for 
same volume.
URL: https://github.com/apache/cloudstack/pull/2373#discussion_r158693184
 
 

 ##########
 File path: server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
 ##########
 @@ -854,15 +856,18 @@ public SnapshotPolicyVO 
createPolicy(CreateSnapshotPolicyCmd cmd, Account policy
                 throw new InvalidParameterValueException("Max number of 
snapshots shouldn't exceed the " + message + " level snapshot limit");
             }
         }
-        SnapshotPolicyVO policy = 
_snapshotPolicyDao.findOneByVolumeInterval(volumeId, intvType);
-        if (policy == null) {
-            policy = new SnapshotPolicyVO(volumeId, cmd.getSchedule(), 
timezoneId, intvType, cmd.getMaxSnaps(), display);
-            policy = _snapshotPolicyDao.persist(policy);
-            _snapSchedMgr.scheduleNextSnapshotJob(policy);
-        } else {
-            try {
+
+        final GlobalLock createSnapshotPolicyLock = 
GlobalLock.getInternLock("createSnapshotPolicy_" + volumeId);
+        createSnapshotPolicyLock.lock(5);
 
 Review comment:
   @marcaurele : Do we just need to add the debug logger if lock is not 
acquired ?
   Please confirm.

----------------------------------------------------------------
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


> createSnapshotPolicy API create multiple entries in DB for same volume.
> -----------------------------------------------------------------------
>
>                 Key: CLOUDSTACK-10202
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10202
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>            Reporter: Nitesh Sarda
>
> *ISSUE :*
> createSnapshotPolicy API create multiple entries in DB for same parameters, 
> if multiple threads are executed in parallel.
> *STEPS TO REPRODUCE :*
> # Created a new machine having root and data disk.
> # Make sure that no existing snapshot policy is present for the volume.
> # Execute multiple threads in parallel for createSnapshotPolicy API having 
> all required parameters exactly same.
> # Verify table snapshot_policy in DB, will get multiple entries for same 
> policy.
> # Once again execute same multiple threads, by changing any API parameter, 
> will see that existing entries are getting modified in DB and no new entries 
> are added.



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

Reply via email to