A cloud-edge data real-time synchronization method, device and equipment, and a storage medium

CN123012050APending Publication Date: 2026-10-30HANGZHOU WULIAN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611160900.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-31
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0004]有鉴于此,本发明的目的在于提供一种云边数据实时同步方法、装置、设备及存储介质,解决了现有技术中数据同步的效率和准确性低的问题

Benefits of technology

[0016]可见,本发明通过确定待同步业务表对应的同步方向,并根据同步方向确定源端和目的端;其中,当同步方向为边缘到中心方向时,源端为边缘端,目的端为中心端;当同步方向为中心到边缘方向时,源端为中心端,目的端为边缘端;获取待同步业务表对应的同步表注解;其中,同步表注解包括表名、同步周期和实时同步开关;在同步方向为边缘到中心方向时,同步表注解为边缘同步表注解;在同步方向为中心到边缘方向时,同步表注解为中心同步表注解;当待同步业务表中的数据发生变更操作,且变更操作对应的数据库写入执行成功后,基于发生变更操作的数据对应的表名和主键生成生产者变更事件;在满足同步触发条件后,判断实时同步开关是否为开启状态;其中,同步触发条件为在变更操作处于事务上下文时事务提交成功;当实时同步开关为开启状态时,根据生产者变更事件对应的表名和所述主键,读取源端当前最新待同步单条数据,并向目的端执行实时单条同步。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123012050A_ABST
    Figure CN123012050A_ABST
Patent Text Reader

Abstract

This invention discloses a method, apparatus, device, and readable storage medium for real-time cloud-edge data synchronization, applied in the field of data synchronization technology. The method includes: determining the synchronization direction corresponding to the business table to be synchronized, and determining the source and destination ends; obtaining the synchronization table annotation corresponding to the business table to be synchronized; when data in the business table to be synchronized undergoes a change operation and the database write is successful, generating a producer change event based on the table name and primary key; after the synchronization trigger condition is met, determining whether the real-time synchronization switch is in the on state; when the real-time synchronization switch is in the on state, reading the latest single data to be synchronized from the source end, and performing real-time single-data synchronization to the destination end. This invention improves the efficiency and accuracy of data synchronization by triggering real-time synchronization after the data is successfully written and the transaction is committed, through synchronization table annotations, producer change events, and trigger conditions after transaction commit. Simultaneously, it can combine synchronization version numbers to perform updates to avoid old synchronization messages overwriting new data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data synchronization technology, and in particular to a method, apparatus, device and storage medium for real-time data synchronization between cloud and edge. Background Technology

[0002] Existing cloud-edge data synchronization frameworks typically employ periodic tasks for synchronization. While periodic synchronization is suitable for scenarios with large data volumes and low real-time requirements, it has significant shortcomings in certain business applications: First, after data changes, the system needs to wait for the next synchronization cycle, and the central or edge endpoints cannot promptly detect critical state changes. Second, uniformly transforming all tables into high-frequency synchronization significantly increases the pressure on database scanning, network transmission, and remote calls. Third, writing separate real-time push logic for each table results in strong coupling between business code and synchronization logic, leading to significant modifications when adding new tables or adjusting synchronization strategies. Fourth, database updates are usually within transactions; if synchronization is triggered before the transaction is committed, the final rollback data may be pushed to the peer, causing data inconsistency.

[0003] It is evident that improving the efficiency and accuracy of data synchronization is a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to provide a method, apparatus, device and storage medium for real-time cloud-edge data synchronization, which solves the problems of low efficiency and accuracy of data synchronization in the prior art.

[0005] To address the aforementioned technical problems, this invention provides a method for real-time cloud-edge data synchronization, comprising: Determine the synchronization direction corresponding to the business table to be synchronized, and determine the source end and destination end based on the synchronization direction; wherein, when the synchronization direction is from the edge to the center, the source end is the edge end and the destination end is the center end; when the synchronization direction is from the center to the edge, the source end is the center end and the destination end is the edge end. Obtain the synchronization table annotation corresponding to the business table to be synchronized; wherein, the synchronization table annotation includes table name, synchronization period and real-time synchronization switch; when the synchronization direction is from edge to center, the synchronization table annotation is an edge synchronization table annotation; when the synchronization direction is from center to edge, the synchronization table annotation is a center synchronization table annotation; When a change operation is performed on the data in the business table to be synchronized, and the database write operation corresponding to the change operation is successfully executed, a producer change event is generated based on the table name and primary key of the data that has undergone the change operation. After the synchronization triggering condition is met, it is determined whether the real-time synchronization switch is in the on state; wherein, the synchronization triggering condition is that when the change operation is in a transaction context, the transaction corresponding to the change operation is successfully committed; When the real-time synchronization switch is on, the latest single data to be synchronized at the source end is read according to the table name and the primary key corresponding to the producer change event, and real-time single-data synchronization is performed to the destination end.

[0006] Optionally, when a data change operation occurs in the business table to be synchronized, and the database write operation corresponding to the change operation is successfully executed, a producer change event is generated based on the table name and primary key corresponding to the data that underwent the change operation, including: Intercept the method used to perform insert or update operations on the data in the business table to be synchronized, and obtain the change operation; Determine whether the data corresponding to the change operation is data configured with the synchronization table annotation; When the data corresponding to the change operation is data configured with the synchronization table annotation, the change time corresponding to the data is recorded, and after the database write is successfully executed, the producer change event is generated based on the table name and the primary key corresponding to the data in which the change operation occurred.

[0007] Optionally, after a data change operation occurs in the business table to be synchronized, and the database write operation corresponding to the change operation is successfully executed, after generating a producer change event based on the table name and primary key corresponding to the data with the change operation, the process further includes: Determine whether a transaction context exists when the producer change event is generated; When the transaction context exists, the producer change event is cached in the transaction event queue corresponding to the current thread, and the synchronization triggering condition is determined to be met after the transaction corresponding to the transaction context is successfully committed; wherein, when the transaction corresponding to the transaction context is rolled back, the producer change event in the transaction event queue is cleaned up. When the transaction context does not exist, the synchronization triggering condition is determined to be met after the database write is successfully executed.

