Shadow table synchronization
Background information
The shadow table synchronization feature in OceanBase Developer Center (ODC) automatically creates a shadow table in the current database based on the schema of a source table. The shadow table name is generated by adding a prefix or suffix to the source table name. This is useful for scenarios such as end-to-end stress testing.
This document describes how to create and view shadow table sync tasks in ODC.
In ODC V4.0.0 and later, the shadow table synchronization feature supports only MySQL mode. If a source table contains subpartitions, only HASH/KEY subpartition templates are supported.
After a shadow table is created, you can view it in the table object list.
When you create a shadow table, if a table with the same name already exists but has a different schema, a sync SQL statement is generated to update the shadow table's schema.
Create a shadow table sync task
Example: In the mysql410 data source, create the shadow table employee_t in the odc_test database.
Item |
Example Value |
Data Source |
mysql4.2.0 |
Database Name |
odc_test |
Source Table Name |
employee |
Shadow Table Name |
employee_t |
In the SQL development window, on the Ticket tab, click Shadow Table Sync > Create Shadow Table Sync Task.
In the Create Shadow Table Sync Task panel, specify the following information.
Select objects.
Item
Description
Database
Select the database where you want to create the shadow table. The name of the current data source is also displayed.
Sync Scope
Select the tables to sync:
Partial Tables: Creates shadow tables for selected tables in the current database. To select all source tables, select the checkbox to the left of the search box.
All Tables: Creates shadow tables for all tables from the source database in the current database.
Shadow Table Name
Create a shadow table name using the format Prefix + `Source Table Name` or `Source Table Name` + Suffix. The prefix and suffix are customizable.
Sync Objects
If you choose to sync partial tables, select the source tables in the Sync Objects section.
Click **Next** to analyze the shadow table schema.
Item
Description
Tables to Sync
On the Tables to Sync tab, the source table name, shadow table name, and analysis result are displayed. Click View to see the source table schema, shadow table schema, and schema evolution SQL statement. Click Skip to exclude the shadow table from synchronization.
Tables Not to Sync
On the Tables Not to Sync tab, the source table name, shadow table name, and analysis result are displayed. Click Cancel Skip to include the shadow table in the synchronization.
NoteTables that you choose to skip are displayed on the **Tables Not to Sync** tab.
If a shadow table with the same name already exists and its schema is identical to the source table, the schema sync for that table is skipped automatically.
SQL Preview
Displays the SQL statements for syncing the table schemas.
Task Settings
Select an Execution Method for after the task is approved.
Sync Immediately: Executes the sync task immediately.
Scheduled Sync: Executes the sync task at a scheduled time.
Select a method for Task Error Handling.
Stop Task: If an error occurs during execution, the task stops and does not execute subsequent SQL scripts.
Ignore Errors and Continue: If an error occurs during execution, the task skips the failed SQL script and continues to execute the remaining SQL scripts.
Description
Describe the business background of the project, such as the purpose and expected goals of the change.
After you specify the information, click the Submit button in the lower-right corner of the panel to create the shadow table sync task.
After the task is created, the Task Hub panel appears automatically. In the Task Hub, you can view the task's approval status and other information.
View a shadow table sync task
Task information
In the Task Hub, find the shadow table sync task in the list and click the View button in the Operations column.
In the task details panel that appears, click the Task Information tab to view basic information and settings for the task.
In the lower-right corner of the panel, click Run Again to restart the task.
Task flow
In the task details panel, click the Task Flow tab to view information such as Task Submission Status, Approval Status, Execution Status, and Completion Result.
In the lower-right corner of the panel, click Run Again to restart the task.
Task logs
In the task details panel, click the Task Logs tab to view all logs and alert logs for the task.
Item
Description
All Logs
The **All Logs** section displays all log information for the task, including INFO, ERROR, and WARN logs.
Use the Find, Download, and Copy buttons to search for information or to download or copy all logs.
Alert Logs
The **Alert Logs** section displays only the ERROR and WARN logs for the task. If a task fails, you can check the alert logs for error messages.
Use the Find, Download, and Copy buttons to search for information or to download or copy the alert logs.
Click Run Again to restart the task.