Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 5B802B53E85 for ; Fri, 25 May 2012 09:55:27 -0300 (ADT) Received: from mout6.freenet.de ([2001:748:100:40::2:8]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SXu39-0000vR-Jr for pgsql-sql@postgresql.org; Fri, 25 May 2012 12:55:26 +0000 Received: from [195.4.92.140] (helo=mjail0.freenet.de) by mout6.freenet.de with esmtpa (ID jan.lentfer@freenet.de) (port 25) (Exim 4.76 #1) id 1SXu2x-0003vE-8e for pgsql-sql@postgresql.org; Fri, 25 May 2012 14:55:11 +0200 Received: from localhost ([::1]:36565 helo=mjail0.freenet.de) by mjail0.freenet.de with esmtpa (ID jan.lentfer@freenet.de) (Exim 4.76 #1) id 1SXu2x-00029v-4k for pgsql-sql@postgresql.org; Fri, 25 May 2012 14:55:11 +0200 Received: from [195.4.92.21] (port=33513 helo=11.mx.freenet.de) by mjail0.freenet.de with esmtpa (ID jan.lentfer@freenet.de) (Exim 4.76 #1) id 1SXu0l-00014d-7s for pgsql-sql@postgresql.org; Fri, 25 May 2012 14:52:55 +0200 Received: from p579b72c7.dip.t-dialin.net ([87.155.114.199]:59974 helo=epia.lan.net) by 11.mx.freenet.de with esmtpa (ID jan.lentfer@freenet.de) (port 25) (Exim 4.76 #1) id 1SXu0k-0001eA-4k for pgsql-sql@postgresql.org; Fri, 25 May 2012 14:52:55 +0200 Received: from localhost (localhost [127.0.0.1]) by epia.lan.net (Postfix) with ESMTP id 93D8E2FAC9576 for ; Fri, 25 May 2012 14:52:53 +0200 (CEST) X-Virus-Scanned: amavisd-new at lan.net Received: from epia.lan.net ([127.0.0.1]) by localhost (epia.lan.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gMfL+jIt1j5L for ; Fri, 25 May 2012 14:52:44 +0200 (CEST) Received: from neslonek.homeunix.org (localhost [127.0.0.1]) by epia.lan.net (Postfix) with ESMTP id 2B19D2FAC940C for ; Fri, 25 May 2012 14:52:44 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 25 May 2012 14:52:43 +0200 From: Jan Lentfer To: Subject: Re: Job control in sql In-Reply-To: <4FBF4293.4090902@krap.dk> References: <4FBF4293.4090902@krap.dk> Message-ID: <879f6ef6940b25a63a82d87dc0c530c3@neslonek.homeunix.org> X-Sender: Jan.Lentfer@web.de User-Agent: RoundCube Webmail/0.5.3 X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201205/89 X-Sequence-Number: 36637 On Fri, 25 May 2012 10:28:03 +0200, Svenne Krap wrote: [...] > The problem is that a later run of run_jobs() will not see the > job_begun has been set by a prior run (that is unfinished - as all > queries from the plpgsql-function runs in a single, huge > transaction). > > > My intitial idea was to set the isolation level to "read > uncommitted" > while doing the is-somebody-else-running-lookup, but I cannot change > that in the plpgsql function (it complains that the session has to be > empty - even when I have run nothing before it). > > Any ideas on how to solve the issue? Add a sort of status table where you insert your unique job identifer at the start of the function and remove it in the end? As seperate transactions of course. Jan -- professional: http://www.oscar-consult.de private: http://neslonek.homeunix.org/drupal/