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

API inconsistency: cron.unschedule(jobid) can unschedule jobs of another user but cron.unschedule(jobname) cannot #320

Open
Ngalstyan4 opened this issue Apr 17, 2024 · 0 comments

Comments

@Ngalstyan4
Copy link
Contributor

Ngalstyan4 commented Apr 17, 2024

The API function cron.unschedule has two overloaded versions - one takes a jobid, the other takes a jobname.

The one taking jobid unschedules the job without looking at the current user column. As a result, one user can unschedule jobs created by another user so long as row level security rules allow for record visibility.

But, the version of cron.unschedule function that takes a job name behaves differently.
It filters for jobs started by current user (source) and reports that task was not found if the task with the passed name was started by another user.

SET ROLE some_non_superuser;

SELECT cron.schedule('some_name', '1 second', $$SELECT 1$$) as some_name_jobid \gset

SET ROLE some_superuser;

\set ON_ERROR_STOP off
SELECT cron.unschedule('some_name'); --fails
\set ON_ERROR_STOP on

SELECT cron.unschedule(:some_name_jobid); --succeeds

The fix probably is to delete the mentioned lines above, or add them in cron_schedule, depending on intended API.

Ngalstyan4 added a commit to lanterndata/lantern that referenced this issue Apr 17, 2024
- Grant necessary permissions to pg_cron resources and lantern.tasks
  table
- Refactor pg_cron unscheduling logic to bypass pg_cron unscheduling
related issue: citusdata/pg_cron#320
citusdata/pg_cron#320
Ngalstyan4 added a commit to lanterndata/lantern that referenced this issue Apr 26, 2024
- Grant necessary permissions to pg_cron resources and lantern.tasks
  table
- Refactor pg_cron unscheduling logic to bypass pg_cron unscheduling
related issue: citusdata/pg_cron#320
citusdata/pg_cron#320
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