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_terminate_backend and pg_cancel_backend propagation #19

Open
Sakiand opened this issue Oct 21, 2020 · 0 comments
Open

pg_terminate_backend and pg_cancel_backend propagation #19

Sakiand opened this issue Oct 21, 2020 · 0 comments

Comments

@Sakiand
Copy link

Sakiand commented Oct 21, 2020

Scenario: plsh function that runs a script with plsql commands.
For example:
create or replace function sp_fact_maintenance_run(get_start_date date DEFAULT (((last_day(('now'::text)::date) - '1 mon'::interval) + '1 day'::interval))::date, get_end_date date DEFAULT (('now'::text)::date - 1)) returns void language plsh as $$ #!/bin/sh export HOME=/var/lib/postgresql echo "#!/bin/sh" > /var/scripts/fact_maintenance.sh psql -d dwh -c "select sp_fact_maintenance_generate(get_start_date := '$1',get_end_date := '$2' );" parallel -j 40 :::: /var/scripts/fact_maintenance.sh $$;

this function generates and runs a file that containing psql commands.
The fact_maintenance.sh file looks like:
#!/bin/sh
psql -d dwh -c "some command"
psql -d dwh -c "some command"
psql -d dwh -c "some command"
psql -d dwh -c "some command"
......

So after you are launching sp_fact_maintenance_run() you see in pg_stat_activity the parent process of sp_fact_maintenance_run() and 40 processes running concurrently of "some command".
So far so good.

The problem is that in case sp_fact_maintenance_run() is canceled or terminated the "some command"'s still running.
So there is no cancel/terminate propagation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant