Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pg_timetable.current_chain_id is not available for autonomous tasks #584

Closed
pashagolub opened this issue Jul 3, 2023 · 0 comments
Closed
Assignees
Labels
🐞 bug Something isn't working

Comments

@pashagolub
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant