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

From Dirk Mika
Subject Re: How to run a task continuously in the background
Date
Msg-id 8D19E041-DFA4-40C0-9CCA-36D65548E842@mikatiming.de
Whole thread Raw
In response to Re: How to run a task continuously in the background  (Luca Ferrari <fluca1978@gmail.com>)
Responses Re: How to run a task continuously in the background  (Luca Ferrari <fluca1978@gmail.com>)
List pgsql-general

 

So, as far as I understand, you want asynchronously processing data

with a process that can be started manually and/or periodically.

 

The process should be started manually and then run until it is stopped by a stop_job() function call. In Oracle there is a package which contains the functions engine.start_job() and engine.stop_job(). :-)

I only mentioned “periodic” because the current Oracle implementation polls to see if there is something to process and goes to sleep for a second when there is no data to process.

 

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

2) the process runs when notified (by the trigger) or when started

manually or when started by pg_cron (one per minute).

 

That is basically still my main question. How do I start a background job (e.g. a function) which waits by polling or LISTEN / NOTIFY for records in a table to be processed.

 

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.

 

In the Oracle world, there is a maximum of one job that takes care of processing.

 

Dirk

 

--
Dirk Mika
Software Developer



mika:timing GmbH
Strundepark - Kürtener Str. 11b
51465 Bergisch Gladbach
Germany

fon +49 2202 2401-1197
dirk.mika@mikatiming.de
www.mikatiming.de

AG Köln HRB 47509 * WEEE-Reg.-Nr. DE 90029884
Geschäftsführer: Harald Mika, Jörg Mika


 
Attachment

pgsql-general by date:

Previous
From: Dirk Mika
Date:
Subject: Re: How to run a task continuously in the background
Next
From: Rob Sargent
Date:
Subject: Re: How to run a task continuously in the background