[0008] Optionally, when the real-time synchronization switch is on, based on the table name and primary key corresponding to the producer change event, the latest single data to be synchronized at the source end is read, and real-time single-data synchronization is performed to the destination end, including: When the synchronization direction is from the edge to the center, the table name and the primary key are obtained by parsing the producer change event, and the current record on the edge side is re-queried based on the table name and the primary key. The current record on the edge side is then used as the latest single data to be synchronized. Compare the change time of the latest single data entry to be synchronized with the last push time of the table-level data corresponding to the business table to be synchronized; When the change time is later than the last push time of the table level, the latest single data to be synchronized will be pushed to the central terminal. If the change time is not later than the last push time of the table level, skip this real-time push.

[0009] Optionally, before pushing the latest single data entry to be synchronized to the central endpoint when the change time is later than the last push time of the table level, the method further includes: In a real-time single-record synchronization scenario, when multiple synchronization messages corresponding to the same primary key are at risk of arriving out of order, and the business table to be synchronized is a business table that supports version control, a synchronization message is constructed based on the latest single data to be synchronized; wherein, the synchronization message includes the primary key, the change time, and the synchronization version number; The synchronization message is sent to the central terminal so that the central terminal performs a version condition update based on the primary key and the synchronization version number. When the current record at the central terminal is not in a logical deletion state, if the current synchronization version number at the central terminal is greater than the synchronization version number carried in the synchronization message, the write operation is rejected. When the current record at the central terminal is in a logical deletion state, new lifecycle data corresponding to the same primary key is allowed to be written to the central terminal.

[0010] Optionally, when the real-time synchronization switch is on, based on the table name and primary key corresponding to the producer change event, the latest single data to be synchronized at the source end is read, and real-time single-data synchronization is performed to the destination end, including: When the synchronization direction is from the center to the edge, the table name and the primary key are obtained by parsing the producer change event. Based on the table name and the primary key, query the current record on the central side again, and use the queried current record on the central side as the latest single data to be synchronized. Based on the target edge selection strategy in the central synchronization table annotation, the target edge set corresponding to the latest single data to be synchronized is determined, and real-time single-data synchronization is performed on the edge ends in the target edge set.

[0011] Optionally, after the synchronization triggering condition is met, determining whether the real-time synchronization switch is in the on state includes: When the synchronization direction is from the edge to the center, determine whether the real-time synchronization switch in the edge synchronization table annotation is in the on state; When the synchronization direction is from the center to the edge, determine whether the real-time synchronization switch in the center synchronization table annotation is in the on state.

[0012] The present invention also provides a cloud-edge data real-time synchronization device, comprising: The synchronization direction determination module is used to determine the synchronization direction corresponding to the business table to be synchronized, and to determine the source end and the destination end according to the synchronization direction; wherein, when the synchronization direction is from the edge to the center, the source end is the edge end and the destination end is the center end; when the synchronization direction is from the center to the edge, the source end is the center end and the destination end is the edge end. The synchronization table annotation acquisition module is used to acquire the synchronization table annotation corresponding to the business table to be synchronized; wherein, the synchronization table annotation includes the table name, synchronization period, and real-time synchronization switch; when the synchronization direction is from the edge to the center, the synchronization table annotation is an edge synchronization table annotation; when the synchronization direction is from the center to the edge, the synchronization table annotation is a center synchronization table annotation; The producer change event determination module is used to generate a producer change event based on the table name and primary key of the data that has undergone the change operation when the data in the business table to be synchronized undergoes a change operation and the database write corresponding to the change operation is successfully executed. The judgment module is used to determine whether the real-time synchronization switch is in the on state after the synchronization trigger condition is met; wherein, the synchronization trigger condition is that the transaction is successfully committed when the change operation is in the transaction context; The real-time synchronization module is used to read the latest single data to be synchronized from the source end according to the table name and the primary key corresponding to the producer change event when the real-time synchronization switch is on, and to perform real-time single-data synchronization to the destination end.

[0013] The present invention also provides a cloud-edge data real-time synchronization device, including a memory and a processor: Memory is used to store computer programs; The processor is used to execute computer programs to implement the above-mentioned real-time cloud-edge data synchronization method.

[0014] The present invention also provides a readable storage medium (i.e., a computer-readable storage medium) storing computer-executable instructions, which, when loaded and executed by a processor, realize the above-mentioned real-time cloud-edge data synchronization method.

[0015] The present invention also provides a computer program product, including a computer program / instructions, which, when executed by a processor, implement the steps of the above-described method.

[0016] As can be seen, this invention determines the synchronization direction corresponding to the service table to be synchronized, and determines the source and destination ends based on the synchronization direction; wherein, when the synchronization direction is from the edge to the center, the source end is the edge end and the destination end is the center end; when the synchronization direction is from the center to the edge, the source end is the center end and the destination end is the edge end; and obtains the synchronization table annotation corresponding to the service table to be synchronized; wherein, the synchronization table annotation includes the table name, synchronization period, and real-time synchronization switch; when the synchronization direction is from the edge to the center, the synchronization table annotation is the edge synchronization table annotation; when the synchronization direction is from the center to the edge, the synchronization table annotation is... Central synchronization table annotation: When a change operation occurs in the data of the business table to be synchronized, and the database write corresponding to the change operation is successfully executed, a producer change event is generated based on the table name and primary key of the data that has undergone the change operation; after the synchronization trigger condition is met, it is determined whether the real-time synchronization switch is in the on state; wherein, the synchronization trigger condition is that the transaction is successfully committed when the change operation is in the transaction context; when the real-time synchronization switch is in the on state, according to the table name and primary key corresponding to the producer change event, the latest single data to be synchronized at the source end is read, and real-time single-row synchronization is performed to the destination end.

[0017] The beneficial effects of this invention are as follows: Compared with the current real-time synchronization or full-text periodic synchronization, this invention limits the data sending end and receiving end by the synchronization direction, and limits whether the business table to be synchronized enters real-time synchronization based on the real-time synchronization switch. Since there is no need to write real-time push logic for each table separately, the efficiency of real-time synchronization is improved. Since synchronization is determined based on two conditions: successful database write execution and synchronization trigger condition, the accuracy of real-time synchronization is improved.

