Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 8A8EC200D64 for ; Tue, 26 Dec 2017 08:25:54 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 891AA160C10; Tue, 26 Dec 2017 07:25:54 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 023CC160C00 for ; Tue, 26 Dec 2017 08:25:53 +0100 (CET) Received: (qmail 40237 invoked by uid 500); 26 Dec 2017 07:25:53 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 40227 invoked by uid 99); 26 Dec 2017 07:25:53 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Dec 2017 07:25:53 +0000 From: GitBox To: commits@cloudstack.apache.org Subject: [GitHub] marcaurele commented on a change in pull request #2373: CLOUDSTACK-10202:createSnapshotPolicy API create multiple entries in DB for same volume. Message-ID: <151427315256.26325.5215119684384780563.gitbox@gitbox.apache.org> archived-at: Tue, 26 Dec 2017 07:25:54 -0000 marcaurele 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_r158675822 ########## File path: server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java ########## @@ -854,15 +855,17 @@ 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 { + + policy = _snapshotPolicyDao.acquireInLockTable(volumeId); Review comment: You can request a lock for the snapshot policy table for existing entries and by giving a snapshot policy ID only, not the ID of a volume: `policy = _snapshotPolicyDao.acquireInLockTable(policyId);` In your case you don't have a policy id yet when creating a new one. You'll have to use the global lock. ---------------------------------------------------------------- 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: users@infra.apache.org With regards, Apache Git Services