Re: How to run a task continuously in the background - Mailing list pgsql-general

From Luca Ferrari
Subject Re: How to run a task continuously in the background
Date
Msg-id CAKoxK+6exRv9yeLOpZGdOi6uefPDDF1yBJOj_Ph8Sq8b3CmeaQ@mail.gmail.com
Whole thread Raw
In response to Re: How to run a task continuously in the background  (Dirk Mika <Dirk.Mika@mikatiming.de>)
Responses Re: How to run a task continuously in the background  (Dirk Mika <Dirk.Mika@mikatiming.de>)
List pgsql-general
On Tue, Jul 16, 2019 at 7:32 AM Dirk Mika <Dirk.Mika@mikatiming.de> wrote:
> It's not really important that the job runs once a second, but that it starts immediately when I want it to.
>
> If I start a job with pg_cron, it will not be executed until the next full minute at the earliest.
>
> The processing of the data via a job is deliberately chosen so as to separate the insertion of the data from their
processing.

So, as far as I understand, you want asynchronously processing data
with a process that can be started manually and/or periodically.
I'm probably unable to see what is the goal, but I would go for a
combined solution:
1) a trigger that notifies an external process
<https://www.postgresql.org/docs/current/sql-notify.html>
2) the process runs when notified (by the trigger) or when started
manually or when started by pg_cron (one per minute).

Of course the process is "internal", so something like a stored
procedure (at least as entry point).
The problem with such solution is about race conditions (what if you
manually start something that is already running?), but I guess you
had this problem on the oracle side too.

Hope this helps.
Luca



pgsql-general by date:

Previous
From: Luca Ferrari
Date:
Subject: Re: after restore the size of the database is increased
Next
From: Luca Ferrari
Date:
Subject: Re: help understanding pgbench results