pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rory Campbell-Lange <rory@campbell-lange.net>
To: Peter J. Holzer <hjp-pgsql@hjp.at>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: How to run a task continuously in the background
Date: Mon, 22 Jul 2019 14:06:04 +0100
Message-ID: <20190722130604.GA17492@campbell-lange.net> (raw)
In-Reply-To: <20190719195313.36d5xgcub7kh2vda@hjp.at>
References: <E9FA92C2921F31408041863B74EE4C2001BD810545@CCPMAILDAG03.cantab.local>
	<CAOzAquKb+O3iu0pVBonDDSS8SH=a4Wa4hmYFxAbTwUCi7Hxjhg@mail.gmail.com>
	<D49B7AAD-5EC3-4D62-A263-E22E6633C807@mikatiming.de>
	<CAKoxK+7x4wEA-AMocZ00b8pAcBe2xZMq_6s8xsKPTWq7tGPdig@mail.gmail.com>
	<14555705-8010-4A73-8501-EA07B285E1BA@mikatiming.de>
	<CAKoxK+6exRv9yeLOpZGdOi6uefPDDF1yBJOj_Ph8Sq8b3CmeaQ@mail.gmail.com>
	<8D19E041-DFA4-40C0-9CCA-36D65548E842@mikatiming.de>
	<CAKoxK+4XysF-aA3VvFMn6pQYXsgs1o92JZ5uGx8=18Fr8+q4xA@mail.gmail.com>
	<20190717113441.GB15220@campbell-lange.net>
	<20190719195313.36d5xgcub7kh2vda@hjp.at>

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






view thread (26+ messages)

Message-ID: <20190722130604.GA17492@campbell-lange.net>
Permalink:  ../20190722130604.GA17492@campbell-lange.net/
Also on:    postgresql.org/message-id/20190722130604.GA17492@campbell-lange.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: rory@campbell-lange.net, hjp-pgsql@hjp.at
  Subject: Re: How to run a task continuously in the background
  In-Reply-To: <20190722130604.GA17492@campbell-lange.net>
  References: <E9FA92C2921F31408041863B74EE4C2001BD810545@CCPMAILDAG03.cantab.local> <CAOzAquKb+O3iu0pVBonDDSS8SH=a4Wa4hmYFxAbTwUCi7Hxjhg@mail.gmail.com> <D49B7AAD-5EC3-4D62-A263-E22E6633C807@mikatiming.de> <CAKoxK+7x4wEA-AMocZ00b8pAcBe2xZMq_6s8xsKPTWq7tGPdig@mail.gmail.com> <14555705-8010-4A73-8501-EA07B285E1BA@mikatiming.de> <CAKoxK+6exRv9yeLOpZGdOi6uefPDDF1yBJOj_Ph8Sq8b3CmeaQ@mail.gmail.com> <8D19E041-DFA4-40C0-9CCA-36D65548E842@mikatiming.de> <CAKoxK+4XysF-aA3VvFMn6pQYXsgs1o92JZ5uGx8=18Fr8+q4xA@mail.gmail.com> <20190717113441.GB15220@campbell-lange.net> <20190719195313.36d5xgcub7kh2vda@hjp.at> <20190722130604.GA17492@campbell-lange.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox