Catalogue 

1. Overview

PanguSync adopts table level data synchronization based on subscription merge publishing principle, and the structure needs to be manually modified on both sides (without modification tasks), suitable for Mysql/SQL server/PostgreSQL. This mechanism requires the table to have a primary key (composite primary key is also acceptable), and the source will add the auxiliary field C_PanguSyncSourceTimestamp, while the target will add the auxiliary field C_PanguSyncTargetTimestamp. Therefore, for insert statements in business systems, fields must be specified, similar to “insert into table (c1, c2) values (v1, v2)”. Do not actively write values for C_PanguSyncSourceTimestamp and C_PanguSyncTargetTimestamp. The software has made significant optimizations to this synchronization method, and in terms of data synchronization, its reliability far exceeds that of the database's built-in synchronization

 

2.Notes on Cloud Database Deployment

1.The closer the server for deploying PanguSync is to the target database server, the better. If the network latency is significant, it may affect the synchronization speed. If possible, it is best to deploy PanguSync servers and target cloud databases in the same VPC region, and then connect them through an internal network.

2.Cloud databases usually use non root accounts, and when the cloud database is used as the source, it may report insufficient permissions. If the source database name is A, you need to manually create a database with a suffix of _SanguSync on the cloud platform, that is, named A_PanguSync, and then assign all permissions of A_PanguSync to the synchronization user.

 

3. How to batch add tasks

At present, batch configuration tasks for all tables in the same type of database are supported. When adding tasks, selecting a database without selecting a table will result in batch configuration tasks based on all tables in the source, but the table structures on both sides must be completely identical beforehand 

 

4. Initial data batching problem

1.If you encounter the "optimization time value", don't panic. It represents splitting the initial data. After the splitting is completed, the initial data will be synchronized in batches according to the "incremental get rows". The advantage of splitting is that if the task is stopped during the initial full synchronization, the next run will start synchronizing from the disconnected batch.

2.The two parameters related to this action are [Incremental Get] and [Time Optimize], representing the meaning that when the initial data exceeds the [Time Optimize], the initial data is batched, and the number of rows in each batch is [Incremental Get]

3.After starting a transaction in the bottom right corner, although it can improve synchronization speed, it is not recommended to set the [Incremental Get] too large. If there are uncontrollable factors such as network disconnection during the process, it may cause the entire batch of synchronization to fail. Although it is possible to resume from a breakpoint, it is also necessary to restart from the disconnected batch

57834c72-1ddb-4295-9c35-0e3b3aad351def9528b0-46b6-48c0-956e-86a39df23c80

 

 

5.How to deploy A ⇌ B bidirectional synchronization mode

Answer: If A is the primary node and B is the backup node, first use the truncate statement (do not use delete) to clear the data in table B, then deploy the task of B → A, click run successfully, and then deploy the task of A → B, and then click run. If you have tested the bidirectional synchronization of this task before, please execute it on the A side:

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Mysql:update table set C_PanguSyncSourceTimestamp = current_timestamp(6) where C_PanguSyncSourceTimestamp ='2000-01-01 00:00:00.000000'

Sqlserver:update table set C_PanguSyncSourceTimestamp = sysdatetime() where C_PanguSyncSourceTimestamp ='2000-01-01 00:00:00.000000'

PostgreSQL:update "table"  set  "C_PanguSyncSourceTimestamp" = CURRENT_TIMESTAMP where "C_PanguSyncSourceTimestamp" ='2000-01-01 00:00:00.000000'

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

At this point, the full synchronization of A → B will be performed first. After the initial full synchronization of data is completed, incremental synchronization will continue. This mode is suitable for dual machine hot backup of data, where only one fixed node writes and the other node performs hot backup. If A goes down, the business can switch to B for writing. When A recovers, the data written in B during the downtime can be synchronized to A. Note that this mode only writes to a fixed node. If you want to double write, that is, both nodes' business systems are writing data, you need to meet the following conditions: [The primary key is not self increasing]

Otherwise, it may cause data conflicts between the two sides. After the conflict, the synchronization software will synchronize according to the latest policy based on the primary key. Additionally, it should be noted that when deploying bidirectional tasks, the IPs need to correspond to each other (for example, the source IP of task A → B should be exactly the same as the target IP of task B → A, and the target IP of task A → B should be exactly the same as the source IP of task B → A), and the two tasks need to be deployed in the same PanguSync software process.

 

6. How to deploy A → B, A → C, A → D with one primary and multiple backup modes

Answer: Just add tasks A → B, A → C, and A → D separately. A writes, BCD only reads. Writing data in BCD may result in inconsistent data.

 

7. How to deploy A → B → C → D chain mode

Answer: Add synchronization tasks for A → B, B → C, and C → D separately. The task editing interface for A → B and B → C requires checking the "Special Mode" option. If there is a need to continue later, such as synchronizing D to E, then the "Special Mode" option should also be checked in the C → D task. The meaning of the "Special Mode" option is whether the source of the task is synchronized to the downstream of the target after writing. For example, checking the "Special Mode" option in A → B means that A's writing can be synchronized to B's downstream, that is, C. In chain mode, only A can write, and BCD only reads. If BCD writes, it may cause data inconsistency

 

8. How to skip initial data and perform incremental synchronization directly

Answer: PanguSync software performs a full synchronization regardless of your initial data, and then performs incremental synchronization. That is, if the data on both sides is completely consistent, PanguSync will still perform full synchronization first. If you want to skip the initial full synchronization, you need to stop writing to the business system to prevent new data from entering, and then run the task. When the task starts synchronization (when the info jumps), stop the task and execute "SELECT max (C_PanguSyncSourceTimestamp) from the table" on the source side to query the maximum time, as shown in the following figure,

image

Then edit the task and configure C_PanguSyncSourceTimestamp>'2025-03-28 20:11:28.123579' at the 'where' condition, as shown in the following figure

image

Finally, restart the task to directly perform incremental synchronization. Initial data deletion or update can also be synchronized.

 

9. How to resynchronize a piece of data

Answer: For example, in task A → B, if you want to synchronize a certain piece of data in A again, you can execute it in A

------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Mysql:update table set C_PanguSyncSourceTimestamp = current_timestamp(6) where 条件

Sqlserver:update table set C_PanguSyncSourceTimestamp = sysdatetime() where 条件

PostgreSQL:update "table"  set  "C_PanguSyncSourceTimestamp" = CURRENT_TIMESTAMP  where 条件

------------------------------------------------------------------------------------------------------------------------------------------------------------------------

After execution, data that meets the conditions in the source will be resynchronized. It is important to note that the 'where' condition should not contain too many rows of data, and the 'where' condition should not be specified. Otherwise, synchronization may take a long time, which should be avoided.

 

 

 

10. The SQL server has exceeded the maximum nesting level (maximum level is 32)

Answer: When updating the value of a table field in the trigger, it will cause infinite triggering. Users need to add a judgment condition such as if update (field) in their trigger, as shown in the following figure,

image

Alternatively, 【if not update (C_PanguSyncSourceTimestamp)】 is also possible

 

 

11. Automatic field mapping

When the source and target databases are of the same type, after manually adding, modifying, or deleting fields on both sides, there is no need to re edit the task, and the new field data will be automatically synchronized

 

12. How to boot up automatically and run tasks in batches automatically

  1. Set the software as a shortcut, then enter 'shell: startup' in Win+R and drag the shortcut into that directory
  2. Win+R input “control userpasswords2”, cancel "To use this computer, users must enter a username and password"
  3. Add an empty file named “AutoStart.txt” to the “Config” directory of PanguSync software