[0018] In addition, the present invention also provides a cloud-edge data real-time synchronization device, equipment, and computer-readable storage medium, which also have the above-mentioned beneficial effects. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0020] Figure 1 A flowchart illustrating a real-time cloud-edge data synchronization method provided in an embodiment of the present invention; Figure 2This is a schematic diagram illustrating out-of-order conflict resolution based on synchronization version number in a real-time synchronization scenario, as provided by an embodiment of the present invention. Figure 3 This is a schematic diagram of the structure of a cloud-edge data real-time synchronization device provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of the structure of a cloud-edge data real-time synchronization device provided in an embodiment of the present invention. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0022] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating a real-time cloud-edge data synchronization method provided in an embodiment of the present invention. The method may include the following steps.

[0023] S101, determine the synchronization direction corresponding to the business table to be synchronized, and determine the source end and destination end according to the synchronization direction; wherein, when the synchronization direction is from edge to center, the source end is the edge end and the destination end is the center end; when the synchronization direction is from center to edge, the source end is the center end and the destination end is the edge end.

[0024] In this embodiment, the execution entity is the source end. Therefore, when the source end is an edge end, the execution entity is the edge end; when the source end is a central end, the execution entity is the central end. The business table to be synchronized in this embodiment is the business table that needs to be synchronized.

[0025] S102, obtain the synchronization table annotation corresponding to the business table to be synchronized; wherein, the synchronization table annotation includes the table name, synchronization period and real-time synchronization switch; when the synchronization direction is from edge to center, the synchronization table annotation is the edge synchronization table annotation; when the synchronization direction is from center to edge, the synchronization table annotation is the center synchronization table annotation.

[0026] In this embodiment, for data tables synchronized from the edge to the center, an edge synchronization table annotation is configured on the corresponding model or synchronization entry point; for data tables synchronized from the center to the edge, a center synchronization table annotation is configured on the corresponding model or synchronization entry point. The synchronization table annotation includes at least the table name, synchronization period, target edge selection strategy, and real-time synchronization switch. The real-time synchronization switch is off by default and is only enabled when the business explicitly requires near-real-time synchronization. In this embodiment, the real-time synchronization switch exists as an annotation attribute. This design separates the synchronization strategy from the business code; when adding a new real-time synchronization business table, typically only the annotation configuration and the necessary target selection strategy need to be adjusted. For example, the synchronization table annotation sets an `immediately` (whether to synchronize in real-time) parameter, which is a boolean value with a default value of `false`. When this parameter is `false`, the table still performs synchronization according to the configured synchronization period; when this parameter is `true`, the table enters the real-time single-row synchronization judgment process after successful insertion or update.

[0027] S103: When a change operation is performed on the data in the business table to be synchronized, and the database write operation corresponding to the change operation is successfully executed, a producer change event is generated based on the table name and primary key of the data that has undergone the change operation.

[0028] The change operations in this embodiment include at least one of insert and update operations. The table name is used to identify the data table undergoing the change, and the primary key is used to uniquely identify the single data record that has been changed. The primary key can be a single field or a composite primary key consisting of multiple fields. This embodiment can monitor data insert and update operations using aspect-oriented programming. When the object being written belongs to the synchronization model (data that needs to be synchronized), a unified operation time (i.e., change time) is written to the object, and a producer change event is generated after the database operation is actually successfully executed. Since this capture process is located in the general data access layer, it is not necessary to write push logic for each table in the specific business service code.

[0029] S104. After the synchronization trigger condition is met, determine whether the real-time synchronization switch is in the on state; wherein, the synchronization trigger condition is that when the change operation is in the transaction context, the transaction corresponding to the change operation is successfully committed.

[0030] In this embodiment, when data writing occurs within a transaction context, the producer change event is not published immediately, but instead enters the transaction event queue corresponding to the current thread. Only when the transaction is completed and the status is successfully committed will the events in the queue be published to the synchronization event context.

[0031] S105, when the real-time synchronization switch is on, read the latest single data to be synchronized from the source end according to the table name and primary key corresponding to the producer change event, and perform real-time single-data synchronization to the destination end.

[0032] In this embodiment, real-time synchronization is performed when the real-time synchronization switch is on, and periodic synchronization is performed when it is off. Real-time single-row synchronization in this embodiment refers to synchronization in a single direction. For business tables where the real-time synchronization switch is not on, batch synchronization is still performed according to the original synchronization cycle. For data tables where real-time synchronization is enabled, periodic synchronization can also serve as a fallback in abnormal situations, used to handle subsequent consistency repairs after network failures, node unreachability, or single-row push failures. This embodiment performs synchronization at the primary key granularity, no longer waiting for periodic tasks to scan the entire table. Before synchronization, it can determine whether a push is needed based on the change time and the previous synchronization level. This improves timeliness while avoiding high-frequency scanning of the entire table. In this embodiment, the edge-to-center direction mainly relies on edge synchronization table annotations and table primary keys; the center-to-edge direction, in addition to the table primary key, also relies on the target edge selection strategy. The target edge selection strategy can return one or more edge nodes based on the data's region, tenant, node identifier, or business relationship, so that real-time synchronization does not need to be broadcast to all edges.

[0033] This invention provides a real-time cloud-edge data synchronization method. Compared to synchronization methods that rely solely on periodic task scanning, this method allows control over whether a business table to be synchronized enters a real-time single-row synchronization path via a real-time synchronization switch in the synchronization table annotation. Because it's real-time synchronization and eliminates the need to write separate real-time push logic for each business table, it improves data synchronization efficiency. Since real-time single-row synchronization is triggered only after successful database write and transaction commit, it prevents the synchronization of data that was not successfully written or whose transactions were not committed, thus improving data synchronization accuracy. Specifically, by adding a real-time synchronization switch to the synchronization table annotation, developers only need to declare this attribute on the data model or synchronization method that requires real-time synchronization. The synchronization framework then automatically completes change capture, post-transaction event publishing, synchronization direction identification, target selection, and single-row data push, thereby maintaining periodic synchronization capabilities while providing a near-real-time synchronization path for critical data, thus improving data synchronization efficiency.

