Skip to content

Checking your reading list…

Retry verification

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

Accidental Table Deletion Recovery in Chinese Databases: Flashback, PITR & Delayed Replicas Compared
Databases 15 min read

Accidental Table Deletion Recovery in Chinese Databases: Flashback, PITR & Delayed Replicas Compared

This article compares how eight databases — Oracle, DB2, MySQL, PostgreSQL, GaussDB, GoldenDB, TiDB, and OceanBase — handle accidental table deletion using flashback/recycle bin, point-in-time backup recovery, and delayed replicas, revealing that domestic databases still lack mature failover to delayed replicas.

Introduction

A recent incident at a major state-owned bank in China highlighted the risk: an accidental table drop in a domestic database caused business disruption, and recovery took several days due to the large data volume. This article surveys how traditional databases (Oracle, DB2, MySQL, PostgreSQL) and Chinese domestic databases (GaussDB, GoldenDB, TiDB, OceanBase) handle DROP TABLE or TRUNCATE TABLE mistakes, focusing on three recovery strategies: flashback/recycle bin, backup-based point-in-time recovery (PITR), and delayed replicas.

Three Recovery Approaches

1. Flashback / Recycle Bin

This logical-layer technique avoids immediate physical deletion. Instead, dropped objects are hidden or historical versions are retained via MVCC/UNDO, allowing quick "undo" within a time window. It is the fastest method with minimal system impact.

MVCC/UNDO-based flashback: Old row versions are kept in undo space; flashback query reads a past snapshot, flashback table generates reverse DML from undo logs.

Recycle bin: DROP TABLE renames the object (e.g., BIN$…) and moves it to a logical recycle bin. Recovery ( FLASHBACK TABLE … TO BEFORE DROP) is a metadata-only operation, hence near-instant. Objects are purged automatically after a retention period or under space pressure.

2. Backup Recovery (PITR)

The traditional, most reliable fallback. Uses full backups, incremental backups, and archive logs to restore to a point just before the error. Two common architectures:

Single-stage: Backup streams directly to centralized storage. Saves resources but restore speed depends entirely on backend storage read performance and network bandwidth.

Two-stage: Backup writes first to local high-performance storage (NAS/OBS), then to centralized storage. Restore reads from local copy first, drastically cutting RTO. Requires 2–3× the database size in local storage.

The bank incident mentioned above used single-stage centralized backup restore and needed two to three days to complete.

3. Delayed Replica

A standby that intentionally lags behind the primary by a configured interval (e.g., 2 hours). When the primary suffers a logical error, the standby has not yet applied the offending transaction. Options: (a) set standby read-only, export the missing data, and import back to primary; (b) skip the bad transaction on the standby and promote it to serve traffic. Characteristics:

Requires a separate management cluster with at least one full replica's worth of server resources.

Delay threshold is adjustable; skipping the bad transaction ID preserves data integrity and enables rapid business recovery.

Standby storage grows because logs accumulate unapplied.

Primary and standby must share a precise NTP time source; otherwise delay accuracy suffers.

While most domestic databases now support basic delayed replay, the article notes that none yet provide a product-level capability to automatically promote a delayed standby to primary during an incident . The operational process and recovery timeliness remain immature for production use.

Database Feature Comparison

Oracle

Flashback/Recycle Bin: Supported ( FLASHBACK TABLE … TO BEFORE DROP).

Backup: RMAN tool.

Delayed Replica: Configure LOG_ARCHIVE_DEST_n with DELAY attribute in Data Guard.

DB2

Flashback/Recycle Bin: Not supported.

Backup: BACKUP and RESTORE commands, forward and backward recovery.

Delayed Replica: HADR focuses on log shipping latency; no built-in parameter to delay log apply.

MySQL

Flashback/Recycle Bin: Not supported natively; DROP/TRUNCATE is immediately logical.

Backup: xtrabackup for physical backup/restore.

Delayed Replica: CHANGE MASTER TO MASTER_DELAY = N (seconds) on replica; SQL thread waits N seconds before executing relay log events.

PostgreSQL

Flashback/Recycle Bin: Not supported; DROP TABLE is irreversible.

Backup: WAL-based PITR.

Delayed Replica: Set recovery_min_apply_delay on standby.

GaussDB (for openGauss)

Flashback/Recycle Bin: Supported via GUC enable_recyclebin. FLASHBACK TABLE … TO BEFORE DROP/TRUNCATE. Retention controlled by recyclebin_retention_time (default 15 minutes).

Backup: gs_roach tool.

Delayed Replica: Same recovery_min_apply_delay as PostgreSQL. Caveat: with synchronous_commit = remote_apply, primary waits for standby apply, adding delay to primary commit latency.

GoldenDB

Flashback/Recycle Bin: Supported from V6 (default off). Distributed flashback ensures consistency across all shards.

Backup: Distributed consistent backup.

Delayed Replica: MySQL-native MASTER_DELAY plus V6 DRSP architecture supports cluster-level delayed replication threshold.

TiDB

Flashback/Recycle Bin: FLASHBACK TABLE <table_name> TO TIMESTAMP … uses MVCC versions. Since v4.0, recovers DROP / TRUNCATE tables. FLASHBACK CLUSTER can flash back the entire cluster.

Backup: Snapshot-based PITR.

Delayed Replica: Set sync-delay in TiCDC sync task to lag downstream cluster.

OceanBase

Flashback/Recycle Bin: Built-in recycle bin for DROP TABLE / DROP DATABASE. Recover with FLASHBACK TABLE/DATABASE … TO BEFORE DROP. Also supports SELECT … AS OF SCN/TIMESTAMP … for snapshot queries.

Backup: Tenant-level backup.

Delayed Replica: Physical standby (tenant-level) supports delayed sync via ls_gc_delay_time (controls log retention) or by pausing log sync on standby. No single parameter to control apply delay directly.

Conclusion

For logical deletion faults, flashback/recycle bin delivers minute-level response; backup recovery is the ultimate guarantee of data integrity but suffers from long RTO; delayed replica offers a middle ground on resources and speed. However, domestic databases currently lack the product capability to fail over to a delayed standby as the new primary — both the emergency process and recovery timeliness are not yet mature enough for practical deployment.

About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

TiDBflashbackOceanBasePITRGaussDBGoldenDBdelayed replicaaccidental table deletion

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion