From patchwork Fri Jul 8 18:26:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 9221647 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 04E0060467 for ; Fri, 8 Jul 2016 18:28:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED7952836F for ; Fri, 8 Jul 2016 18:28:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E219E2837F; Fri, 8 Jul 2016 18:28:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 941722836F for ; Fri, 8 Jul 2016 18:28:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bLaUC-0003sw-V7; Fri, 08 Jul 2016 18:26:48 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bLaUA-0003pd-8N for xen-devel@lists.xenproject.org; Fri, 08 Jul 2016 18:26:46 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id 89/96-01915-560FF775; Fri, 08 Jul 2016 18:26:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphkeJIrShJLcpLzFFi42JxWrohUjf1Q32 4waUrQhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aPbSvZCppEK141zmNtYJzC18XIySEh4C9x betrJhCbTUBXomnLX7YuRg4OEQEVidt7DUBMZoFQiR0vLEFMYQEXiY87y0GKWYAKFnw6wwxi8 wp4SiyfeIMdYqCcxPnjP8HinEDxXUtugsWFBDwkmn81MYKMERJQk5i7Ph6iVVDi5MwnLCA2s4 CExMEXL5ghxnBL3D49lXkCI98sJGWzkJQtYGRaxahenFpUllqka6KXVJSZnlGSm5iZo2toYKq Xm1pcnJiempOYVKyXnJ+7iREYSgxAsIPxVp/zIUZJDiYlUd59z+rDhfiS8lMqMxKLM+KLSnNS iw8xynBwKEnwMr8HygkWpaanVqRl5gCDGiYtwcGjJMLLCJLmLS5IzC3OTIdInWJUlBLnffMOK CEAksgozYNrg0XSJUZZKWFeRqBDhHgKUotyM0tQ5V8xinMwKgnzngWZwpOZVwI3/RXQYiagxQ YBYItLEhFSUg2MCV/iNN4fzU36En6iUuvOdYmlt+SXMIvsj89jObeL6VvA/B3LHke9bV3tZSj S2smU9ClS8NwGy9R1nzN8f+i/tg+e06WUkiBh8qw17/5JWeaOK0+corc/SLMrbZkXal8Qdzhw YsSGS+yp6Vf+9r9++fzM2j13Hjq+rkqe13FL9fdtHvOQC+c5lFiKMxINtZiLihMBwH9frp8CA AA= X-Env-Sender: prvs=9904f56b2=Ian.Jackson@citrix.com X-Msg-Ref: server-4.tower-206.messagelabs.com!1468002401!49240152!4 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 53763 invoked from network); 8 Jul 2016 18:26:45 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-4.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 8 Jul 2016 18:26:45 -0000 X-IronPort-AV: E=Sophos;i="5.28,331,1464652800"; d="scan'208";a="365150950" From: Ian Jackson To: Date: Fri, 8 Jul 2016 19:26:05 +0100 Message-ID: <1468002385-4407-14-git-send-email-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1468002385-4407-1-git-send-email-ian.jackson@eu.citrix.com> References: <1468002385-4407-1-git-send-email-ian.jackson@eu.citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Ian Jackson Subject: [Xen-devel] [OSSTEST PATCH 13/33] Database locking: Tcl: Use db-execute X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Replace open-coded uses of pg_execute dbh STMT with jobdb::db-execute STMT. The only functional change is that if OSSTEST_TCL_JOBDB_DEBUG is set, there will be debugging output. But we are going to want to make db-execute do something more complicated involving pg_exec. Signed-off-by: Ian Jackson Acked-by: Ian Campbell --- ms-ownerdaemon | 6 +++--- ms-queuedaemon | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ms-ownerdaemon b/ms-ownerdaemon index cc2f361..3623d19 100755 --- a/ms-ownerdaemon +++ b/ms-ownerdaemon @@ -32,7 +32,7 @@ proc chan-destroy-stuff {chan} { jobdb::transaction resources { puts-chan-desc $chan "-- $tasks" foreach task $tasks { - pg_execute dbh " + jobdb::db-execute " UPDATE tasks SET live = 'f' WHERE taskid = $task @@ -62,7 +62,7 @@ proc cmd/create-task {chan desc} { set taskdesc $desc } jobdb::transaction resources { - pg_execute dbh " + jobdb::db-execute " INSERT INTO tasks ( type, refkey, refinfo, live) VALUES ('ownd', [pg_quote $taskdesc], [clock seconds], 't') @@ -93,7 +93,7 @@ main-daemon Owner { jobdb::db-open jobdb::transaction resources { - set nrows [pg_execute dbh " + set nrows [jobdb::db-execute " UPDATE tasks SET refkey = 'previous ' || refkey WHERE type = 'ownd' diff --git a/ms-queuedaemon b/ms-queuedaemon index 6e93288..9db8b05 100755 --- a/ms-queuedaemon +++ b/ms-queuedaemon @@ -155,7 +155,7 @@ proc runneeded-perhaps-start {} { } jobdb::transaction resources { - set nrows [pg_execute dbh { + set nrows [jobdb::db-execute { UPDATE resources SET owntaskid= (SELECT taskid FROM tasks WHERE type='magic' AND refkey='allocatable') @@ -167,7 +167,7 @@ proc runneeded-perhaps-start {} { if {!($nrows || $needed>=2)} return jobdb::transaction resources { - set cleaned [pg_execute dbh { + set cleaned [jobdb::db-execute { DELETE FROM tasks WHERE type='ownd' AND live='f' @@ -650,7 +650,7 @@ proc cmd/uptime {chan desc seconds} { continue } if {$refinfo > $before} continue - pg_execute dbh " + jobdb::db-execute " UPDATE tasks SET live = false, refinfo = refinfo || ' stale'