[0034] It should be further explained that, based on any of the above embodiments, in step S103, when a data change operation occurs in the business table to be synchronized, and the database write operation corresponding to the change operation is successfully executed, a producer change event is generated based on the table name and primary key of the data whose change operation occurred. This can include: intercepting the method used to perform insert or update operations on the data in the business table to be synchronized, and obtaining the change operation; determining whether the data corresponding to the change operation is data configured with a synchronization table annotation; when the data corresponding to the change operation is data configured with a synchronization table annotation, recording the change time of the data, and generating a producer change event based on the table name and primary key of the data whose change operation occurred after the database write operation is successfully executed. This embodiment can intercept insert and update operations of the general data access layer in an aspect-oriented manner to identify the operation time of the data in the business table to be synchronized. After the database write returns successfully, a producer change event is generated based on the copy of the written object (data in the business table to be synchronized), preventing subsequent business code from continuing to modify the same object and affecting the event content.

[0035] It should be further explained that, based on any of the above embodiments, after the data in the business table to be synchronized undergoes a change operation in S103, and the database write operation corresponding to the change operation is successfully executed, after generating a producer change event based on the table name and primary key corresponding to the data undergoing the change operation, the method may further include: determining whether a transaction context exists when the producer change event is generated; if a transaction context exists, caching the producer change event in the transaction event queue corresponding to the current thread, and determining that the synchronization triggering condition is met after the transaction corresponding to the transaction context is successfully committed; wherein, when the transaction corresponding to the transaction context is rolled back, the producer change event in the transaction event queue is cleaned up; when no transaction context exists, determining that the synchronization triggering condition is met after the database write operation is successfully executed. In this embodiment, if the current thread has a transaction, the synchronization event first enters the thread-level transaction event queue; the event in the transaction event queue is only published after the transaction is successfully committed; no event is published when the transaction is rolled back. For data writes without a transaction, the synchronization event can be published directly. This avoids uncommitted or rolled-back data being synchronized to the other end. This embodiment keeps the real-time synchronization trigger point consistent with the database commit result, reducing the risk of dirty data synchronization.

[0036] It should be further explained that, based on any of the above embodiments, when the real-time synchronization switch is in the on state, S105 reads the latest single data to be synchronized from the source end according to the table name and primary key corresponding to the producer change event, and performs real-time single-data synchronization to the destination end, which may include: S1051, when the synchronization direction is from the edge to the center, the table name and primary key are obtained by parsing the producer change event, and the current record on the edge side is re-queried based on the table name and primary key, and the current record on the edge side is used as the latest single data to be synchronized. S1052, compare the change time of the latest single data to be synchronized with the last push time of the table-level corresponding business table to be synchronized; S1053, when the change time is later than the last push time of the table level, push the latest single data to be synchronized to the central end; S1054: If the change time is no later than the last push time at the table level, skip this real-time push.

[0037] In this embodiment, when edge-side data changes and the corresponding synchronization table annotation is enabled for real-time synchronization, a listener is used to parse the table name and primary key based on the model metadata, and then the single-record synchronization interface from the edge to the center is called. This interface reads the latest record based on the primary key and determines whether the record's change time is later than the last push time for this table. If it is not later than the last push time, it is skipped; if it is later than the last push time, the latest single data record is pushed to the center via a remote synchronization service. The center receives the data, writes it to the corresponding table, and publishes a consumer update event. This embodiment can asynchronously call the listener using a thread pool. The business write thread is only responsible for generating events and does not directly handle the time-consuming remote synchronization operations, thereby reducing the impact of real-time synchronization on the business write response time. This embodiment only pushes the latest single data record to be synchronized to the center when the change time is later than the last push time at the table level, thereby improving the accuracy of synchronization.

[0038] Furthermore, with the introduction of real-time single-record synchronization, data for the same business primary key may undergo multiple changes within a short period, generating multiple real-time synchronization events. Since real-time synchronization events typically involve asynchronous event distribution, remote calls, network transmission, or failure retries, the order in which different events arrive at the destination may differ from the actual commit order at the source. If the destination only performs overwrite writes according to message arrival order or normal update time, older synchronization messages generated earlier but arriving later may overwrite newly written data, causing data state rollback at the cloud edge. Therefore, the real-time synchronization mechanism also needs to be coupled with the ability to determine the age of messages within the same primary key dimension.

[0039] It should be further explained that, based on any of the above embodiments, before pushing the latest single data to be synchronized to the central end when the change time is later than the last push time at the table level, S1053 may further include: in real-time single-data synchronization scenarios, when there is a risk of out-of-order arrival of multiple synchronization messages corresponding to the same primary key, and the business table to be synchronized is a business table that supports version control, constructing a synchronization message based on the latest single data to be synchronized; wherein, the synchronization message includes the primary key, change time, and synchronization version number; sending the synchronization message to the central end so that the central end performs version condition updates based on the primary key and synchronization version number; when the current record at the central end is not in a logical deletion state, if the current synchronization version number at the central end is greater than the synchronization version number carried in the synchronization message, then rejecting this write; when the current record at the central end is in a logical deletion state, allowing new lifecycle data corresponding to the same primary key to be written to the central end. This embodiment is applicable to scenarios where there is asynchronous communication, batch push, paginated synchronization, or message retries between the central node and multiple edge nodes. Edge nodes generate or modify business data during local business operations and synchronize these changes to the central node. Due to factors such as network latency, thread scheduling, batch task execution, and failure retries, multiple change messages for the same data may arrive at the central node out of order. This embodiment adds a synchronization version number field to the data to be synchronized at the edge. Each time the edge performs a business update on a version-controlled data record, the synchronization version number increments with the record update. When constructing a synchronization message, the edge includes the primary key, operation time, and synchronization version number. After receiving the message, the central node parses the synchronization version number in the message and adds a version condition when updating the central database: the update is only allowed if the version number of the current record in the central database is less than or equal to the version number carried in the message; if the current version number in the central database is greater than the message version number, it indicates that the message is an old message or an out-of-order message, and it is rejected from overwriting the central data. This embodiment avoids old messages overwriting new messages by introducing a synchronization version number into the data to be synchronized and performing a database update with version conditions at the central node.

[0040] Specifically, the synchronization messages at the edge include a `syncVersion` field, and `sync_version = sync_version + 1` is executed during database updates. This ensures that the same data receives a larger version number with each update. If the business table has field inclusion or exclusion rules, the primary key, change time, and synchronization version number are retained after field filtering to guarantee version verification by the central node. The central node parses each synchronization message to obtain the data primary key and the synchronization version number carried in the message. If the target table supports version control, it enters the version condition update process; otherwise, it can be processed according to the normal synchronization update process. In this embodiment, during the database update phase at the central node, when performing version verification, for existing central records, an update statement containing the primary key and synchronization is constructed: the primary key equals the current data primary key, and the current `sync_version` of the central node is less than or equal to the `syncVersion` carried in the message. When the conditions are met, the business field is written and the `sync_version` of the central record is set to the version number of the synchronization message. When the conditions are not met, the number of updated rows in the database is zero, indicating that the message version is outdated and cannot overwrite existing data in the center. A log can be logged and a failure or skip processing can be returned. This method merges version judgment and data update into a single database condition update, reducing the concurrency window and avoiding concurrency penetration when the application layer queries the version before updating. For business tables with logical deletion fields, the central end adds a logical deletion status judgment in addition to the version condition: when the current data in the central end is not in a logical deletion state, it still judges whether to allow the update based on `sync_version <= message version number`; when the current record in the center is already in a logical deletion state, new data with the same primary key sent by edge nodes is allowed to be written to the center, even if the synchronization version number carried by the new data is less than the historical version number of the old record in the center. The reason for this design is that some business objects reuse fixed primary keys. For example, when a computing device is registered, the edge node generates a computing resource data record using the computing device identifier as the primary key. When the device is deregistered, the edge node physically deletes the local computing resource data, while the central node sets the corresponding record to logical deletion. Subsequently, when the same computing device is re-registered, the edge node regenerates computing resource data with the same primary key. However, since this is a new record locally at the edge node, its synchronization version number may start from the initial value. If the central node (i.e., the central end) still strictly requires that the version number of the old record at the central node be less than or equal to the message version number, the re-registered data will fail to synchronize to the central node due to the lower version number. For easier understanding, please refer to [link to relevant documentation]. Figure 2 , Figure 2 This is a schematic diagram illustrating out-of-order conflict resolution based on the synchronization version number in a real-time synchronization scenario, as provided in an embodiment of the present invention.

[0041] It should be further explained that, based on any of the above embodiments, when the real-time synchronization switch is on in S105, the latest single data to be synchronized at the source end is read according to the table name and primary key corresponding to the producer change event, and real-time single-data synchronization is performed at the destination end. This may include: when the synchronization direction is from center to edge, parsing the table name and primary key according to the producer change event; re-querying the current record on the center side based on the table name and primary key, and using the queried current record on the center side as the latest single data to be synchronized; determining the target edge set corresponding to the latest single data to be synchronized according to the target edge selection strategy in the center synchronization table annotation, and performing real-time single-data synchronization at the edge nodes in the target edge set. In this embodiment, when the data on the center end changes and the corresponding synchronization table annotation enables real-time synchronization, the listener on the center end parses the table name and primary key according to the model metadata, re-queries the latest data corresponding to the primary key, and determines the set of edge nodes (edge ​​nodes) to be notified according to the target edge selection strategy in the annotation. Subsequently, the center side sends a single data change notification to each target edge node. Upon receiving the notification, the edge node, while acting as the master node, invokes the single-line synchronization interface from the center to the edge to complete the local write. In this embodiment, the edge node is first determined according to the target edge selection strategy, and then the single data is notified to the corresponding edge, thereby improving the accuracy of synchronization.

[0042] It should be further explained that, based on any of the above embodiments, after the synchronization triggering condition is met, S104 determines whether the real-time synchronization switch is in the on state, which may include: when the synchronization direction is from the edge to the center, determining whether the real-time synchronization switch in the edge synchronization table annotation is in the on state; when the synchronization direction is from the center to the edge, determining whether the real-time synchronization switch in the center synchronization table annotation is in the on state. In this embodiment, for data tables synchronized from the edge end to the center end, edge synchronization table annotations are configured on the corresponding model or synchronization entry; for data tables synchronized from the center end to the edge end, center synchronization table annotations are configured on the corresponding model or synchronization entry. In this embodiment, the edge end can use the edge listener to receive producer change events and then read the edge synchronization table annotations; the center end can use the center listener to receive producer change events and then read the center synchronization table annotations. The listener first determines whether the real-time synchronization switch in the annotation is on; if it is not on, it exits directly, and the data is still processed by the periodic synchronization link (referring to the synchronization periodic processing); if it is on, it enters the real-time single synchronization path. This embodiment improves the accuracy of synchronization by setting synchronization table annotations for different directions.

[0043] Specifically, in Example 1, edge business status is reported in real time. Edge nodes generate or update business status data locally. The model corresponding to this data is configured with an edge synchronization table annotation, and `immediately` is set to `true`. When the business code executes an insert or update, the database change capture module recognizes the object as a synchronization model and sets the operation time (i.e., change time). After a successful database write, if the current write is within a transaction, the event enters the transaction event queue; after the transaction is successfully committed, the event is published to the asynchronous event context. The edge-to-center listener receives the event, reads the annotation, confirms that the real-time synchronization switch is enabled, then parses the table name and primary key, and re-queries the latest data corresponding to the current primary key (i.e., the latest single data to be synchronized). If the operation time of this data is later than the last push time at the table level, the central synchronization service is called to write it to the center. After receiving the data, the central end completes the write to the corresponding table and can publish consumer-side update events for subsequent local processing.

[0044] Example 2: Real-time Central Configuration Distribution. When a configuration data point changes at the central end, the corresponding model configuration's central synchronization table annotation is updated, and `immediately` is set to `true`. Simultaneously, a target edge selection strategy is configured. The database write is successful, and a producer change event is published after the transaction is committed. Upon receiving the event, the central-to-edge listener reads the central synchronization table annotation, confirms that real-time synchronization is enabled, then parses the table name and primary key, and queries the latest single data entry at the central end. The listener invokes the target edge selection strategy to determine one or more edge nodes that need to receive this configuration. Subsequently, the central end sends a single data change notification to the target edge node. Upon receiving the notification, the edge node, if it is a valid processing node, initiates the single-data synchronization write process.

[0045] Example 3: Coordination of Periodic and Real-Time Synchronization. For data tables with low timeliness requirements, the `immediately` annotation remains off by default, and data is still processed in batches by periodic synchronization tasks. For data tables with high timeliness requirements, enabling `immediately` can prioritize shortening the waiting time through real-time single-row synchronization, but periodic synchronization can still be retained as a fallback synchronization method. When remote calls fail, the target edge is temporarily unreachable, or single-row synchronization is skipped by water level judgment, subsequent periodic synchronizations can continue to compensate for the data, ensuring that real-time capability and eventual consistency capability coexist.

[0046] Through the above implementation methods, the present invention achieves real-time table-based synchronization capability driven by annotation declarations, enabling the cloud-edge synchronization framework to provide real-time synchronization trigger paths for key data after submission, in a single-item and directional manner without intruding on specific business logic.

[0047] The following describes a cloud-edge data real-time synchronization device provided by an embodiment of the present invention. The cloud-edge data real-time synchronization device described below and the cloud-edge data real-time synchronization method described above can be referred to in correspondence.

[0048] Please refer to Figure 3 , Figure 3 A schematic diagram of a cloud-edge data real-time synchronization device provided in an embodiment of the present invention may include: The synchronization direction determination module 100 is used to determine the synchronization direction corresponding to the business table to be synchronized, and to determine the source end and the destination end according to the synchronization direction; wherein, when the synchronization direction is from the edge to the center, the source end is the edge end and the destination end is the center end; when the synchronization direction is from the center to the edge, the source end is the center end and the destination end is the edge end. The synchronization table annotation acquisition module 200 is used to acquire the synchronization table annotation corresponding to the business table to be synchronized; wherein, the synchronization table annotation includes the table name, synchronization period, and real-time synchronization switch; when the synchronization direction is from the edge to the center, the synchronization table annotation is an edge synchronization table annotation; when the synchronization direction is from the center to the edge, the synchronization table annotation is a center synchronization table annotation. The producer change event determination module 300 is used to generate a producer change event based on the table name and primary key of the data that has undergone the change operation when the data in the business table to be synchronized undergoes a change operation and the database write corresponding to the change operation is successfully executed. The judgment module 400 is used to determine whether the real-time synchronization switch is in the on state after the synchronization trigger condition is met; wherein, the synchronization trigger condition is that the transaction is successfully committed when the change operation is in the transaction context; The real-time synchronization module 500 is used to read the latest single data to be synchronized from the source end according to the table name and the primary key corresponding to the producer change event when the real-time synchronization switch is on, and to perform real-time single-data synchronization to the destination end.

[0049] Furthermore, based on any of the above embodiments, the producer change event determination module 300 may include: A change operation monitoring unit is used to intercept methods used to perform insert or update operations on data in the business table to be synchronized, and to obtain the change operation. A data synchronization judgment unit is used to determine whether the data corresponding to the change operation is data configured with the synchronization table annotation; The event generation unit is used to record the change time corresponding to the data when the data corresponding to the change operation is data configured with the synchronization table annotation, and generate the producer change event based on the table name and the primary key corresponding to the data where the change operation occurred after the database write is successfully executed.

[0050] Furthermore, based on any of the above embodiments, the cloud-edge data real-time synchronization device may further include: The transaction judgment module is used to determine whether a transaction context exists when the producer change event is generated; The event caching module is used to cache the producer change event to the transaction event queue corresponding to the current thread when the transaction context exists; The event context module is used to receive the producer change event and perform asynchronous listening processing after the transaction is successfully committed; The no-transaction triggering module is used to determine that the synchronization triggering condition is met after the database write is successfully executed when the transaction context does not exist.

[0051] Furthermore, based on any of the above embodiments, the real-time synchronization module 500 may include: The edge-to-center synchronization unit is used to parse the table name and the primary key according to the producer change event when the synchronization direction is edge-to-center, and re-query the current record on the edge side based on the table name and the primary key, and take the queried current record on the edge side as the latest single data to be synchronized. The comparison unit is used to compare the change time of the latest single data to be synchronized with the last push time of the table-level data corresponding to the business table to be synchronized; The push unit is used to push the latest single data to be synchronized to the central end when the change time is later than the last push time of the table level; The skip push unit is used to skip the current real-time push when the change time is not later than the last push time of the table level.

[0052] Furthermore, based on any of the above embodiments, the real-time synchronization module 500 may include: A synchronization message construction unit is used to construct a synchronization message based on the latest single data to be synchronized in a real-time single-data synchronization scenario when there is a risk of out-of-order arrival of multiple synchronization messages corresponding to the same primary key, and the business table to be synchronized is a business table that supports version control; wherein, the synchronization message includes the primary key, the change time, and the synchronization version number; The system sends the synchronization message to the central terminal unit, enabling the central terminal to perform a version condition update based on the primary key and the synchronization version number. If the current synchronization version number at the central terminal is not in a logical deletion state, and this write operation is rejected if it is greater than the synchronization version number carried in the synchronization message, then the write operation is rejected. If the current record at the central terminal is in a logical deletion state, new lifecycle data corresponding to the same primary key is allowed to be written to the central terminal. Furthermore, based on any of the above embodiments, the real-time synchronization module 500 may include: The parsing unit is used to parse the table name and the primary key based on the producer change event when the synchronization direction is from the center to the edge. The query unit is used to re-query the current record on the central side based on the table name and the primary key, and use the queried current record on the central side as the latest single data to be synchronized. Based on the target edge synchronization unit, it is used to determine the target edge set corresponding to the latest single data to be synchronized according to the target edge selection strategy in the central synchronization table annotation, and to perform real-time single-data synchronization to the edge in the target edge set.

[0053] Furthermore, based on any of the above embodiments, the determination module 400 may include: The edge switch determination unit is used to determine whether the real-time synchronization switch in the edge synchronization table annotation is in the on state when the synchronization direction is from the edge to the center. The center switch determination unit is used to determine whether the real-time synchronization switch in the center synchronization table annotation is in the on state when the synchronization direction is from the center to the edge.

[0054] It should be noted that the order of the modules and units in the aforementioned cloud-edge data real-time synchronization device can be changed without affecting the logic.

[0055] This invention provides a cloud-edge data real-time synchronization device, which may include: a synchronization direction determination module 100, used to determine the synchronization direction corresponding to the business table to be synchronized, and to determine the source end and the destination end according to the synchronization direction; wherein, when the synchronization direction is from the edge to the center, the source end is the edge end and the destination end is the center end; when the synchronization direction is from the center to the edge, the source end is the center end and the destination end is the edge end; and a synchronization table annotation acquisition module 200, used to acquire the synchronization table annotation corresponding to the business table to be synchronized; wherein, the synchronization table annotation includes the table name, synchronization period, and real-time synchronization switch; when the synchronization direction is from the edge to the center, the synchronization table annotation is an edge synchronization table annotation; when the synchronization direction is from the center to the edge... In this context, the synchronization table annotation is the central synchronization table annotation; the producer change event determination module 300 is used to generate a producer change event based on the table name and primary key corresponding to the data in the business table to be synchronized when a change operation occurs and the database write corresponding to the change operation is successfully executed; the judgment module 400 is used to determine whether the real-time synchronization switch is in the on state after the synchronization trigger condition is met; wherein, the synchronization trigger condition is that the transaction is successfully committed when the change operation is in the transaction context; the real-time synchronization module 500 is used to read the latest single data to be synchronized at the source end according to the table name and the primary key corresponding to the producer change event when the real-time synchronization switch is in the on state, and perform real-time single-data synchronization to the destination end. Compared to synchronization methods that rely solely on periodic task scans, the real-time synchronization switch in the synchronization table annotation can control whether the business table to be synchronized enters the real-time single-row synchronization path. Since it is real-time synchronization and there is no need to write real-time push logic separately for each business table, the efficiency of data synchronization is improved. Because real-time single-row synchronization is only triggered after the database write is successful and the transaction is successfully committed, it prevents the synchronization of data that has not been successfully written or whose transactions have not been committed, thus improving the accuracy of data synchronization.

[0056] The following describes a cloud-edge data real-time synchronization device provided by an embodiment of the present invention. The cloud-edge data real-time synchronization device described below and the cloud-edge data real-time synchronization method described above can be referred to in correspondence.

[0057] Please refer to Figure 4 , Figure 4 A schematic diagram of a cloud-edge data real-time synchronization device provided in an embodiment of the present invention may include: Memory 10 is used to store computer programs; Processor 20 is used to execute computer programs to implement the above-described cloud-edge data real-time synchronization method.

[0058] The memory 10, processor 20, and communication interface 30 all communicate with each other through the communication bus 40.

[0059] In this embodiment of the invention, the memory 10 is used to store one or more programs. The programs may include program code, which includes computer operation instructions. In this embodiment of the invention, the memory 10 may store programs for implementing the following functions: Determine the synchronization direction corresponding to the business table to be synchronized, and determine the source and destination ends based on the synchronization direction; where the synchronization direction is from the edge to the center, the source end is the edge end and the destination end is the center end; when the synchronization direction is from the center to the edge, the source end is the center end and the destination end is the edge end. Retrieve the synchronization table annotations corresponding to the business tables to be synchronized; the synchronization table annotations include the table name, synchronization period, and real-time synchronization switch; when the synchronization direction is from the edge to the center, the synchronization table annotation is the edge synchronization table annotation; when the synchronization direction is from the center to the edge, the synchronization table annotation is the center synchronization table annotation. When a change operation is performed on the data in the business table to be synchronized, and the database write operation corresponding to the change operation is successfully executed, a producer change event is generated based on the table name and primary key of the data that has undergone the change operation. After the synchronization trigger condition is met, it is determined whether the real-time synchronization switch is in the on state; wherein, the synchronization trigger condition is that when the change operation is in a transaction context, the transaction corresponding to the change operation is successfully committed; When the real-time synchronization switch is on, the latest single data to be synchronized on the source end is read according to the table name and primary key corresponding to the producer change event, and real-time single-data synchronization is performed on the destination end.

[0060] In one possible implementation, the memory 10 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and applications required for at least one function; and the data storage area may store data created during use.

[0061] Furthermore, memory 10 may include read-only memory and random access memory, providing instructions and data to the processor. A portion of the memory may also include NVRAM. The memory stores operating systems and operating instructions, executable modules, or data structures, or subsets thereof, or extended sets thereof, wherein the operating instructions may include various operating instructions for implementing various operations. The operating system may include various system programs for implementing various basic tasks and handling hardware-based tasks.

[0062] Processor 20 can be a central processing unit (CPU), an application-specific integrated circuit, a digital signal processor, a field-programmable gate array, or other programmable logic device. Processor 20 can be a microprocessor or any conventional processor. Processor 20 can call programs stored in memory 10.

[0063] The communication interface 30 can be an interface for the communication module, used to connect with other devices or systems.

[0064] Of course, it should be noted that, Figure 4 The structure shown does not constitute a limitation on the cloud-edge data real-time synchronization device in the embodiments of the present invention. In practical applications, the cloud-edge data real-time synchronization device may include devices such as... Figure 4 More or fewer components as shown, or combinations of certain components.

[0065] The following describes the computer-readable storage medium provided in the embodiments of the present invention. The computer-readable storage medium described below can be referred to in correspondence with the cloud-edge data real-time synchronization method described above.

[0066] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the above-described cloud-edge data real-time synchronization method.

[0067] The computer-readable storage medium may include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0068] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0069] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0070] Finally, it should be noted that in this document, relationships such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0071] The above provides a detailed description of a cloud-edge data real-time synchronization method, apparatus, device, and readable storage medium provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A method for real-time data synchronization between cloud and edge, characterized in that, include: Determine the synchronization direction corresponding to the business table to be synchronized, and determine the source end and destination end based on the synchronization direction; wherein, when the synchronization direction is from the edge to the center, the source end is the edge end and the destination end is the center end; when the synchronization direction is from the center to the edge, the source end is the center end and the destination end is the edge end. Obtain the synchronization table annotation corresponding to the business table to be synchronized; wherein, the synchronization table annotation includes table name, synchronization period and real-time synchronization switch; when the synchronization direction is from edge to center, the synchronization table annotation is an edge synchronization table annotation; when the synchronization direction is from center to edge, the synchronization table annotation is a center synchronization table annotation; When a change operation is performed on the data in the business table to be synchronized, and the database write operation corresponding to the change operation is successfully executed, a producer change event is generated based on the table name and primary key of the data that has undergone the change operation. After the synchronization triggering condition is met, it is determined whether the real-time synchronization switch is in the on state; wherein, the synchronization triggering condition is that when the change operation is in a transaction context, the transaction corresponding to the change operation is successfully committed; When the real-time synchronization switch is on, the latest single data to be synchronized at the source end is read according to the table name and the primary key corresponding to the producer change event, and real-time single-data synchronization is performed to the destination end.

