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

From Dirk Mika
Subject How to run a task continuously in the background
Date
Msg-id 7932668C-EA48-436B-AA15-DB7C8446D57F@mikatiming.de
Whole thread Raw
Responses RE: How to run a task continuously in the background
List pgsql-general

Hi,

 

another oracle -> postgreSQL migration question.

 

I have a database in which a job runs continuously to perform tasks that are inserted into a table in the form of records.

The current Oracle implementation is to use DBMS_JOB to start a job (to be precise, there can be multiple jobs working in parallel) that goes through the following loop:

  • is there anything to do?
    • Yes -> Do Tasks
    • No  -> 1 second sleep
  • Was the EXIT command sent to me?
    • Yes -> Exit loop.

 

The question now is how do I start in PostgreSQL a background task that meets the following requirements:

  1. It must continue to run even if the connection in which the task was started is terminated.
  2. I need to be able to check if a background task exists.
  3. I need to be able to finish the background task without explicitly sending the EXIT command (see above) to the task.

 

I've already looked at the pg_background extension, but I don't think it meets either requirement 2 or requirement 3. But maybe I just didn’t look hard enough. And with regard to requirement 1, I'm not sure that's guaranteed.

 

Any suggestions on how this might be realized. Preferably without an external application.

 

BR

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: Gavin Flower
Date:
Subject: Re: migrating from Oracle to PostgreSQL 11
Next
From: Steven Winfield
Date:
Subject: RE: How to run a task continuously in the background