Skip to content

pg_timetable.current_chain_id is not available for autonomous tasks #584

Closed
@pashagolub

Description

CREATE OR REPLACE FUNCTION raise_func(text)
  RETURNS void LANGUAGE plpgsql AS
$BODY$ 
BEGIN
   RAISE NOTICE 'Message from chain %: "%"', 
    current_setting('pg_timetable.current_chain_id')::text, 
    $1; 
END; 
$BODY$;

SELECT timetable.add_job(
    job_name            => 'raise client message every minute',
    job_schedule        => '* * * * *',
    job_command         => 'SELECT raise_func($1)',
    job_parameters      => '[ "Hey from client messages task" ]' :: jsonb,
    job_kind            => 'SQL'::timetable.command_kind,
    job_client_name     => NULL,
    job_max_instances   => 1,
    job_live            => TRUE,
    job_self_destruct   => FALSE,
    job_ignore_errors   => TRUE
) as chain_id;

In this example add_job() creates a chain with autonomous task in it. Autonomous tasks are executed outside of chain transaction and some system setting are not set for them

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions