Database data synchronization exception processing method based on savepoint
By employing a savepoint mechanism during database data synchronization, data write operations are divided into batches, and rollback to the batch savepoint is performed when an exception occurs, automatically handling exceptions. This solves the problems of low efficiency and high coupling in existing technologies, and achieves efficient and automated exception handling.
Patent Information
- Application Number
- CN202610039052.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-13
- Publication Date
- 2026-03-20
AI Technical Summary
In the current database data synchronization process, the exception handling method causes the entire transaction to be rolled back, which reduces efficiency. Moreover, the exception handling logic is highly coupled with the data writing logic, making it difficult to automate and generalize.
By employing a savepoint mechanism, data write operations are divided into batches, and a batch savepoint is created in each loop to roll back to the exception batch processing. This automatically identifies and handles exceptions, reduces overall transaction rollback, and improves efficiency and automation.
By controlling savepoints at the batch level, overall transaction rollback is avoided, resource consumption is reduced, data synchronization efficiency is improved, and exception handling is automated and universal.
Smart Images

Figure CN121705090A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of database and data synchronization technology, and in particular to a method for handling database data synchronization anomalies based on savepoints. Background Technology
[0002] As information systems grow in scale, data synchronization between databases typically involves continuous write operations of large amounts of data, often using transactions to ensure data consistency. In actual synchronization, data write failures frequently occur due to primary key conflicts, unique key conflicts, or missing data.
[0003] During data synchronization, due to inconsistencies in data states between the source and target ends, differences in historical data, or concurrent writes, anomalies such as primary key conflicts, unique key conflicts, and missing updated data often occur. These anomalies are often sporadic and localized, affecting only a small number of data records, but the anomaly handling methods in existing technologies usually have a significant impact on the entire synchronization process.
[0004] In existing technologies, the following methods are typically used to handle data synchronization anomalies:
[0005] 1. Overall transaction rollback method: If any data write fails, the entire transaction is rolled back and the data synchronization operation is re-executed. Although this method is simple to implement, in large transactions or high-concurrency scenarios, it can easily cause a large amount of successfully written data to be repeatedly rolled back and replayed, which not only significantly reduces data synchronization efficiency, but also increases database lock contention and system resource consumption.
[0006] 2. Manual intervention or business layer compensation: The business logic layer captures the exception and performs manual analysis, or processes the abnormal data through customized compensation code. This method is complex to implement, has poor versatility, and the exception handling logic is highly dependent on the specific business scenario. In the presence of multiple exception types or multiple occurrences of exceptions, it is difficult to guarantee the integrity and consistency of the processing logic.
[0007] The existing technologies mentioned above have the following shortcomings: 1. They cannot perform fine-grained control over abnormal data within the same transaction; 2. After an exception occurs, it is often necessary to roll back a large amount of successfully written data, which leads to a significant reduction in data synchronization efficiency; 3. The exception handling logic and the data writing logic are highly coupled, which is not conducive to the automation and generalization of the exception handling process.
[0008] Chinese patent CN116107583A discloses a data synchronization error handling method, storage medium and device. The design of this scheme, which uses the entire transaction as the smallest rollback unit, comes at a high cost in terms of efficiency. Its mode switching and the use of statement-level savepoints also introduce additional complexity and overhead.
[0009] Therefore, how to provide a database data synchronization anomaly handling method to automatically identify and process abnormal data while ensuring transaction consistency, thereby effectively improving data synchronization efficiency in abnormal data handling scenarios, has become an urgent technical problem to be solved. Summary of the Invention
[0010] In view of this, in order to overcome the shortcomings of the prior art, the present invention aims to provide a database data synchronization anomaly handling method based on savepoint.
[0011] According to a first aspect of the present invention, a method for handling database data synchronization anomalies based on savepoints is provided, the method comprising the following steps:
[0012] Start the data synchronization task, initialize a database transaction, and perform data write operations in a loop within the database transaction. Each loop processes a data batch of a preset size, and in each loop, it determines whether to commit the current transaction based on the preset transaction commit conditions.
[0013] Before each data write operation in the loop begins, a batch savepoint is created in the current transaction. If the data write of this batch fails, the data write operation of the current batch is undone by rolling back to the batch savepoint, triggering the automatic exception handling sub-process. If the data write of this batch is successful, the corresponding batch savepoint is released.
[0014] In the automatic exception handling sub-process, an exception handling savepoint is created within the current transaction. The reasons for data write failure are analyzed and classified, and the corresponding data repair operation is performed according to the identified exception type. If the repair is successful, the exception handling savepoint is released and the next loop continues. If the repair fails, the process rolls back to the exception handling savepoint and rolls back the entire transaction.
[0015] Optionally, the database data synchronization exception handling method based on savepoint of the present invention determines whether the accumulated pending data or the executed operation in the current transaction meets the preset transaction commit conditions before each loop of data writing operation. If the transaction commit conditions are met, the current transaction is committed and a new transaction is reinitialized. If the transaction commit conditions are not met, the batch data writing of the current loop continues.
[0016] Optionally, the database data synchronization exception handling method based on savepoint of the present invention includes transaction commit conditions such as the data volume reaching a threshold, the number of operations reaching a threshold, or the time interval reaching a threshold.
[0017] Optionally, the database data synchronization anomaly handling method based on savepoint of the present invention processes a preset size of data batch in each loop, which is achieved in the following ways: before the data synchronization task starts or during execution, a batch size parameter is configured, and the continuous data stream or data set to be synchronized is cut into multiple data blocks of equal or similar size according to the parameter, and each data block is a write batch; or the collected data is a write batch according to a fixed time window.
[0018] Optionally, the savepoint-based database data synchronization exception handling method of the present invention analyzes and classifies the reasons for data write failure in the following way: capturing the SQL execution exception object returned by the database, extracting the standard SQL status code and database-specific error code from the exception object, and identifying the specific exception type by matching the SQL status code and error code with a predefined exception type mapping table.
[0019] Optionally, the database data synchronization exception handling method based on savepoint of the present invention includes at least the following predefined exception types: primary key conflict exception, unique key constraint conflict exception, and target row non-existence exception during update.
[0020] Optionally, the savepoint-based database data synchronization anomaly handling method of the present invention performs corresponding data repair operations according to the identified anomaly type, including:
[0021] If a primary key conflict or unique key constraint conflict is identified as occurring during data insertion, a delete statement is constructed and executed to delete the existing record causing the conflict in the target table. The conditions of this delete statement are based on the field value of the conflicting key. After successful deletion, the original data insertion statement is executed again.
[0022] If a primary key conflict or unique key constraint conflict is identified as occurring during data update, construct and execute a delete statement to delete the existing record causing the conflict in the target table. After successful deletion, execute the original data update statement again.
[0023] If the target row does not exist when the data to be updated is identified, the original update statement is converted into an insert statement and executed to insert the target data as a new record into the target table.
[0024] Optionally, the database data synchronization exception handling method based on savepoint of the present invention constructs the deletion statement in the following manner: when the exception type is a primary key conflict, the deletion condition exactly matches the primary key field; when the exception type is a unique key constraint conflict, the deletion condition exactly matches all fields constituting the unique constraint.
[0025] Optionally, in the database data synchronization exception handling method based on savepoint of the present invention, in the exception automatic handling sub-process, regardless of whether the identified exception type matches the predefined type, the data repair operation is performed after the exception handling savepoint. If an error occurs during the repair operation or the exception type is not identified, all repair operations in the exception automatic handling sub-process are undone by performing the rollback operation to the exception handling savepoint.
[0026] Optionally, the database data synchronization exception handling method based on savepoint of the present invention further includes reducing database overhead by reducing the frequency of savepoint creation in the following manner: increasing the granularity of savepoint creation from a single data record to the data batch level, so that the total number of savepoints created in a transaction is equal to the number of data processing loops.
[0027] The database data synchronization anomaly handling method based on savepoint of the present invention has the following beneficial technical effects:
[0028] 1. Avoid overall transaction rollback and improve data synchronization efficiency in abnormal scenarios.
[0029] By rolling back only the write batches corresponding to the data that is abnormal during the data synchronization process, the overall transaction rollback is avoided, the number of times the successfully written data is processed is reduced, thereby reducing the transaction rollback frequency and data replay overhead, and significantly improving the data synchronization efficiency in abnormal scenarios.
[0030] 2. Reduce savepoint creation overhead and lower system resource consumption.
[0031] By adopting a batch write approach, savepoints are created at the write batch level, effectively reducing the number of savepoint creation and release operations. This avoids increased database management overhead and decreased write performance caused by creating savepoints for each data operation, thereby reducing overall system resource consumption.
[0032] 3. Implement in-transaction automation for exception handling.
[0033] The identification and handling of data write anomalies are completed within the same transaction, reducing reliance on business layer compensation logic and manual intervention, and improving the automation and consistency of the anomaly handling process.
[0034] 4. Applicable to various database environments, with good versatility and portability.
[0035] Implemented based on standard transactions and savepoint mechanisms, it can be adapted to various relational database systems that support savepoints, and is suitable for different data synchronization application scenarios, with good versatility and portability. Attached Figure Description
[0036] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0037] Figure 1 This is a flowchart illustrating a database data synchronization exception handling method based on savepoint according to an exemplary embodiment 2 of the present invention.
[0038] Figure 2 This is another flowchart illustrating a database data synchronization exception handling method based on savepoint according to an exemplary embodiment 3 of the present invention. Detailed Implementation
[0039] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0040] It should be noted that, in the absence of conflict, the following embodiments and features can be combined with each other; and, based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0041] It should be noted that various aspects of embodiments within the scope of the appended claims are described below. It will be apparent that the aspects described herein can be embodied in a wide variety of forms, and any particular structure and / or function described herein is merely illustrative. Based on this disclosure, those skilled in the art will understand that one aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number of aspects set forth herein can be used to implement the device and / or practice the method. Additionally, this device and / or method can be implemented using structures and / or functionalities other than one or more of the aspects set forth herein.
[0042] Example 1
[0043] Exemplary embodiment 1 of the present invention provides a database data synchronization exception handling method based on savepoint. The method of this embodiment includes the following steps:
[0044] Step 1: Start the data synchronization task, initialize a database transaction, and perform data write operations in a loop within the database transaction. Each loop processes a data batch of a preset size, and in each loop, it determines whether to commit the current transaction based on the preset transaction commit conditions.
[0045] During data synchronization, this embodiment divides the data to be synchronized into multiple write batches according to preset rules, and performs data write operations in batches within the same transaction. For each write batch, a corresponding savepoint is created at the beginning, thereby effectively controlling the number of savepoints created in batch write scenarios. The rules for dividing write batches and the exception handling strategy can be configured according to the data synchronization scenario to adapt to different data scales and exception types.
[0046] It should be noted that, in this embodiment, before each data write operation is executed in a loop, it is determined whether the accumulated data to be processed or the operations already performed in the current transaction meet the preset transaction commit conditions. If the transaction commit conditions are met, the current transaction is committed and a new transaction is re-initialized to carry subsequent write operations. If the transaction commit conditions are not met, the batch data writing of the current loop continues. In practical applications, transaction commit conditions include the data volume reaching a threshold, the number of operations reaching a threshold, or the time interval reaching a threshold.
[0047] In this embodiment, the preset size of data batches is processed in each cycle, which is achieved in the following way: before the data synchronization task starts or during the execution, a batch size parameter is configured, and the continuous data stream or data set to be synchronized is cut into multiple data blocks of equal or similar size according to the parameter, and each data block is a write batch; or the collected data is a write batch according to a fixed time window.
[0048] Step 2: Before each data write operation in the loop begins, create a batch savepoint in the current transaction; if the data write of this batch fails, roll back to the batch savepoint to undo the data write operation of the current batch and trigger the automatic exception handling sub-process; if the data write of this batch succeeds, release the corresponding batch savepoint.
[0049] In this embodiment, a savepoint is a type of transaction save point in the database transaction control mechanism, used to mark a rollback point within the same transaction. After a savepoint is created during transaction execution, if an exception occurs in subsequent operations, the transaction can be rolled back to that savepoint without having to roll back the entire transaction. After rolling back to the savepoint, transaction operations that were successfully executed before that savepoint remain valid.
[0050] When an exception occurs during data writing, this invention does not roll back the entire transaction. Instead, it rolls back to the savepoint corresponding to the write batch where the exception occurred, only undoing the data write operation for the current batch. Subsequently, the write exception is analyzed to determine the exception type, and the exception handling operation corresponding to that type is executed within the same transaction. After exception handling is completed, subsequent data synchronization operations continue; if exception handling fails, the exception handling operation or the current transaction is rolled back. Through this method, this invention achieves automatic processing of abnormal data while ensuring transaction consistency, avoiding overall transaction rollback, thereby improving data synchronization efficiency in abnormal data handling scenarios.
[0051] As an optional instance, in the automatic exception handling sub-process, an exception handling savepoint is created within the current transaction to analyze and classify the reasons for data write failures, and to perform corresponding data repair operations according to the identified exception type. If the repair is successful, the exception handling savepoint is released and the next loop continues. If the repair fails, the process is rolled back to the exception handling savepoint and the entire transaction is rolled back.
[0052] It should be noted that in this embodiment, the reasons for data write failures are analyzed and classified in the following way: The SQL execution exception object returned by the database is captured; standard SQL status codes and database-specific error codes are extracted from the exception object; and the specific exception type is identified by matching the SQL status codes and error codes with a predefined exception type mapping table. For example, the predefined exception types include at least primary key conflict exceptions, unique key constraint conflict exceptions, and exceptions where the target row does not exist during the update.
[0053] If a primary key conflict or unique key constraint conflict is identified as occurring during data insertion, a delete statement is constructed and executed to delete the existing record causing the conflict in the target table. The delete statement's condition is based on the field value of the conflicting key. After successful deletion, the original data insertion statement is executed again. In this embodiment, the delete statement is constructed as follows: when the exception type is a primary key conflict, the delete condition precisely matches the primary key field; when the exception type is a unique key constraint conflict, the delete condition precisely matches all fields constituting the unique constraint, to ensure the accuracy and minimum scope of the deletion operation and avoid accidentally deleting other data.
[0054] If a primary key conflict or unique key constraint conflict is identified as occurring during data update, a delete statement is constructed and executed to delete the existing record causing the conflict in the target table. After successful deletion, the original data update statement is executed again. If the target row does not exist when updating data, the original update statement is converted into an insert statement and executed to insert the target data as a new record into the target table.
[0055] In this embodiment, the automatic exception handling sub-process has an atomicity guarantee mechanism. Specifically, in the automatic exception handling sub-process, regardless of whether the identified exception type matches the predefined type, the data repair operation is executed after the exception handling savepoint. If an error occurs during the repair operation or the exception type is not identified, all repair operations in the automatic exception handling sub-process are undone by performing a rollback to the exception handling savepoint, so that the transaction state is restored to the node when it first entered this sub-process, that is, it only includes the state after the batch write failure rollback.
[0056] In this embodiment, database overhead is reduced by decreasing the frequency of savepoint creation in the following way: the granularity of savepoint creation is increased from a single data record to the data batch level, so that the total number of savepoints created in a transaction is equal to the number of data processing loops, rather than the total number of records to be synchronized.
[0057] The method in this embodiment, from batch write failure to triggering the exception handling sub-process, to executing the repair operation and judging the result, is all completed within the context of the same database transaction. The transaction is committed or rolled back only when the final repair fails or the transaction commit conditions are met, thus ensuring transactional consistency throughout the "attempt-repair" process. It is applicable to relational databases that support transactions and savepoint mechanisms, including but not limited to MySQL, PostgreSQL, Oracle, SQL Server, and all database management systems that conform to the SQL standard and provide savepoint-related statements.
[0058] Example 2
[0059] Exemplary embodiment 2 of the present invention provides a method for handling database data synchronization anomalies based on savepoints. Figure 1 This is a flowchart illustrating a database data synchronization exception handling method based on savepoint according to an exemplary embodiment 2 of the present invention, as shown below. Figure 1 As shown, the method in this embodiment is applied to a database data synchronization scenario and includes the following steps:
[0060] 1) Transaction initialization steps
[0061] When the data synchronization task begins, a database transaction is initialized to carry out subsequent data write operations.
[0062] 2) Submission condition judgment steps
[0063] Determine whether the currently collected synchronized data meets the transaction commit conditions;
[0064] If the transaction commit conditions are met, then commit the current transaction.
[0065] If the transaction commit conditions are not met, proceed to the data write processing step.
[0066] 3) Create a savepoint
[0067] Create a savepoint in the current transaction to mark the rollback position corresponding to this batch data write operation.
[0068] 4) Data writing steps
[0069] DML statements are generated based on the synchronized data, and then written to the target database in batches. DML is a set of instructions used to manipulate data in a database, mainly including data insertion, update, and deletion operations.
[0070] 5) Write the result judgment step
[0071] Determine whether the data write operation was successful:
[0072] If the write operation is successful, the savepoint created in step 3) is released, and the process jumps to step 2) to continue execution.
[0073] If the write operation fails, the process will roll back to the savepoint created in step 3) and proceed to the exception handling step.
[0074] 6) Steps for judging abnormal data results
[0075] Determine if the abnormal data processing was successful:
[0076] If the write is successful, proceed to step 2) to continue execution.
[0077] If the write operation fails, the entire transaction is rolled back, and an exception message is returned.
[0078] Example 3
[0079] Exemplary embodiment 3 of the present invention provides a method for handling database data synchronization anomalies based on savepoints. Figure 2 This is another flowchart illustrating a database data synchronization exception handling method based on savepoint according to an exemplary embodiment 3 of the present invention, as shown below. Figure 2 As shown, in this embodiment, the exception handling sub-process includes the following steps:
[0080] 1) Exception handling and savepoint creation steps
[0081] Create a savepoint within the current transaction for exception handling to limit the rollback scope of the exception handling operation.
[0082] 2) Parse the exception information generated by data write failure, and identify the exception type based on the error code and SQLState information returned by the exception. The exception type includes at least the following:
[0083] A primary key conflict or unique key conflict exception occurred during data insertion;
[0084] A primary key conflict or unique key conflict exception occurred during data update;
[0085] There were no anomalies in the target data when updating the data.
[0086] 3) Abnormal data processing steps
[0087] Based on the identified anomaly type, perform the corresponding anomaly data processing operation, which includes:
[0088] For primary key or unique key conflicts that occur during data insertion, perform a process to delete the conflicting data before inserting the target data.
[0089] For primary key or unique key conflicts that occur when updating data, perform a process to delete the conflicting data and then update the target data.
[0090] If the target data does not contain any anomalies when updating data, perform the operation of inserting the target data.
[0091] In addition to the above exceptions, roll to the exception handling savepoint created in step 1) and return failure.
[0092] 4) Steps for judging the results of exception handling
[0093] Determine if the abnormal data processing operation was successful:
[0094] If the exception data processing operation is successful, the exception processing savepoint created in step 1) is released, and the successful processing result is returned.
[0095] If the abnormal data processing operation fails, roll back to the abnormal handling savepoint created in step 1), roll back the current transaction, and return the abnormal information.
[0096] In practical applications, the database data synchronization anomaly handling method based on savepoints in this invention has the following beneficial technical effects:
[0097] 1. Avoid overall transaction rollback and improve data synchronization efficiency in abnormal scenarios.
[0098] By rolling back only the write batches corresponding to the data that is abnormal during the data synchronization process, the overall transaction rollback is avoided, the number of times the successfully written data is processed is reduced, thereby reducing the transaction rollback frequency and data replay overhead, and significantly improving the data synchronization efficiency in abnormal scenarios.
[0099] 2. Reduce savepoint creation overhead and lower system resource consumption.
[0100] By adopting a batch write approach, savepoints are created at the write batch level, effectively reducing the number of savepoint creation and release operations. This avoids increased database management overhead and decreased write performance caused by creating savepoints for each data operation, thereby reducing overall system resource consumption.
[0101] 3. Implement in-transaction automation for exception handling.
[0102] The identification and handling of data write anomalies are completed within the same transaction, reducing reliance on business layer compensation logic and manual intervention, and improving the automation and consistency of the anomaly handling process.
[0103] 4. Applicable to various database environments, with good versatility and portability.
[0104] Implemented based on standard transactions and savepoint mechanisms, it can be adapted to various relational database systems that support savepoints, and is suitable for different data synchronization application scenarios, with good versatility and portability.
[0105] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods of various embodiments or some parts of embodiments.
[0106] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for handling database data synchronization anomalies based on savepoints, characterized in that, The method includes the following steps: Start the data synchronization task, initialize a database transaction, and perform data write operations in a loop within the database transaction. Each loop processes a data batch of a preset size, and in each loop, it determines whether to commit the current transaction based on the preset transaction commit conditions. Before each data write operation in the loop begins, a batch savepoint is created in the current transaction. If the data write of this batch fails, the data write operation of the current batch is undone by rolling back to the batch savepoint, triggering the automatic exception handling sub-process. If the data write of this batch is successful, the corresponding batch savepoint is released. In the automatic exception handling sub-process, an exception handling savepoint is created within the current transaction. The reasons for data write failure are analyzed and classified, and the corresponding data repair operation is performed according to the identified exception type. If the repair is successful, the exception handling savepoint is released and the next loop continues. If the repair fails, the process rolls back to the exception handling savepoint and rolls back the entire transaction.
2. The database data synchronization anomaly handling method based on savepoint according to claim 1, characterized in that, Before executing the data write operation in each loop, it is determined whether the accumulated pending data or the operations already executed in the current transaction meet the preset transaction commit conditions. If the transaction commit conditions are met, the current transaction is committed and a new transaction is reinitialized. If the transaction commit conditions are not met, the batch data write of the current loop continues.
3. The database data synchronization anomaly handling method based on savepoint according to claim 2, characterized in that, Transaction commit conditions include the amount of data reaching a threshold, the number of operations reaching a threshold, or the time interval reaching a threshold.
4. The database data synchronization anomaly handling method based on savepoint according to claim 1, characterized in that, Each loop processes a data batch of a preset size, which is achieved in the following way: Before the data synchronization task starts or during execution, a batch size parameter is configured, and the continuous data stream or data set to be synchronized is divided into multiple data blocks of equal or similar size according to the parameter, with each data block being a write batch; Alternatively, the collected data can be written as a single batch based on a fixed time window.
5. The database data synchronization anomaly handling method based on savepoint according to claim 1, characterized in that, The reasons for data write failures are analyzed and classified in the following way: capture the SQL execution exception object returned by the database, extract the standard SQL status code and database-specific error code from the exception object, and identify the specific exception type by matching the SQL status code and error code with a predefined exception type mapping table.
6. The database data synchronization anomaly handling method based on savepoint according to claim 5, characterized in that, The predefined exception types include at least primary key conflict exception, unique key constraint conflict exception, and target row not found exception during update.
7. The database data synchronization anomaly handling method based on savepoint according to claim 1, characterized in that, Perform corresponding data repair operations based on the identified anomaly type, including: If a primary key conflict or unique key constraint conflict is identified as occurring during data insertion, a delete statement is constructed and executed to delete the existing record causing the conflict in the target table. The conditions of this delete statement are based on the field value of the conflicting key. After successful deletion, the original data insertion statement is executed again. If a primary key conflict or unique key constraint conflict is identified as occurring during data update, construct and execute a delete statement to delete the existing record causing the conflict in the target table. After successful deletion, execute the original data update statement again. If the target row does not exist when the data to be updated is identified, the original update statement is converted into an insert statement and executed to insert the target data as a new record into the target table.
8. The database data synchronization anomaly handling method based on savepoint according to claim 7, characterized in that, Construct the delete statement as follows: When the exception type is a primary key conflict, the delete condition exactly matches the primary key field; when the exception type is a unique key constraint conflict, the delete condition exactly matches all fields that constitute a unique constraint.
9. The database data synchronization anomaly handling method based on savepoint according to claim 1, characterized in that, In the automatic exception handling sub-process, regardless of whether the identified exception type matches the predefined type, the data repair operation is executed after the exception handling savepoint. If an error occurs during the repair operation or the exception type is not identified, all repair operations in the automatic exception handling sub-process are undone by performing a rollback to the exception handling savepoint.
10. The database data synchronization anomaly handling method based on savepoint according to claim 1, characterized in that, The method also includes reducing database overhead by decreasing the frequency of savepoint creation in the following way: increasing the granularity of savepoint creation from a single data record to the data batch level, so that the total number of savepoints created in a single transaction equals the number of data processing loops.
Citation Information
Patent Citations
Data synchronization error processing method, storage medium and equipment
CN116107583A
