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

sql: block DROP TENANT based on a session var #99607

Merged
merged 1 commit into from
Mar 30, 2023

Commits on Mar 28, 2023

  1. sql: block DROP TENANT based on a session var

    In clusters where we will promote tenant management operations, we
    would like to ensure there is one extra step needed for administrators
    to drop a tenant (and thus irremedially lose data). Given that
    `sql_safe_updates` is not set automatically when users open their
    SQL session using their own client, we need another mechanism.
    
    This change introduces the new (hidden) session var,
    `disable_drop_tenant`. When set, tenant deletion fails with the
    following error message:
    
    ```
    demo@127.0.0.1:26257/movr> drop tenant foo;
    ERROR: rejected (via sql_safe_updates or disable_drop_tenant): DROP TENANT causes irreversible data loss
    SQLSTATE: 01000
    ```
    
    (The session var `sql_safe_updates` is _also_ included as a blocker in
    the mechanism so that folk using `cockroach sql` get double
    protection).
    
    The default value of this session var is `false` in single-tenant
    clusters (set via a cluster setting `sql.drop_tenant.enabled`), for
    compatibility with CC Serverless. The default will be set to `true`
    via a config profile when suitable.
    
    Release note: None
    knz committed Mar 28, 2023
    Configuration menu
    Copy the full SHA
    bdc8d1a View commit details
    Browse the repository at this point in the history