Set statement_timeout for one role in Citus i.e. Azure Cosmos DB for Postgresql

Anuj Seth 20 Reputation points
2024-09-16T07:10:33.0266667+00:00

I want to set the statement_timeout for one specific user of our DB.

While I can do this in stock Postgres:

alter role yourRoleName set statement_timeout='3 min'; --all new sessions of this user

Citus/Azure Cosmos Db for Postgres

  1. Does not allow me to do this on the psql prompt while conncted as the citus user
  2. I cannot find any place in the portal to change this setting per user (not system wide - that I found in the portal and is not what I want to do).
Azure Database for PostgreSQL
{count} votes

Accepted answer
  1. Vinodh247 34,741 Reputation points MVP Volunteer Moderator
    2024-09-16T10:18:27.22+00:00

    Hi Anuj Seth,

    Thanks for reaching out to Microsoft Q&A.

    In azure cosmos db for postgresql (citus), the approach for setting user specific configurations like 'statement_timeout' is different from standard postgresql due to its distributed nature. Azure cosmos db for postgresql might not support the same level of per-role configuration directly through standard sql commands, especially for distributed settings.

    Probably workarounds:

    1. Since direct per-role settings might not be supported, you could handle this at the application level. For example, you can set the 'statement_timeout' parameter for a connection in your application code when a user connects. This can be achieved by setting the timeout in the connection string or in the application logic when creating a connection.
    2. if you have control over the application or connection management, you can set 'statement_timeout' at the beginning of each session for the specific user. This needs to be done every time the user connects or executes a statement.

    Set statement_timeout = '3 min';

    1. Citus might have its own ways to manage configuration settings or user roles, but they might not support fine-grained configuration like postgresql. Check citus or azure cosmos db documentation for any supported methods or features related to user-specific settings.
    2. implement a proxy or middleware layer that enforces the timeout for specific users. This layer would need to intercept queries and apply the desired 'statement_timeout' setting.

    Directly setting 'statement_timeout' for a specific role might not be supported in azure cosmos db for postgresql as it is in stock postgresql. You may need to implement application-level settings or use alternative approaches like session-level settings or contacting azure support for further assistance.

    Please 'Upvote'(Thumbs-up) and 'Accept' as an answer if the reply was helpful. This will benefit other community members who face the same issue.

    0 comments No comments

0 additional answers

Sort by: Most 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.