Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hpY13-00031j-DM for pgsql-general@arkaria.postgresql.org; Mon, 22 Jul 2019 13:06:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hpY12-0007gO-48 for pgsql-general@arkaria.postgresql.org; Mon, 22 Jul 2019 13:06:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hpY11-0007gH-OW for pgsql-general@lists.postgresql.org; Mon, 22 Jul 2019 13:06:07 +0000 Received: from [2a01:7e00::f03c:91ff:fe18:393b] (helo=campbell-lange.net) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hpY0x-0007rd-AY for pgsql-general@lists.postgresql.org; Mon, 22 Jul 2019 13:06:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=campbell-lange.net; s=it; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=tTz1RGcFCTsnA+z7hZ/YIWZmDBzeuRMy6ce/zUqbkvU=; b=cEoBnucWpWcRrKitQuUdqPstq rponto40H6Skj33oEZ0wda3FZpfdzK8X+PhdXs9/6fdnlPhpOWjiZTdEx+8BRCtbUaqN7x88GHvik kkazNhMjKGOOWfdDHhh4s6kuKpvFOKYx3TqSeOJyg3Htr5NN+Pt4+z8LuuJY08tI0Smz8=; Received: from arennes-651-1-28-26.w86-214.abo.wanadoo.fr ([86.214.187.26] helo=rory-t450s) by campbell-lange.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1hpY0v-0001sT-A7; Mon, 22 Jul 2019 13:06:01 +0000 Received: from rory by rory-t450s with local (Exim 4.92) (envelope-from ) id 1hpY0y-0004ZS-VP; Mon, 22 Jul 2019 14:06:05 +0100 Date: Mon, 22 Jul 2019 14:06:04 +0100 From: Rory Campbell-Lange To: "Peter J. Holzer" Cc: pgsql-general@lists.postgresql.org Subject: Re: How to run a task continuously in the background Message-ID: <20190722130604.GA17492@campbell-lange.net> References: <14555705-8010-4A73-8501-EA07B285E1BA@mikatiming.de> <8D19E041-DFA4-40C0-9CCA-36D65548E842@mikatiming.de> <20190717113441.GB15220@campbell-lange.net> <20190719195313.36d5xgcub7kh2vda@hjp.at> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190719195313.36d5xgcub7kh2vda@hjp.at> User-Agent: Mutt/1.10.1 (2018-07-13) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:7e00::f03c:91ff:fe18:393b (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 19/07/19, Peter J. Holzer (hjp-pgsql@hjp.at) wrote: > On 2019-07-17 12:34:41 +0100, Rory Campbell-Lange wrote: > > We make extensive use of postgresql 'contacting' an external process, > > but our use case involves many databases in a cluster rather than many > > schemas. Also we don't have to deal with cancelling the external > > process. We chose this architecture to avoid many postgresql > > connections for LISTEN/NOTIFY. > > > > We use a pgmemcache interface trigger to update memcached with a > > notification of the database holding items to be flushed. > > Memcached is a cache. It will delete old items if storage is full (or if > they expire). Is this not a problem in your case or did you make sure > that this cannot happen? We have a few hundred databases in a cluster, and the notifications are simply the database name and the value "1" when the database queue requires processing. With only the database name as key memory use memcached is bounded. There is a potential race condition between the queue processor processing the queue before setting the value to "0" and more queue items landing, but that is not an issue for our use case. Rory