Return-Path: X-Original-To: apmail-incubator-cloudstack-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-cloudstack-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8D98AD0DD for ; Thu, 23 Aug 2012 14:50:13 +0000 (UTC) Received: (qmail 75366 invoked by uid 500); 23 Aug 2012 14:50:13 -0000 Delivered-To: apmail-incubator-cloudstack-dev-archive@incubator.apache.org Received: (qmail 75316 invoked by uid 500); 23 Aug 2012 14:50:13 -0000 Mailing-List: contact cloudstack-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cloudstack-dev@incubator.apache.org Delivered-To: mailing list cloudstack-dev@incubator.apache.org Received: (qmail 75306 invoked by uid 99); 23 Aug 2012 14:50:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Aug 2012 14:50:13 +0000 X-ASF-Spam-Status: No, hits=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of Prasanna.Santhanam@citrix.com designates 203.166.19.134 as permitted sender) Received: from [203.166.19.134] (HELO SMTP.CITRIX.COM.AU) (203.166.19.134) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Aug 2012 14:50:07 +0000 X-IronPort-AV: E=Sophos;i="4.80,300,1344211200"; d="scan'208";a="12464536" Received: from banpmailmx02.citrite.net ([10.103.128.74]) by SYDPIPO01.CITRIX.COM.AU with ESMTP/TLS/RC4-MD5; 23 Aug 2012 14:49:44 +0000 Received: from citrix.com (10.146.0.130) by BANPMAILMX02.citrite.net (10.103.128.74) with Microsoft SMTP Server id 8.3.213.0; Thu, 23 Aug 2012 20:19:43 +0530 Date: Thu, 23 Aug 2012 20:19:43 +0530 From: Prasanna Santhanam To: CloudStack Dev Subject: About Transaction management Message-ID: <20120823144943.GA24660@cloud.com> Mail-Followup-To: CloudStack Dev MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Checked: Checked by ClamAV on apache.org I was looking at moving the Simulator managed entities into a different database and found that Transaction.java is not able to switch to the right DB based on context of its execution. To explain further: The ServerResource for simulator which is the bottommost layer manages a set of Daos which alter entities in the database : `simulator`. When the context goes back to the middle manager layers of CS (ResourceManagerImpl say) after a Command is executed at the ServerResource all the Daos in the Managers seem to access the `simulator` db instead of the `cloud` db for their operations. I noticed that Transaction.java holds a threadlocal store where it retains the _previously used database. 1) Is this a bad design for the simulator in that it tries to alter db entities at the ServerResource? 2) Or is this a bug in the way transactions are managed? 3) Or is this the wrong way to switch databases? txn = Transaction.open(Transaction.SIMULATOR_DB) try { txn.start(); .... some persistence code here.... txn.commit(); } catch (Exception ex) { txn.rollback(); } finally { txn.close(); } Thanks, -- Prasanna.,