Postgre-SQL Flexible Server - pg_cron permissions issue

Herman, Justin 30 Reputation points
2024-11-20T22:35:13.98+00:00

I am connecting to the postgres database with the psqladminun user who is a member of the azure_pg_admin role.

I run the following:

CREATE EXTENSION pg_cron;

After that I go to schedule a job:

SELECT cron.schedule_in_database('part_maint_TEST','0 * * * *', 'call partman.cron_maintain_partitions();', 'TEST');

I receive the following error:

ERROR: permission denied for function schedule_in_database

SQL state: 42501

I verified that psqladminun truly doesn't have privs by checking the following:

SELECT has_function_privilege('psqladminun', 'cron.schedule_in_database(text, text, text, text, text, boolean)', 'EXECUTE');

How is this possible?

Database is PG 16.4

I don't have this issue in other Flexible Server setups that are on PG14.

Thanks,

Justin

Azure Database for PostgreSQL
{count} vote

Accepted answer
  1. Oury Ba-MSFT 19,886 Reputation points Microsoft Employee
    2024-11-27T22:07:16.32+00:00

    @Herman, Justin Thank you for reaching out and for being patient while we resolved this issue.

    The issue was resolved by opening a support ticket. The backend team updated the permissions on the affected resource.

    Our product team is aware of this known issue caused by the latest deployment, and the upcoming releases will address this fix.

    In the meantime, if you have any questions or concerns, please feel free to reach out. We are happy to help.

    Thank you for accepting this answer as it will be useful for other community members with the same issue.

    Regards,

    Oury


1 additional answer

Sort by: Most helpful
  1. hossein jalilian 8,840 Reputation points
    2024-11-20T23:41:22.3933333+00:00

    Thanks for posting your question in the Microsoft Q&A forum.

    Double-check that psqladminun is indeed a member of azure_pg_admin:

    SELECT pg_has_role('psqladminun', 'azure_pg_admin', 'MEMBER');
    
    

    If the above check confirms membership, try granting explicit permissions to the azure_pg_admin role:

    GRANT USAGE ON SCHEMA cron TO azure_pg_admin;
    GRANT ALL ON ALL FUNCTIONS IN SCHEMA cron TO azure_pg_admin;
    
    

    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.