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 62610200D63 for ; Thu, 21 Dec 2017 08:03:06 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 60E2F160C2B; Thu, 21 Dec 2017 07:03:06 +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 AAE68160C1A for ; Thu, 21 Dec 2017 08:03:05 +0100 (CET) Received: (qmail 92066 invoked by uid 500); 21 Dec 2017 07:03:04 -0000 Mailing-List: contact issues-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 issues@cloudstack.apache.org Received: (qmail 92057 invoked by uid 500); 21 Dec 2017 07:03:04 -0000 Delivered-To: apmail-incubator-cloudstack-issues@incubator.apache.org Received: (qmail 92054 invoked by uid 99); 21 Dec 2017 07:03:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Dec 2017 07:03:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 09C55C4094 for ; Thu, 21 Dec 2017 07:03:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.211 X-Spam-Level: X-Spam-Status: No, score=-99.211 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 37GSfVlMi6V3 for ; Thu, 21 Dec 2017 07:03:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id DB5BA5FB91 for ; Thu, 21 Dec 2017 07:03:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 52BBBE2585 for ; Thu, 21 Dec 2017 07:03:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 6E47D24102 for ; Thu, 21 Dec 2017 07:03:00 +0000 (UTC) Date: Thu, 21 Dec 2017 07:03:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: cloudstack-issues@incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CLOUDSTACK-10202) createSnapshotPolicy API create multiple entries in DB for same parameters. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 21 Dec 2017 07:03:06 -0000 [ https://issues.apache.org/jira/browse/CLOUDSTACK-10202?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16299647#comment-16299647 ] ASF GitHub Bot commented on CLOUDSTACK-10202: --------------------------------------------- marcaurele commented on a change in pull request #2373: CLOUDSTACK-10202:createSnapshotPolicy API create multiple entries in DB for same parameters. URL: https://github.com/apache/cloudstack/pull/2373#discussion_r158208194 ########## 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"); Review comment: Would be more effective to append the volume id in the lock name to avoid locking the call for all snapshot policy. ---------------------------------------------------------------- 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 > createSnapshotPolicy API create multiple entries in DB for same parameters. > --------------------------------------------------------------------------- > > 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)