Recycle bin for tenants

2023-10-27 09:57:43  Updated

This topic describes how to manage the recycle bin for tenants. This includes how to view objects in a recycle bin and how to enable, disable, and purge a recycle bin.

The sys tenant cannot be dropped. The recycle bin for tenants is managed by the sys tenant through the statements related to the recycle bin.

Only the tenant objects in the sys tenant can be placed in the recycle bin.

Considerations

The constraints on the tenants in the recycle bin are as follows:

  • The DROP TENANT statement converts a tenant name into a unified format within the recycle bin. The space occupied by the tenant is not released, but new connections to the tenant cannot be created.

  • When executing PURGE TENANT, you can use either the original tenant name or the tenant name in the recycle bin. Unlike FLASHBACK, when purging a tenant with multiple identical original names, PURGE TENANT will delete the one that entered the recycle bin first.

    For more information about flashing back objects in the recycle bin, see Flash back objects in the recycle bin.

The constraints on the primary/standby cluster are as follows:

  • In a standby cluster, automatic execution of operations such as DROP TENANT, DROP TENANT FORCE, DROP TENANT PURGE, FLASHBACK TENANT, or PURGE TENANT is not allowed. All these operations must be synchronized from the primary cluster.

  • The PURGE RECYCLEBIN operation can be executed for a standby cluster. However, it will not delete tenants that belong to this cluster in the recycle bin.

View objects in the recycle bin

Execute the SHOW RECYCLEBIN statement in the sys tenant to view all objects in the recycle bin.

Background information

When the sys tenant executes the DROP TENANT statement on another tenant:

  • If the recycle bin is enabled, the tenant will be moved to the recycle bin and can be queried in the recycle bin.

  • If the recycle bin is disabled, the tenant will not be moved to the recycle bin and cannot be queried in the recycle bin.

Procedure

  1. Log on to the sys tenant as the root user.

  2. Execute the following statement to view the objects in the recycle bin.

    Example:

    obclient> SHOW RECYCLEBIN;
    +--------------------------------+----------------+----------+----------------------------+
    | OBJECT_NAME                    | ORIGINAL_NAME  | TYPE     | CREATETIME                 |
    +--------------------------------+----------------+----------+----------------------------+
    | __recycle_$_1_1600136460199936 | wendo_table    | TABLE    | 2020-09-15 10:21:00.207886 |
    | __recycle_$_1_1600136479664128 | wendo_database | DATABASE | 2020-09-15 10:21:19.664534 |
    | __recycle_$_1_1600135793000960 | mysql          | TENANT   | 2020-09-15 10:23:25.773877 |
    +--------------------------------+----------------+----------+----------------------------+
    3 rows in set
    

    where:

    • OBJECT_NAME indicates the name of the object in the recycle bin.

    • ORIGINAL_NAME indicates the original name of the object.

    • TYPE indicates the type of the object in the recycle bin. Supported object types are INDEX, TABLE, DATABASE, and TENANT. In this example, mysql is a tenant object in the recycle bin.

    • CREATETIME indicates the time when the object was placed in the recycle bin.

Enable or disable the recycle bin

The recycle bin is disabled for the sys tenant by default. If the recycle bin is enabled for the sys tenant, when you execute the DROP TENANT statement on a specific tenant, that tenant will be moved to the recycle bin.

The procedure for enabling or disabling the recycle bin is as follows:

  1. Log on to the sys tenant as the root user.

  2. Execute the following statement to view the state of the recycle bin:

    obclient> SHOW VARIABLES LIKE 'recyclebin';
    +---------------+-------+
    | Variable_name | Value |
    +---------------+-------+
    | recyclebin    | OFF   |
    +---------------+-------+
    1 row in set
    
  3. Execute the following statements to enable and disable the recycle bin feature.

    The recyclebin variable is Boolean and can be set to one of the following values:

    • on, 1, or true: indicates that the recycle bin is enabled for the tenant.

    • off, 0, or false: indicates that the recycle bin is disabled for the tenant.

    Syntax:

    obclient> SET GLOBAL recyclebin = on;
    
    obclient> SET GLOBAL recyclebin = off;
    

    or

    obclient> SET GLOBAL recyclebin = 1;
    
    obclient> SET GLOBAL recyclebin = 0;
    

    or

    obclient> SET GLOBAL recyclebin = true;
    
    obclient> SET GLOBAL recyclebin = false;
    
  4. After the recycle bin is enabled or disabled, log on again and create a new session to make the setting take effect.

Purge the recycle bin

In the sys tenant, the PURGE statement can be used to purge the tenants or all objects in the recycle bin.

  1. Log on to the sys tenant as the root user.

  2. Execute an appropriate statement as needed to purge the recycle bin.

    • Purge tenants from the recycle bin

      obclient> PURGE TENANT tenant_name;
      

      where tenant_name can be set to the original tenant name or the tenant name in the recycle bin. If multiple tenants have the same original name, the first tenant that entered the recycle bin first will be deleted.

      If you purge a tenant from the recycle bin, all objects in the tenant will be purged.

      Note

      The objects discussed in this topic are tenants. For details about purging other types of objects from the recycle bin, see Recycle bin for databases, tables, and indexes.

    • Purge all objects from the recycle bin

      obclient> PURGE RECYCLEBIN;
      
  3. (Optional) Execute the following statement to check whether the objects that meet the specified conditions have been purged from the recycle bin:

    obclient> SHOW RECYCLEBIN;
    

Contact Us