2. The cloud-edge data real-time synchronization method according to claim 1, characterized in that, When a data change operation occurs in the business table to be synchronized, and the database write operation corresponding to the change operation is successfully executed, a producer change event is generated based on the table name and primary key corresponding to the data that underwent the change operation, including: Intercept the method used to perform insert or update operations on the data in the business table to be synchronized, and obtain the change operation; Determine whether the data corresponding to the change operation is data configured with the synchronization table annotation; When the data corresponding to the change operation is data configured with the synchronization table annotation, the change time corresponding to the data is recorded, and after the database write is successfully executed, the producer change event is generated based on the table name and the primary key corresponding to the data in which the change operation occurred.

3. The cloud-edge data real-time synchronization method according to claim 1, characterized in that, After a data change operation occurs in the business table to be synchronized, and the database write operation corresponding to the change operation is successfully executed, and a producer change event is generated based on the table name and primary key corresponding to the data that underwent the change operation, the process further includes: Determine whether a transaction context exists when the producer change event is generated; When the transaction context exists, the producer change event is cached in the transaction event queue corresponding to the current thread, and the synchronization triggering condition is determined to be met after the transaction corresponding to the transaction context is successfully committed; wherein, when the transaction corresponding to the transaction context is rolled back, the producer change event in the transaction event queue is cleaned up. When the transaction context does not exist, the synchronization triggering condition is determined to be met after the database write is successfully executed.

4. The cloud-edge data real-time synchronization method according to any one of claims 1 to 3, characterized in that, When the real-time synchronization switch is on, based on the table name and primary key corresponding to the producer change event, the latest single data to be synchronized at the source end is read, and real-time single-data synchronization is performed at the destination end, including: When the synchronization direction is from the edge to the center, the table name and the primary key are obtained by parsing the producer change event, and the current record on the edge side is re-queried based on the table name and the primary key. The current record on the edge side is then used as the latest single data to be synchronized. Compare the change time of the latest single data entry to be synchronized with the last push time of the table-level data corresponding to the business table to be synchronized; When the change time is later than the last push time of the table level, the latest single data to be synchronized will be pushed to the central terminal. If the change time is not later than the last push time of the table level, skip this real-time push.

5. The cloud-edge data real-time synchronization method according to claim 4, characterized in that, Before pushing the latest single data entry to be synchronized to the central terminal when the change time is later than the last push time of the table level, the method further includes: In a real-time single-record synchronization scenario, when multiple synchronization messages corresponding to the same primary key are at risk of arriving out of order, and the business table to be synchronized is a business table that supports version control, a synchronization message is constructed based on the latest single data to be synchronized; wherein, the synchronization message includes the primary key, the change time, and the synchronization version number; The synchronization message is sent to the central terminal so that the central terminal performs a version condition update based on the primary key and the synchronization version number. When the current record at the central terminal is not in a logical deletion state, if the current synchronization version number at the central terminal is greater than the synchronization version number carried in the synchronization message, the write operation is rejected. When the current record at the central terminal is in a logical deletion state, new lifecycle data corresponding to the same primary key is allowed to be written to the central terminal.

6. The cloud-edge data real-time synchronization method according to claim 1, characterized in that, When the real-time synchronization switch is on, based on the table name and primary key corresponding to the producer change event, the latest single data to be synchronized at the source end is read, and real-time single-data synchronization is performed at the destination end, including: When the synchronization direction is from the center to the edge, the table name and the primary key are obtained by parsing the producer change event. Based on the table name and the primary key, query the current record on the central side again, and use the queried current record on the central side as the latest single data to be synchronized. Based on the target edge selection strategy in the central synchronization table annotation, the target edge set corresponding to the latest single data to be synchronized is determined, and real-time single-data synchronization is performed on the edge ends in the target edge set.

7. The cloud-edge data real-time synchronization method according to claim 1, characterized in that, After the synchronization triggering condition is met, it is determined whether the real-time synchronization switch is in the on state, including: When the synchronization direction is from the edge to the center, determine whether the real-time synchronization switch in the edge synchronization table annotation is in the on state; When the synchronization direction is from the center to the edge, determine whether the real-time synchronization switch in the center synchronization table annotation is in the on state.

8. A cloud-edge data real-time synchronization device, characterized in that, include: The synchronization direction determination module is used to determine the synchronization direction corresponding to the business table to be synchronized, and to determine the source end and the destination end according to the synchronization direction; wherein, when the synchronization direction is from the edge to the center, the source end is the edge end and the destination end is the center end; when the synchronization direction is from the center to the edge, the source end is the center end and the destination end is the edge end. The synchronization table annotation acquisition module is used to acquire the synchronization table annotation corresponding to the business table to be synchronized; wherein, the synchronization table annotation includes the table name, synchronization period, and real-time synchronization switch; when the synchronization direction is from the edge to the center, the synchronization table annotation is an edge synchronization table annotation; when the synchronization direction is from the center to the edge, the synchronization table annotation is a center synchronization table annotation; The producer change event determination module is used to generate a producer change event based on the table name and primary key of the data that has undergone the change operation when the data in the business table to be synchronized undergoes a change operation and the database write corresponding to the change operation is successfully executed. The judgment module is used to determine whether the real-time synchronization switch is in the on state after the synchronization trigger condition is met; wherein, the synchronization trigger condition is that the transaction is successfully committed when the change operation is in the transaction context; The real-time synchronization module is used to read the latest single data to be synchronized from the source end according to the table name and the primary key corresponding to the producer change event when the real-time synchronization switch is on, and to perform real-time single-data synchronization to the destination end.

9. A cloud-edge data real-time synchronization device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the cloud-edge data real-time synchronization method as described in any one of claims 1 to 7.

10. A readable storage medium, characterized in that, The readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the cloud-edge data real-time synchronization method as described in any one of claims 1 to 7.