A real-time parsing and synchronizing method and system for database log data
By calculating batch hashes and generating evidence records in real time during database log data synchronization, asynchronously persisting the data, and combining Merkle Mountain Range hash trees and trust anchor mechanisms, the verifiability problem of the trust layer in existing technologies is solved. This enables batch-by-batch traceable evidence generation and efficient integrity verification, ensuring the reliability and trustworthiness of data synchronization.
Patent Information
- Application Number
- CN202611184919.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-06
- Publication Date
- 2026-11-27
AI Technical Summary
Existing real-time database synchronization technologies lack verifiability at the trust layer, cannot independently verify the integrity of data content, cannot quickly locate historical data tampering or loss points, and cannot generate credible evidence without affecting real-time synchronization performance.
By calculating the batch content hash and generating evidence records in real time during the database log data synchronization process, asynchronously persisting them to the shared log, and performing hash comparison on the independent verification end, combined with the Merkle Mountain Range hash tree and trust anchor mechanism, it is possible to achieve batch-by-batch traceable evidence generation and historical data integrity verification.
Without affecting real-time synchronization performance, batch-by-batch traceable cryptographic evidence is automatically generated for each data synchronization, building a cross-institutional trusted evidence system to achieve efficient integrity verification and accurate tampering location of large-scale historical data, ensuring that evidence records are not lost during shared log failures.
Smart Images

Figure CN123178505A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of database update technology, specifically to a method and system for real-time parsing and synchronization of database log data. Background Technology
[0002] With the deepening of digital transformation in finance, government affairs, healthcare, and other fields, cross-institutional data sharing and regulatory compliance reporting have placed higher demands on the reliability of real-time database synchronization. Currently, real-time database synchronization technology has formed a mature industrial system. Change Data Capture (CDC) technology, represented by open-source tools such as Debezium, Canal, and Maxwell, combined with high-throughput message queues such as Kafka and Pulsar, as well as Flink CDC's checkpoint mechanism and Kafka's transaction mechanism, can reliably solve the problems of data loss prevention, non-duplication, and breakpoint resumption in common scenarios. Cloud vendors' DTS and DMS products further enhance this by adding engineering capabilities such as operation and maintenance management, task degradation, and monitoring and alerting, supporting the data synchronization needs of the vast majority of enterprises. Meanwhile, cryptographic auditing technology is also constantly developing. Incremental hash tree structures such as Merkle Mountain Range have been standardized by the IETF, and external trust anchor mechanisms such as blockchain anchoring and trusted timestamp services are becoming increasingly mature, providing a technical foundation for building an immutable data evidence chain.
[0003] However, existing technologies have clear limitations in their trust layer capabilities. First, the offset mechanism can only pinpoint the consumption progress, not prove the data content. Even if the offset is correct, tampering with the message content during transmission or storage cannot be detected, and the offset belongs to the internal system state, invisible to the auditor, and lacks cross-institutional verifiability. Second, the checkpoint mechanism guarantees the fault-tolerant semantic correctness within the system, not the cryptographic guarantee of content integrity. The auditor cannot independently verify the correctness of the checkpoint because the checkpoint data is stored internally. Third, existing CRC32 or MD5 hash checks are mostly instantaneous error detection at the transport layer, discarded after verification, and not persisted as long-term audit evidence, nor can they handle scenarios where the sender and receiver collude to tamper with the data. Fourth, some solutions attempt to write the hash of synchronized data into the blockchain to obtain immutability, but writing to the blockchain requires network consensus waiting, directly blocking real-time synchronization, and the storage cost and throughput are not suitable for high-frequency synchronization scenarios.
[0004] In summary, existing technologies are mature in the survival and stability layers, but there are design gaps in the trust layer: there is no mechanism that can generate independent, persistent, and third-party verifiable cryptographic evidence for each synchronization operation without significantly interfering with the main link; there is no mechanism that allows the receiver to independently verify data integrity without relying on the sender's system; and there is no mechanism that can quickly locate tampering or loss points in historical data without requiring full reconciliation.
[0005] Therefore, there is an urgent need for a database log data synchronization scheme that is decoupled from the existing CDC synchronization mechanism, has low interference, and is traceable in batches to generate credible evidence. This scheme should provide independently verifiable cryptographic evidence support for cross-agency data sharing and regulatory compliance reporting without affecting real-time synchronization performance. Summary of the Invention
[0006] To address the aforementioned problems in the existing technology, this invention provides a method and system for real-time parsing and synchronization of database log data.
[0007] According to a first aspect of the present invention, a method for real-time parsing and synchronization of database log data is proposed, comprising the following steps: Change capture step S1: Parse the source database logs using the change capture component to obtain a data batch consisting of multiple data change records; Hash calculation step S2: Based on the data batches already loaded in memory, calculate the batch content hash corresponding to the data batch; Evidence construction step S3: Generate evidence records. The evidence records shall include at least a batch unique identifier, source library location information, message queue location information, and batch content hash. Asynchronous persistence step S4: Write evidence records to the shared log in a non-blocking asynchronous manner; the shared log is physically isolated from the main link message queue of the data transmission batch, and the shared log adopts an append-only writing mode; Independent verification step S5: Independent of the sender, the audit end reads the evidence record in the shared log, reads the corresponding data batch from the target storage, recalculates the hash according to the serialization rules consistent with the hash calculation step, and compares it with the batch content hash in the evidence record to obtain the verification result.
[0008] According to some embodiments, in the method of the first aspect of the present invention, step S4 includes: S41: Detect the service communication status of the shared log; S42: When the shared log service is unavailable, cache the evidence records to be written to the local cache queue of the change capture component; S43: After the shared log service communication is restored, the evidence records in the local cache queue will be replayed in batches according to time order and written to the shared log.
[0009] According to some embodiments, in the method of the first aspect of the present invention, a local cache queue is set with a capacity threshold; when the local cache queue reaches the capacity threshold, the evidence records in the queue are persisted to the local disk.
[0010] According to some embodiments, the method of the first aspect of the present invention further includes a recipient collaborative signature step: The recipient recalculates the verification hash of the data batch written to the target storage. When the verification hash matches the batch content hash, the recipient uses its own key to generate a batch signature and appends the batch signature to the corresponding evidence record.
[0011] According to some embodiments, in the method of the first aspect of the present invention, trusted timestamp signing and / or blockchain hash anchoring operations are selectively enabled according to preset trust anchor configuration parameters.
[0012] According to some embodiments, in the method of the first aspect of the present invention, the blockchain hash anchoring operation includes: periodically extracting the batch content hashes corresponding to multiple evidence records within a preset time window, aggregating them to generate an aggregate root hash, and submitting the aggregate root hash to the blockchain for evidence storage.
[0013] According to some embodiments, the method of the first aspect of the present invention further includes an evidence aggregation and verification step, specifically including the following sub-steps: The audit plane periodically reads multiple evidence records from the shared log within a time window divided by a preset time granularity, extracts the batch content hash from the multiple evidence records, and incrementally constructs a Merkle Mountain Range hash tree; Write the root hash of the interval corresponding to the Merkle Mountain Range hash tree to the shared log; When performing large-scale historical data verification, the first step is to compare the interval root hash to determine the overall integrity of the window. If the interval root hash comparison is inconsistent, the data batch with abnormality is located by searching layer by layer along the Merkle Mountain Range hash tree path.
[0014] According to some embodiments, in the method of the first aspect of the present invention, when constructing the Merkle Mountain Range hash tree, the leaf node type and the intermediate node type are distinguished; the leaf nodes store the batch content hash, and the intermediate nodes store the child node combination hash; when constructing the integrity proof, the single batch existence proof and the continuous interval integrity verification logic are distinguished.
[0015] According to some embodiments, the method of the first aspect of the present invention further includes an adaptive traffic scheduling step: The scheduling component, independent of the change capture component, reads batch processing timing indicators from multiple evidence records in the shared log. Combined with source library load indicators, network transmission indicators, and target storage write load indicators collected by independent monitoring probes, the component dynamically adjusts the operating parameters of the change capture component through a feedback control mechanism. When the monitored indicators exceed the preset safety threshold, an emergency braking is triggered, locking the scheduling parameters to the preset safety range.
[0016] According to a second aspect of the present invention, a real-time parsing and synchronization system for database log data is provided, comprising: The change capture module is used to parse the source database logs to obtain a data batch consisting of multiple data change records; The hash calculation module is used to calculate the batch content hash corresponding to the data batch based on the data batches loaded in memory; The evidence construction module is used to generate evidence records, which include at least a batch unique identifier, source library location information, message queue location information, and batch content hash. The asynchronous persistence module is used to write evidence records to the shared log in a non-blocking asynchronous manner; the shared log is physically isolated from the main link message queue of the data transmission batch, and the shared log adopts an append-only writing mode; The independent verification module is used to read evidence records in the shared log, read the corresponding data batches from the target storage, recalculate the hash according to the serialization rules consistent with the hash calculation steps, and compare it with the batch content hash in the evidence record to obtain the verification result.
[0017] Compared with the prior art, the present invention has the following beneficial effects: 1. Without affecting real-time synchronization performance, automatically generate batch-by-batch traceable cryptographic evidence for each data synchronization. This is the most direct technical effect of the core solution of this invention. By combining in-memory hash calculation with bypass asynchronous persistence, evidence generation is embedded in the CDC parsing process without adding extra I / O. The shared log is physically isolated from the main link message queue to avoid resource contention. This ensures that failure of the evidence chain does not affect data synchronization, and failure of data synchronization does not lead to evidence loss, thus resolving the contradiction between compliant evidence and real-time performance.
[0018] 2. A layered, selectable, and progressively enhanced cross-institutional trusted evidence system has been constructed. An independent trust anchor is introduced through recipient collaborative signatures, third-party time verification is provided through TSA timestamps, and public immutability is obtained through blockchain anchoring. This allows for the selection of appropriate trust levels for different scenarios such as internal institutional synchronization, cross-institutional collaboration, high-compliance supervision, and cross-border judicial evidence presentation, avoiding the security risks of overly engineered approaches or insufficient trust.
[0019] 3. Achieved efficient integrity verification and accurate tamper location for large-scale historical data. By aggregating massive batch hashes into a rapidly comparable interval root hash through Merkle Mountain Range, routine verification only requires comparing the root hash to confirm the integrity of the window. In case of anomalies, drill down the tree path layer by layer to locate the specific batch, compressing the annual audit from hours or even days of full reconciliation to minutes, while retaining the finesse of batch-by-batch traceability.
[0020] 4. Adaptive synchronization stability assurance under traffic fluctuation scenarios. By obtaining batch processing timing indicators from shared logs and combining multi-dimensional load signals from the source database, network, and target database, the batching window and the number of concurrent threads are dynamically adjusted. This allows for rapid digestion of backlogs during sudden traffic surges, reduction of write pressure when the target database is bottlenecked, activation of compression or link switching during network jitter, and prevention of system crashes through threshold-based emergency braking.
[0021] 5. Achieved zero loss of evidence records during shared log failures. Through memory buffering of the local cache queue and disk persistence triggered by capacity thresholds, it automatically degrades to local storage when the shared log service becomes unavailable. After the service recovers, it replays and rewrites the data in batches according to time sequence, ensuring that the continuity and integrity of the evidence chain are not interrupted due to external dependency failures. Attached Figure Description
[0022] Figure 1 This is a flowchart illustrating an embodiment 1000 of a method for real-time parsing and synchronization of database log data according to the present invention. Figure 2 for Figure 1 A flowchart illustrating step S4 in Example 1000; Figure 3 This is a flowchart illustrating an embodiment 2000 of the real-time parsing and synchronization method for database log data according to the present invention. Figure 4 This is a flowchart illustrating an embodiment 3000 of a method for real-time parsing and synchronization of database log data according to the present invention. Figure 5 This is a flowchart illustrating an embodiment 4000 of a method for real-time parsing and synchronization of database log data according to the present invention. Figure 6 This is a schematic diagram of an embodiment 5000 of the real-time parsing and synchronization system for database log data according to the present invention. Detailed Implementation
[0023] 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.
[0024] Figure 1 This is a flowchart illustrating an embodiment 1000 of the real-time parsing and synchronization method for database log data according to the present invention. Figure 1 As shown, Example 1000 includes steps S1-S5.
[0025] The change capture step S1 involves parsing the source database logs using the change capture component to obtain a data batch consisting of multiple data change records. The core inventive concept of step S1 lies in utilizing the I / O operations already completed by the change capture component, i.e., the CDC tool, when parsing the database logs, to keep the data batch resident in memory, creating conditions for subsequent calculations and avoiding additional data reading overhead.
[0026] The change capture component establishes a replication connection to the master database as a slave, receiving write-ahead log event streams in real time. The replication connection uses the standard Binlog Dump protocol. The change capture component sends a handshake request containing the starting Binlog filename and offset, and the master database then continuously pushes all Binlog events after that offset. Event types include: rotation events describing log file switching, metadata events describing Binlog format, table mapping events describing table structure mapping, and row change events describing data insertion, updates, and deletions.
[0027] The change capture component performs batch processing on a continuous stream of events. The batching mechanism employs a dual-threshold control strategy: setting a time threshold and a record count threshold. A batch commit is triggered when the elapsed time since the last batch reaches the time threshold, or when the current cumulative number of change records reaches the record count threshold. The design principle of this dual-threshold mechanism is that in low-frequency change scenarios, the time threshold ensures that excessive delays will not occur due to waiting for the record count to reach the threshold; in high-frequency change scenarios, the record count threshold ensures that the memory usage and processing time of a single batch are within a controllable range. The specific values of the two thresholds are configured according to the change frequency and latency requirements of the business scenario.
[0028] Data batches are organized in memory as an ordered list, where each element is a change record object. Each change record object includes the operation type, table name, primary key value, field value mapping before the change, field value mapping after the change, and change timestamp. The metadata for each data batch includes a unique batch identifier, the starting Binlog filename and offset, the ending Binlog filename and offset, the number of records in the batch, and the batch generation timestamp.
[0029] Each batch's unique identifier is generated using the UUID format to ensure global uniqueness. The source database location information accurately records the start and end positions of this data batch in the source database Binlog, providing a basis for subsequent troubleshooting and data backtracking.
[0030] Hash calculation step S2 calculates the batch content hash corresponding to the data batch based on the data batches already loaded in memory. The core inventive concept of step S2 is to take advantage of the fact that the data is already in memory in the CDC parsing process, calculate the hash before putting the data into the sending queue, embed evidence generation into the existing processing flow rather than as an additional independent step, thereby achieving almost zero interference with the main link.
[0031] The design principle of the serialization rules is to eliminate all format differences unrelated to the data content, ensuring that the sender and receiver obtain completely consistent serialized byte streams for the same batch of data at any time when recalculated using any programming language. To this end, serialization uses a binary encoding format and enforces a specific encoding order for fields: operation type is encoded first, followed by table name, then primary key value, then the mapping of field values before and after the change in ascending alphabetical order by field name, and finally the change timestamp. The key-value pairs in the field value mapping are arranged in ascending alphabetical order by the key to ensure that the field order does not lead to differences in the serialization results.
[0032] The hash algorithm employs a cryptographically secure one-way hash function. A one-way hash function possesses the following key properties: it produces a fixed-length output for an input of arbitrary length; small changes to the input result in significant changes to the output; and it is computationally infeasible to deduce the input from the output. These properties make the hash value a unique fingerprint of the data content; any tampering with the batch of content will result in a completely different hash value, thus being detected by independent verification steps.
[0033] The hash calculation is performed synchronously within the main thread of the change capture component. Since the data batch has already been loaded into memory, the hash calculation involves only CPU computation and does not involve disk I / O or network communication. After the hash calculation is completed, the resulting batch content hash serves as the core field of the evidence record and proceeds to the next step.
[0034] In evidence construction step S3, an evidence record is generated. The evidence record includes at least a batch unique identifier, source library location information, message queue location information, and batch content hash. The core inventive concept of step S3 is to bind the batch content hash with the batch's location and time information to construct a self-contained evidence record, which can be independently verified without relying on any external system state.
[0035] The evidence record contains the following core fields: a batch unique identifier for globally locating an evidence record; source database location information for locating the original data of the batch in the source database Binlog; message queue location information for locating the sending position of the batch in the transport layer message queue; batch content hash for verifying the integrity of the data content; and batch generation timestamp for establishing the timeline sequence.
[0036] The design principle of message queue position information is as follows: After the CDC tool completes batch parsing and hash calculation, it places the data batch into the message queue's send buffer. At this time, the partition number and offset allocated by the message queue are not yet determined, depending on the sending timing and partitioning strategy. Therefore, the message queue position information adopts a pre-placement mechanism: this field is reserved in the evidence record, and the actual partition number and offset are filled back by the send callback function after the data batch has been actually sent. This mechanism ensures that the position information in the evidence record is consistent with the actual sending position, providing an accurate basis for subsequent data backtracking and fault location.
[0037] Evidence records are serialized using a binary encoding format. Compared to text format, binary encoding offers advantages such as compact size, efficient parsing, and cross-language consistency. The serialized result of the evidence record is much smaller than the data batch itself, making the network and storage overhead of asynchronous writing to the shared log negligible.
[0038] In asynchronous persistence step S4, evidence records are written to the shared log in a non-blocking asynchronous manner. The shared log is physically isolated from the main link message queue of the data transmission batch, and the shared log adopts an append-only writing mode. The core inventive concept of step S4 lies in decoupling the evidence chain from the main link through two designs: asynchronous non-blocking writing and physical isolation. Asynchronous non-blocking ensures that evidence writing does not wait for confirmation or block subsequent processing; physical isolation ensures that evidence storage and data transmission do not share resources and do not interfere with each other.
[0039] The asynchronous write mechanism employs a batch asynchronous sending mode using a message queue producer. Internally, the producer maintains a sending buffer. Evidence records first enter the buffer. When the buffer reaches its preset capacity or the preset sending delay expires, the producer batches multiple evidence records in the buffer and sends them to the shared log server at once. The sending operation is executed in a background thread. The main thread returns immediately after placing the evidence records into the buffer and continues processing the next batch of data. Callback processing of the sending results is also executed in a background thread; the main thread is not involved at all.
[0040] The shared log employs an append-only write mode. The core principle of this mode is that once evidence is written, it becomes part of history; any subsequent modification or deletion will disrupt the integrity and temporal continuity of the evidence chain. The append-only write mode is implemented through operating system-level file attribute settings or storage device hardware characteristics, prohibiting overwrite or deletion operations on existing log files. When storage space needs to be freed up, an archiving strategy is used instead of a deletion strategy: historical evidence records are aggregated into higher-level hash digests, retaining the digest information, while the original records are transferred to low-cost cold storage.
[0041] Physical isolation between the shared log and the main message queue is achieved through the following methods: deployment on independent compute nodes or independent storage clusters; use of independent network bandwidth and disk I / O resources; and configuration of independent resource quotas and fault domains. The design principle of physical isolation is that the main link carries actual business data, with high throughput, short data lifecycle, and sensitivity to latency; the shared log carries evidence records, with low throughput, long data lifecycle, and insensitivity to latency. Their resource requirements are drastically different, and mixed deployment can lead to resource contention and mutual interference.
[0042] A fallback mechanism for shared log service unavailability: The change capture component maintains a local cache queue. When shared log service unavailability is detected, evidence records are transferred from the asynchronous sending process to the local cache queue. The local cache queue has a capacity threshold; when the number of records in the queue reaches the threshold, disk persistence is triggered: all evidence records in the queue are written to a local disk file, releasing memory space. After disk persistence is complete, the memory queue is cleared, and new evidence records are received again. The design principle of this fallback mechanism is that the memory queue provides a low-latency temporary buffer, and the disk file provides large-capacity reliable storage; the two work together to ensure that evidence records are not lost during shared log service failures.
[0043] The shared log service recovery detection employs a timed probe mechanism. The change capture component periodically sends probe messages to the shared log. A successful probe indicates service recovery and initiates a batch replay process: evidence records are read from the local cache queue and disk backup files in chronological order, and the asynchronous sending operation is re-executed. After replay is complete, the replayed disk backup files are deleted. The chronological replay design ensures that the storage order of evidence records in the shared log matches the batch generation order, maintaining the temporal continuity and traceability of the evidence chain.
[0044] Optionally, step S4 includes: detecting the service communication status of the shared log; when the shared log service is unavailable, caching the evidence records to be written to the local cache queue of the change capture component; and writing the evidence records in the local cache queue to the shared log in batches in chronological order after the shared log service communication is restored.
[0045] In the independent verification step S5, the auditing end, independent of the sender, reads the evidence record from the shared log, retrieves the corresponding data batch from the target storage, recalculates the hash according to the serialization rules consistent with the hash calculation step, and compares it with the batch content hash in the evidence record to obtain the verification result. The core inventive concept of step S5 is to transfer the verification subject from the sender to the auditing end, independent of the sender, so that the verification process does not depend on the sender's system state, thereby achieving independent third-party verifiability.
[0046] The auditing module is deployed on the receiving side, completely isolated physically and logically from the sender's change capture component and shared log service. The auditing module comprises three functional sub-modules: a shared log reader responsible for retrieving evidence records from the shared logs; a target storage connector responsible for reading the actual data from the recipient's target storage; and a hash comparison engine responsible for recalculating the hash according to the same serialization rules and hash algorithm as the sender, and comparing it with the batch content hash in the evidence records.
[0047] The shared log reader uses a consumer model to subscribe to shared logs. Consumers sequentially consume evidence records starting from a specified position, which can be located based on a timestamp or a batch unique identifier. The principle behind sequential consumption is to ensure that evidence records are processed chronologically, facilitating the construction of a continuous audit trail.
[0048] The target storage connector locates the corresponding partition and offset of the target message queue based on the message queue location information in the evidence record, and retrieves the data content for that batch. After retrieval, it re-serializes the data according to the same serialization rules as step S2, and recalculates the hash using the same hash algorithm. The principle behind this complete consistency is to eliminate any differences in implementation details between the sender and receiver, ensuring that both parties obtain the same hash value for the same data content. Any difference—whether it's a different order of serialization fields, a different encoding format, or a different hash algorithm implementation—will lead to hash comparison failures and false positives.
[0049] The hash comparison engine performs byte-level precise comparisons. The comparison results are divided into three states: if the hash values are completely consistent, the verification is passed; if the hash values are inconsistent, the data is determined to have been tampered with during transmission or storage, an anomaly is marked and an alarm is triggered; if the corresponding data is not found in the target storage, the data is determined to be missing, an anomaly is marked and an alarm is triggered.
[0050] The verification results generate audit logs, which are written to a separate storage area of the shared log in a non-blocking asynchronous manner. The design principle is that the original evidence records and audit logs are physically isolated to avoid interference with the original evidence during the audit process; at the same time, the audit logs, as secondary evidence, together with the original evidence, form a complete chain of evidence, making the verification behavior itself recorded and traceable.
[0051] According to such Figure 1 The implementation method shown, through the coordinated implementation of the above five steps, achieves the following core technical effects: First, zero-interference evidence generation. Leveraging the inherent advantage that data is already in memory during the CDC parsing process, hashes are calculated conveniently before data is placed in the sending queue, eliminating the need for additional disk reads or network requests; asynchronous writing to the shared log does not wait for confirmation and does not block subsequent processing on the main link. The performance impact of evidence generation on the main link is negligible.
[0052] Second, physical isolation and independent evolution. The shared log and the main link message queue are deployed on different physical infrastructures. The failure of the evidence chain will not affect the normal operation of the data synchronization main link, and the failure of the main link will not cause the loss of generated evidence. The evidence chain and data stream can be upgraded, expanded, and maintained independently.
[0053] Third, it is independently verifiable across institutions. The auditing end is deployed on the receiving side, independent of the sending system. It can independently read data from the target storage and recalculate the hash for comparison, without needing to trust the sending system's state. The verification results have cross-institutional trust validity.
[0054] Fourth, rapid fault location. Batch-by-batch evidence records contain precise source database location and message queue location information. When an anomaly is detected during verification, the specific log location and sending location can be quickly located through the location information, transforming fault investigation from a rough mode of full reconciliation to a precise mode of batch-by-batch tracing.
[0055] Fifth, the reliability of evidence persistence. The local cache queue and disk persistence mechanism form a two-tiered safety net to ensure that evidence records are not lost during brief failures of the shared log service. After the service is restored, evidence is replayed and rewritten in batches according to time order, ensuring that the continuity and integrity of the evidence chain are not interrupted due to external dependency failures.
[0056] The specific implementation process of the present invention is illustrated below with a specific embodiment.
[0057] Specific implementation examples of cross-institutional fund clearing data synchronization among financial institutions: A commercial bank (sender) needs to synchronize its core system's fund clearing records to a partner securities firm's (receiver's) risk control system in real time. Regulatory requirements mandate that both parties retain immutable evidence of each synchronization operation for third-party verification in case of disputes. The synchronization chain is: MySQL source database → Debezium change capture → Kafka message queue → target MySQL database.
[0058] System architecture deployment: The sender deploys Debezium Connector as the change capture component and a standalone Kafka cluster as the shared log service. The receiver deploys the target MySQL database and auditing services. The sender and receiver are connected via a dedicated network line.
[0059] The implementation process includes: Step S1: Change capture The Debezium Connector establishes a replication connection to the source database as a MySQL slave, listening for Binlog events. Batch aggregation rules are configured: a time threshold of 100 milliseconds and a record count threshold of 500. Batch commit is triggered when the cumulative number of INSERT events in the liquidation log table reaches 500, or when 100 milliseconds have elapsed since the last batch aggregation.
[0060] The generated data batch contains multiple clearing transaction records. Each record includes fields such as transaction ID, transaction time, transaction amount, transaction type, and account information. The batch metadata record starts at mysql-bin.000456:7890123 in the Binlog and ends at mysql-bin.000456:7891234 in the Binlog.
[0061] Step S2: Hash Calculation Before putting data batches into the Kafka Producer send buffer, the Debezium Connector performs serialization and hash calculations on the data batches in memory.
[0062] Serialization uses Avro binary encoding, and the field order is fixed as follows: Transaction ID → Transaction Time → Transaction Amount → Transaction Type → Account Information. Field values are mapped to key-value pairs in ascending alphabetical order.
[0063] Calculate the SHA-256 hash of the Avro serialized byte stream to obtain the batch content hash value a1b2c3d4e5f6... (64-character hexadecimal string).
[0064] Step S3: Evidence Construction Construct an evidence record containing the following fields: batch_id:550e8400-e29b-41d4-a716-446655440000 source_position: mysql-bin.000456:7890123-7891234 queue_position: fund_clearance:0: (Pre-reserved position, to be filled after sending) batch_hash: a1b2c3d4e5f6... batch_timestamp:1753248000000 record_count: 500 Step S4: Asynchronous Persistence Evidence records are entered into the Kafka Producer's send buffer. The Producer is configured with acks=1, batch.size=16384, linger.ms=5, and compression.type=snappy.
[0065] The Producer sends evidence records in batches to the Topic "evidence_log" of the shared log Kafka cluster independently deployed by the sender.
[0066] Steps S41-S43: Cache degradation when service is unavailable Suppose that the shared log Kafka cluster is temporarily unavailable due to a network failure: If the heartbeat thread fails to probe three times consecutively, the service is determined to be unreachable. Evidence recording is switched from the Producer sending process to a local cache queue (LinkedBlockingQueue, capacity 10,000 records).
[0067] Evidence records are continuously added to the queue. When the number of records in the queue reaches 10,000, disk persistence is triggered. A background thread writes all 10,000 evidence records in the queue to the local disk file evidence_backup_20260724103000.avro, in Avro container file format, with each record containing serialized evidence content. After persistence is complete, the memory queue is cleared, and new evidence is received again.
[0068] After network recovery, the heartbeat thread successfully probes three times consecutively, confirming service recovery. Batch playback is initiated: evidence records are read from the memory queue and sorted by batch_timestamp; evidence records are also read from the disk file and sorted by batch_timestamp; the sorted record streams are merged and sent in batches to the shared log. After playback is complete, the disk files are deleted.
[0069] Step S5: Independent Verification The recipient's auditing service performs verification every 5 minutes. The auditing Consumer pulls evidence records from the shared log Topic "evidence_log".
[0070] For each evidence record, the auditing end retrieves the corresponding data batch from the business topic "fund_clearance" based on the Kafka partition number and offset in the queue_position. The hash is then recalculated using the Avro serialization rules and SHA-256 algorithm, which are completely consistent with those used by the sender.
[0071] Compare the recalculated hash with the batch_hash in the evidence record. If they match, generate a PASSED audit record; if they do not match, generate a FAILED audit record and trigger an alarm.
[0072] Audit logs are written to the independent Topic "audit_log" in the shared log.
[0073] Optionally, in some specific embodiments, layered trust anchor enhancement is also included: In high compliance scenarios, enable recipient collaborative signing: After verification, the recipient uses an RSA private key to sign the batch_hash field of the evidence record and appends the signature to the evidence record.
[0074] Enable TSA timestamps: After generating the evidence record, the sender sends a timestamp request to the National Time Service Center (TSA) service. The TSA returns a timestamp token containing a signature, which is embedded in the evidence record.
[0075] Enable blockchain anchoring: Every hour, the batch hashes of the evidence records from the most recent hour are used to build an MMR tree, generate a root hash, and anchor it via an Ethereum smart contract.
[0076] Figure 2 for Figure 1 A flowchart illustrating step S4 in Example 1000. (See attached diagram.) Figure 2 As shown, step S4 includes steps S41-S43.
[0077] Step S41: Detect the service communication status of the shared log. Step S41 uses a lightweight communication status detection mechanism to perceive the availability of the shared log service in real time without increasing the main link processing latency, providing a basis for decision-making for subsequent cache degradation and recovery playback.
[0078] Optionally, communication status detection employs a layered probing strategy. The first layer is send callback probing: after each asynchronous send operation, the producer's callback function records the sending result. If multiple consecutive callbacks return failures, the shared log service is deemed potentially unavailable, triggering the second layer of probing. The second layer is periodic heartbeat probing: the change capture component maintains an independent heartbeat thread, sending probe messages to the shared log at fixed intervals. The probe messages are minimal empty records or dedicated heartbeat records, carrying no business data. If consecutive heartbeat failures reach a preset threshold, the shared log service is formally deemed unreachable, triggering a local cache degradation process.
[0079] The design principle of the layered probing strategy is as follows: Sending callback probing utilizes existing sending operations to achieve real-time perception with zero additional overhead, but may produce false judgments due to instantaneous network jitter; timed heartbeat probing provides an independent verification channel to eliminate false judgments, but introduces periodic overhead. The two work together to balance real-time performance and accuracy.
[0080] In step S42: When the shared log service is unavailable, the evidence records to be written are cached in the local cache queue of the change capture component. Step S42 also involves switching the write target of the evidence records from the remote shared log to the local memory queue, thus implementing local degradation of the write operation and ensuring that the evidence generation process is not interrupted due to external dependency failures.
[0081] The local cache queue is implemented using a bounded blocking queue. The maximum capacity of the queue is estimated based on the memory quota of the change capture component and the memory usage of a single evidence record. When an evidence record enters the queue, if the queue is not full, it is enqueued directly; if the queue is full, it is blocked and waited for or the oldest record is discarded. The specific strategy is configured according to the business requirements for evidence integrity.
[0082] The design principle behind capacity threshold-triggered disk persistence is as follows: Memory queues offer low-latency write capabilities, but are limited by memory capacity; disk storage offers large-capacity persistence capabilities, but its write latency is higher than memory. When the memory queue reaches its capacity threshold, it indicates that the shared log service failure has persisted for some time, and the memory buffer is about to run out. At this point, disk persistence must be triggered to prevent evidence loss. The disk persistence operation is performed in a separate background thread, without blocking the main thread's evidence enqueueing operations.
[0083] The disk-persistent files use an append-only write mode, and the file format is a sequentially stored binary record stream. Each record contains a length prefix and a record body. The length prefix is a fixed-length integer value, and the record body is the serialized result of the evidence record. This format supports efficient sequential reading and record-boundary parsing, facilitating subsequent batch playback.
[0084] In step S43: After the shared log service communication is restored, the evidence records in the local cache queue are batch replayed and written to the shared log in chronological order. Optionally, a capacity threshold is set for the local cache queue; when the local cache queue reaches the capacity threshold, the evidence records in the queue are persisted to the local disk.
[0085] In some specific embodiments, in step S43, after the shared log service recovers, the locally cached evidence records are replayed in batches according to time order and written to the shared log to ensure the continuity of the evidence chain and time consistency.
[0086] The recovery detection is triggered by the heartbeat detection mechanism in step S41. When the heartbeat detection successfully reaches a preset threshold consecutively, it is determined that the shared log service has been restored.
[0087] The batch playback process first reads evidence records from the local cache queue, generates timestamps for each batch, and then sends them in batches. After the queue is emptied, it reads evidence records from the persistent disk files, sorts them by timestamp, and then sends them in batches. Once playback is complete, the played-out disk files are deleted.
[0088] The design principle of chronological playback is that the storage order of evidence records in the shared log must be consistent with the batch generation order to maintain the temporal continuity and traceability of the evidence chain. If playback is out of order, subsequent audit verification and Merkle tree construction based on time windows will not be able to execute correctly.
[0089] Bulk sending uses the same producer batch mode as the normal process, but is configured with a larger batch size and a longer send latency to maximize playback throughput and shorten recovery time.
[0090] Figure 3 This is a flowchart illustrating an embodiment 2000 of the real-time parsing and synchronization method for database log data according to the present invention. Figure 3 As shown, Embodiment 2000 includes steps S201-S205, which are the same as steps S1-S5 in Embodiment 1000, and will not be described again here. Embodiment 2000 also includes a recipient collaborative signature step S206.
[0091] The receiver recalculates the verification hash of the data batch written to the target storage. When the verification hash matches the batch content hash, the receiver generates a batch signature using its own key and appends the batch signature to the corresponding evidence record. In step S206, the receiver is introduced as an independent trust anchor, breaking the sender's unilateral control over the evidence chain. This ensures that valid evidence must be endorsed by both the sender and the receiver, preventing either party from unilaterally forging complete evidence.
[0092] The receiver's verification process is independent of the sender's evidence generation process. The receiver's consumer component pulls data batches from the message queue and recalculates the verification hash according to the same serialization rules and hash algorithm as the sender. The verification hash is compared with the batch content hash in the evidence record, with the comparison logic being a byte-level exact match. If the two hash values do not match, it indicates that the data has been tampered with or corrupted during transmission or writing. The receiver refuses to generate a batch signature and triggers an anomaly alarm process.
[0093] Batch signature generation employs an asymmetric encryption mechanism. The recipient uses its own private key to perform a digital signature operation on the batch content hash field in the evidence record, generating a signature value. The input to the signature operation is strictly limited to the batch content hash value, excluding other fields from the evidence record, to ensure the semantic clarity of the signature: the recipient only endorses the fact that "the data content hash of this batch" and does not endorse auxiliary information such as source repository locations or message queue locations provided by the sender. The design principle is that the source repository location and message queue location are generated by the sender, and the recipient cannot independently verify their authenticity. If the signature includes these fields, it would broaden the scope of the recipient's endorsement and reduce the credibility of the signature.
[0094] The signature value adopts the standard digital signature output format, including the signature value body and the signature algorithm identifier. When the signature value is appended to the evidence record, it does not overwrite or modify the original fields of the evidence record, but instead adds a recipient signature field to the data structure of the evidence record. This append operation is initiated by the recipient to the shared log through an independent secure channel. The shared log uses the same add-only mode as the original record for appending to evidence records.
[0095] The rule for determining valid evidence records on shared logs is that they must simultaneously contain both the batch content hash generated by the sender and the batch signature generated by the receiver. Evidence records lacking either element are considered incomplete evidence and are marked as abnormal during the verification and evidence presentation process. The design principle of this rule is that, since the sender does not know the receiver's private key, they cannot forge the receiver's signature; furthermore, because the hash is calculated based on the original data and the receiver lacks write permissions to the source database, they cannot forge the sender's hash. Through mutual checks and balances, the authenticity of the evidence is jointly ensured.
[0096] In Example 2000, through the receiver collaborative signature mechanism, this solution achieves the following technical effects: First, there is the defense against unilateral tampering. If the sender tampers with the data before calculating the hash, the verification hash recalculated by the receiver will be inconsistent with the batch content hash in the evidence record. The receiver will refuse to sign, and the sender will be unable to generate valid evidence. This mechanism fundamentally eliminates the security risk of the sender unilaterally controlling the entire link.
[0097] Second, there is bidirectional non-repudiation. The sender cannot deny generating the batch content hash (because the hash is calculated based on the data it parsed), and the receiver cannot deny generating the batch signature (because the signature uses its private key). Both parties leave their own cryptographic traces on the chain of evidence, and any subsequent denial by either party can be independently verified.
[0098] Third, the trust foundation is upgraded. The core solution relies on the honesty of the sender, which is suitable for internal synchronization scenarios within an organization. By introducing collaborative signatures from the receiver, the trust foundation is upgraded to mutual honesty between the sender and the receiver, making it suitable for routine cross-organizational collaboration scenarios and enabling the establishment of a mutually trusted chain of evidence without relying on a third party.
[0099] In some specific embodiments, trusted timestamp signing and / or blockchain hash anchoring operations are selectively enabled based on preset trust anchor configuration parameters. Building upon recipient-coordinated signing, an externally uncontrollable third-party trust anchor is further introduced, forming a complete trust gradient from within the institution to cross-border regulation. This ensures that scenarios with different compliance levels can obtain trusted guarantees that match their needs, avoiding over-engineering or insufficient trust.
[0100] Trust anchor configuration parameters are stored in a structured format in the system configuration center, including the following fields: trust anchor level identifier, trusted timestamp service enabled flag, blockchain anchor enabled flag, timestamp service access address, blockchain network identifier, and anchoring period configuration. The configuration parameters are loaded at system startup, and the system dynamically decides whether to execute the corresponding trust anchor operation based on the parameter values during runtime.
[0101] The principle behind trusted timestamp signatures is as follows: After generating an evidence record, the sender submits a batch hash of the evidence record to the Trusted Timestamp Service (TSA). The TSA uses its private key to digitally sign this hash and the current timestamp, generating a timestamp token. The timestamp token contains the following information: the TSA identifier, the timestamp value, the evidence record hash, and the TSA digital signature. The timestamp token is appended to the evidence record. As an independent third-party organization, the TSA's private key is unknown to both the sender and the receiver; therefore, even if the sender and receiver collude to tamper with the data, they cannot forge the TSA's timestamp signature. The selection of the TSA follows the qualification certification requirements of the State Cryptography Administration or the International Organization for Standardization, ensuring the legal validity of the timestamp.
[0102] The principle behind blockchain hash anchoring involves aggregating the hashes of multiple evidence records into a single root hash at preset intervals, and then submitting this root hash to the blockchain network for storage. The blockchain network's consensus mechanism ensures that the written hashes are immutable, and that all participants can independently verify the on-chain records. The anchoring operation is not performed individually for each evidence record, but rather in batches within a time window, reducing the frequency and cost of writing to the blockchain.
[0103] In Example 2000, the selective activation design principle is based on the significant differences in trust strength requirements across different application scenarios. In internal institutional synchronization scenarios, the sender and receiver belong to the same legal entity, and internal auditing suffices for compliance, eliminating the need for an external trust anchor. In cross-institutional routine collaboration scenarios, a foundation of commercial trust exists between the parties, and the receiver's collaborative signature is sufficient. In high-compliance regulatory scenarios, regulatory agencies require third-party time verification, necessitating the activation of TSA. In cross-border judicial evidence scenarios, defense against collusion among all participants is required, necessitating the activation of blockchain anchoring. By selectively enabling configuration parameters, the system automatically adapts the trust level to different scenarios, avoiding unnecessary external dependencies and operational costs in scenarios with low trust requirements.
[0104] Through a layered, optional trust anchor mechanism, this solution achieves the following technical effects: First, the trust gradient is flexibly adaptable. From basic unilateral hashing to receiver collaborative signatures, TSA timestamps, and blockchain anchoring, four layers form a clear progression of trust strength. When deploying the system, the appropriate adaptation layer is selected based on the compliance requirements of the scenario, satisfying the security needs of high-constraint scenarios while avoiding resource waste in low-constraint scenarios.
[0105] Second, third-party independence is guaranteed. As external entities uncontrollable by both the sender and receiver, the TSA and blockchain's signatures and records possess cross-institutional credibility. Even if the sender and receiver collude, they cannot forge TSA signatures or tamper with the hashes already on the blockchain, providing ultimate trust assurance for highly compliant scenarios.
[0106] Third, dynamic switching with configuration. Trust anchor configuration parameters can be dynamically adjusted at runtime, allowing for upgrades or downgrades of trust levels without restarting the system. For example, during routine operations, recipient collaborative signatures can be enabled; during regulatory audits, TSA timestamps can be temporarily enabled; and during annual audits, blockchain anchoring can be enabled. This dynamic switching capability gives the system the flexibility to evolve towards future compliance.
[0107] Optionally, the blockchain hash anchoring operation includes: periodically extracting the batch content hashes corresponding to multiple evidence records within a preset time window, aggregating them to generate an aggregated root hash, and submitting the aggregated root hash to the blockchain for evidence storage. By hash aggregation, the high-frequency batch-by-batch evidence records are compressed into low-frequency batch root hashes. While preserving immutability, this significantly reduces the frequency and cost of writing to the blockchain, transforming blockchain anchoring from an infeasible solution of uploading each record to the chain to a feasible solution of periodic batch anchoring.
[0108] The time window is defined using a fixed-time granularity mechanism. The system maintains a sliding time window, with the starting point being the timestamp of the last anchoring operation and the ending point being the current anchoring trigger time. The window length is determined by the anchoring cycle configuration parameter, typically configured to occur once per hour. Evidence records within the window are read sequentially from the shared log, with the reading condition being that the batch generation timestamp of the evidence record falls within the current window range. After reading, the batch content hash value is extracted from each evidence record, forming an ordered hash list.
[0109] The aggregate root hash is generated using a Merkle Mountain Range structure. Merkle Mountain Range is a Merkle tree variant suitable for appending scenarios, organizing sequentially appended leaf nodes into a series of complete binary trees of varying heights. The construction process is as follows: batch content hashes within the window are used as leaf nodes, arranged from left to right in append order; whenever two subtrees of the same height are adjacent, they are merged to generate a parent node, whose value is a combination of the hashes of the two child nodes; this merging is repeated until no further steps are possible, ultimately forming a set of mountain peaks of varying heights. The root hashes of all peaks are combined in a specific order to generate the aggregate root hash for that time window. This aggregate root hash uniquely identifies the completeness of the set of all batch content hashes within the window—any modification to a leaf node hash will result in a change to the aggregate root hash.
[0110] The submission of the aggregated root hash is achieved through a blockchain smart contract call. The sender or a designated anchor service uses the aggregated root hash as transaction data to invoke the notarization smart contract deployed on the blockchain network. The smart contract records the aggregated root hash, the window start timestamp, the window end timestamp, the submitter's address, and returns the transaction hash as the notarization credential. The notarization credential is appended to the corresponding evidence record in the shared log, establishing a correlation index between on-chain records and off-chain evidence.
[0111] The design principle behind the relationship between aggregated root hash and batch hashing is as follows: the aggregated root hash is a cryptographic digest of the batch hash, possessing the following properties: when verifying window integrity, only the aggregated root hash needs to be compared, without comparing each item individually; when locating tampered batches, drilling down layer by layer from the aggregated root hash requires only a logarithmic number of hash calculations to locate the specific leaf node. This design makes daily auditing efficient and anomaly detection accurate, balancing efficiency and precision.
[0112] Through the blockchain hash anchoring mechanism, this solution achieves the following technical effects: First, the immutability with controllable costs. Blockchain storage and transaction fees are charged per write operation, and the cost of batch-by-batch on-chain deployment is unacceptable in high-frequency synchronization scenarios. By using Merkle Mountain Range aggregation, the on-chain frequency is reduced from tens of thousands of times per second to once per hour, reducing costs by more than four orders of magnitude, making blockchain anchoring not only theoretically feasible but also economically feasible.
[0113] Second, rapid verification of batch integrity. During routine audits, auditors only need to compare the aggregated root hash on the blockchain with the locally recalculated aggregated root hash to confirm the integrity of all batches within the entire time window in milliseconds, without needing to read and compare every piece of evidence record within the window. This efficiency improvement reduces large-scale historical audits from hours to minutes.
[0114] Third, precise tamper location capability. When the aggregate root hash comparison is inconsistent, the auditor can use the proof path of the Merkle Mountain Range to drill down layer by layer to locate the specific tampered batch by obtaining only a logarithmic number of intermediate node hashes. This location capability transforms anomaly investigation from a rough mode of full-scale scanning to a precise mode of single-point tracing, significantly reducing the cost of fault investigation.
[0115] Fourth, on-chain and off-chain connections are traceable. The evidence storage certificate establishes an index link between blockchain transactions and evidence records in the shared log. Any third party can independently verify the existence of the aggregated root hash and timestamp on the blockchain through the evidence storage certificate, without relying on the sender's or receiver's system, thus achieving public verifiability.
[0116] Figure 4This is a flowchart illustrating an embodiment 3000 of the real-time parsing and synchronization method for database log data according to the present invention. Figure 4 As shown, Embodiment 3000 includes steps S301-S305, which are the same as steps S1-S5 in Embodiment 1000, and will not be described again here. Embodiment 3000 also includes an evidence aggregation and verification step S306.
[0117] In step S361: The audit plane periodically reads multiple evidence records within a time window divided by a preset time granularity from the shared log, extracts batch content hashes from the multiple evidence records, and incrementally constructs a Merkle Mountain Range hash tree. Step S361 aggregates the long-accumulated batch-by-batch hash evidence through the incrementally constructed Merkle Mountain Range structure, reducing the complexity of large-scale integrity verification from linear to logarithmic, while retaining the accurate ability to locate batch-by-batch tampering.
[0118] Merkle Mountain Range is a Merkle tree variant suitable for appending data. Its structure consists of a series of complete binary trees of varying heights, resembling a continuous mountain range. A key feature of this structure is incremental construction: each new leaf node only requires calculating the hash of nodes along the path from that leaf node to the root of its corresponding mountain peak, without needing to rebuild the entire tree. This characteristic aligns perfectly with the continuous appending pattern of evidence records in CDC synchronization scenarios.
[0119] Optionally, when constructing the Merkle Mountain Range hash tree, the leaf node type and the intermediate node type are distinguished; the leaf nodes store the batch content hash, and the intermediate nodes store the combined hash of the child nodes; when constructing the integrity proof, the single batch existence proof and the continuous interval integrity verification logic are distinguished.
[0120] The construction process follows a strict appending order. The audit plane reads evidence records from the shared log in the order of batch-generated timestamps, extracting the batch content hash from each evidence record as a leaf node. When inserting leaf nodes, the Merkle Mountain Range merging rules are followed: when two adjacent subtrees of the same height exist, they are merged to generate a parent node with a height increased by one; the hash value of the parent node is the combined hash of the hash values of the two child nodes concatenated in a fixed order. This merging process is repeated until no adjacent subtrees of the same height exist, ultimately forming a set of mountain peak structures with varying heights.
[0121] Distinguishing node types is a crucial security mechanism in the construction process. Leaf node types identify that the node directly stores the batch content hash, corresponding to the original data evidence; intermediate node types identify that the node stores the combined hash of its child nodes, corresponding to the aggregate digest. Node type information is embedded in the node data structure and is strictly distinguished when constructing integrity proofs and verifying proofs. This distinction mechanism prevents attacks that disguise intermediate nodes as leaf nodes: if an attacker attempts to submit an existence proof by replacing a leaf node with an intermediate node, the verifier can identify the forgery through node type checks.
[0122] The construction logic of integrity proofs is divided into two types based on the verification objective. Single-batch existence proofs verify whether a specific batch hash exists in the Merkle Mountain Range. The proof consists of the hashes of all sibling nodes on the path from the leaf node to the root of its mountain peak. The verifier reconstructs the root hash through path reconstruction and compares it with the interval root hash. Continuous interval integrity verification verifies whether all batches from the i-th batch to the j-th batch are complete and unaltered. The proof consists of the minimum set of peaks covering the interval and their associated paths. The verifier reconstructs the root hash through an interval covering algorithm and compares it with the interval root hash. The construction algorithms and verification logic of the two types of proofs are strictly separated at the implementation level to prevent verification vulnerabilities caused by confusion in proof types.
[0123] The frequency of incremental builds is controlled by a preset time granularity. The audit plane maintains a sliding window, with the window starting at the timestamp of the last build completion and ending at the current build trigger time. The window length is determined by configuration parameters. After the evidence records within the window are read, incremental builds are performed, generating the root hash of the corresponding interval for that window.
[0124] In step S362: Write the root hash of the interval corresponding to the Merkle Mountain Range hash tree to the shared log.
[0125] After the interval root hash is generated, it is written to the shared log as an independent evidence record. The data structure of this evidence record includes the following fields: interval identifier, window start timestamp, window end timestamp, interval root hash value, construction completion timestamp, and construction node identifier. The interval root hash evidence record and the batch evidence record are stored in different partitions of the same topic in the shared log, or in independent topics, with physical isolation achieved through partitioning strategies.
[0126] Write operations employ the same asynchronous, non-blocking mode as batch-by-batch evidence recording, without blocking other operations on the audit plane. The writing of interval root hashes creates a two-layer structure in the shared log: the bottom layer contains batch-by-batch evidence records, providing precise traceability at the single-batch level; the upper layer contains interval root hash records, providing fast verification at the batch level. The two layers are linked by a time window range index.
[0127] In step S363: When performing large-scale historical data verification, first compare the interval root hash to determine the overall integrity of the window; if the interval root hash comparison is inconsistent, then search layer by layer along the Merkle Mountain Range hash tree path to locate the data batch with anomalies.
[0128] During large-scale historical data verification, the audit plane first performs a comparison of the interval root hashes. The auditor reads the interval root hash records corresponding to the target time range from the shared log, recalculates the interval root hashes locally according to the same construction rules and input data as SA1, and compares the two root hashes byte by byte. If they match, it is determined that all batches within that time window are intact and have not been tampered with, and the verification process ends; if they do not match, a drill-down process is triggered.
[0129] The drill-down process leverages the structural characteristics of the Merkle Mountain Range to quickly locate anomalies. The auditor obtains the set of peaks corresponding to the root hash of each interval and performs existence verification on each peak. For peaks that fail verification, the auditor obtains the two child nodes of its root node, recalculates the subtree hashes for each, and compares them with the stored values to determine the direction of the anomalous subtree. This process is repeated until a specific leaf node is located, indicating a batch that has been tampered with or is anomalous. The computational complexity of this drill-down process is logarithmic, independent of the total number of batches within the window.
[0130] After drilling down to pinpoint the location, the auditor obtains evidence records corresponding to the abnormal batch. Combining this with source database location information and message queue location information, they initiate a targeted investigation process. The targeted investigation may include: independently parsing the original data of the batch from the source database read-only copy or WAL log and recalculating the hash; reading the actual data of the batch from the target storage and recalculating the hash; and comparing the three hash values to determine the point at which the tampering occurred.
[0131] According to such Figure 4 The implementation method shown, through an evidence aggregation and verification mechanism, achieves the following technical effects: efficient integrity verification of large-scale historical data. Batch-by-batch hash comparison is inefficient when dealing with massive amounts of evidence accumulated over a long period; a full comparison at the annual level can take hours or even days. By using interval root hash aggregation of the Merkle Mountain Range, daily audits only need to compare a small number of root hashes to confirm the integrity of a large range of data, reducing verification time from hours to minutes, while retaining the precise ability to locate batch-by-batch tampering, thus balancing efficiency and accuracy.
[0132] Figure 5 This is a flowchart illustrating an embodiment 4000 of a method for real-time parsing and synchronization of database log data according to the present invention. Figure 5As shown, Embodiment 4000 includes steps S401-S405, which are the same as steps S1-S5 in Embodiment 1000, and will not be described again here. Embodiment 4000 also includes an adaptive traffic scheduling step S406.
[0133] In step S406, the scheduling component, independent of the change capture component, reads batch processing timing indicators carried by multiple evidence records from the shared log. Combined with the source library load indicators, network transmission indicators, and target storage write load indicators collected by independent monitoring probes, the operating parameters of the change capture component are dynamically adjusted through a feedback control mechanism. When the monitoring indicators exceed the preset safety threshold, an emergency braking is triggered, and the scheduling parameters are locked to the preset safety range. Step S406 utilizes the shared log as a unified state data source, deeply integrating the evidence chain with the scheduling system, enabling scheduling decisions to be based on the actual processing sequence of each batch rather than a rough system average index, thereby achieving accurate perception and dynamic response to synchronization link bottlenecks.
[0134] Optionally, the scheduling component is deployed and operated independently of the change capture component. This independence is reflected in the fact that the scheduling component has its own independent process or container instance, independent resource configuration, and independent fault domain. The design principle is that failures in the scheduling component, such as algorithm anomalies or resource exhaustion, should not affect the main data synchronization link of the change capture component; and failures in the change capture component, such as parsing anomalies or connection interruptions, should not cause the scheduling component to lose its state. The only communication channel between the two is a shared log. The scheduling component writes scheduling instructions to the shared log, and the change capture component reads and executes them from the shared log, forming a unidirectional, non-blocking, loosely coupled collaboration.
[0135] The principle behind extracting batch processing timing metrics: Evidence records carry key time nodes of batch processing upon generation, including batch parsing timestamps, message queue write timestamps, and target storage confirmation timestamps. The scheduling component reads evidence records in batches from the shared log, parses these timestamp fields, and calculates the following derived metrics: batch parsing time (the difference between the message queue write timestamp and the batch parsing timestamp); message queue dwell time (the difference between the target storage confirmation timestamp and the message queue write timestamp); and end-to-end processing time (the difference between the target storage confirmation timestamp and the batch parsing timestamp). These derived metrics reflect the actual dwell time of data batches at each stage of the synchronization link and are a direct basis for determining bottleneck locations.
[0136] Source database load metrics are collected via independent monitoring probes. These probes connect to the source database in read-only query mode, collecting data on Binlog generation rate, number of active transactions, and slow query ratio. Binlog generation rate reflects change pressure on the source database; the number of active transactions reflects concurrent load; and the slow query ratio reflects query performance degradation. These metrics are used to determine if the bottleneck is at the source: if the Binlog generation rate consistently exceeds the consumption rate of the change capture component, or if the number of active transactions exceeds a preset threshold, the source is identified as the bottleneck.
[0137] Network transmission metrics are collected via independent monitoring probes. These probes are deployed on the network path between the change capture component and the message queue, collecting data on bandwidth utilization, round-trip latency, and packet loss rate. Near-saturation bandwidth utilization or a sudden increase in round-trip latency indicates network congestion; a high packet loss rate indicates deteriorating network quality. These metrics are used to determine if the bottleneck is located at the transport layer.
[0138] Target storage write load metrics are collected via independent monitoring probes. These probes connect to the target storage in read-only query mode, collecting APPLY thread wait time, lock wait time, and disk I / O utilization. APPLY thread wait time reflects the target storage's consumption capacity; lock wait time reflects the degree of concurrency conflicts; and disk I / O utilization reflects the physical resource pressure on the target storage. These metrics are used to determine whether the bottleneck is located on the consumption side.
[0139] The design principle of the feedback control mechanism is as follows: The scheduling component maintains a target state, such as keeping the queue depth within a reasonable range, and continuously calculates the deviation between the actual state and the target state. When the deviation is small, the operating parameters of the capture component are fine-tuned, such as slightly adjusting the batch window size; when the deviation is large, the parameters are significantly adjusted, such as significantly reducing the number of concurrent threads; when the deviation persists, historical deviations are accumulated for compensation adjustments to eliminate systematic offsets. This mechanism enables the scheduling parameters to smoothly track load changes and avoids frequent jitter caused by instantaneous fluctuations.
[0140] The emergency braking mechanism is designed as follows: when any monitored indicator exceeds a preset safety threshold, the fine-tuning of feedback control is immediately suspended, and the scheduling parameters are forcibly locked to a preset safety range. The parameter values within the safety range are empirical values determined by the system designers based on extreme scenario testing, ensuring that the system can maintain basic operation without crashing even under the worst conditions. After emergency braking is triggered, the scheduling component enters observation mode, continuously monitoring indicator changes. Once all indicators return to normal and stabilize for a period, the lock is gradually released, and the fine-tuning of feedback control resumes. The design principle of this mechanism is that while fine-tuning is suitable for performance optimization during stable operation, in extreme and abnormal scenarios, rapid loss mitigation takes precedence over fine-tuning, avoiding oscillations during the adjustment process that could exacerbate system deterioration.
[0141] Writing and executing scheduling instructions: The scheduling component encapsulates the adjusted runtime parameters into scheduling instructions and writes them to a separate partition of the shared log in a non-blocking asynchronous manner. The change capture component periodically reads scheduling instructions from the shared log, parses them, and applies them to the local runtime parameters. The change capture component adopts a "suggestion adoption" mode for executing scheduling instructions: after an instruction arrives, the new parameters are applied after the current batch processing is completed to avoid data inconsistencies caused by parameter switching; if instruction parsing fails or parameter values exceed the local allowed range, execution is rejected and an exception is logged, maintaining the current parameters for continued operation. The design principle is that the scheduling component's suggestion instructions should not forcibly interrupt ongoing batch processing, and the change capture component retains the final parameter decision-making power. Even if the scheduling component fails, data synchronization can still continue to run according to the current parameters.
[0142] According to such Figure 5 The embodiments shown in this invention achieve the following technical effects through an adaptive traffic scheduling mechanism: Precise bottleneck identification and dynamic resource adaptation. Traditional CDC scheduling relies on static parameters set by DBAs based on their experience. While this works well during periods of stable business operations, it fails in dynamic scenarios such as sudden traffic spikes, target database bottlenecks, and network jitter. This solution obtains batch processing timelines from shared logs and combines this with multi-dimensional load signals from the source database, network, and target database to precisely identify bottlenecks. Feedback control dynamically adjusts parameters, giving the synchronization system the resilience to adapt to load changes and maintain stable synchronization latency and throughput even under fluctuating traffic conditions.
[0143] Figure 6 This is a schematic diagram of an embodiment 5000 of the real-time parsing and synchronization system for database log data according to the present invention. Figure 6 As shown, embodiment 5000 includes a change capture module 501, a hash calculation module 502, an evidence construction module 503, an asynchronous persistence module 504, and an independent verification module 505.
[0144] The change capture module 501 parses the source database log to obtain a data batch consisting of multiple data change records. The hash calculation module 502 calculates the batch content hash corresponding to the data batch based on the data batches loaded in memory. The evidence construction module 503 generates evidence records, which at least include a unique batch identifier, source database location information, message queue location information, and batch content hash. The asynchronous persistence module 504 writes the evidence records to the shared log in a non-blocking asynchronous manner; the shared log is physically isolated from the main link message queue transmitting the data batches, and the shared log uses an append-only writing mode. The independent verification module 505 reads the evidence records from the shared log, reads the corresponding data batches from the target storage, recalculates the hash according to the serialization rules consistent with the hash calculation steps, and compares it with the batch content hash in the evidence record to obtain the verification result.
[0145] It should be noted that, in this document, relational terms such as "first" and "second" are used only 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 thereof 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 a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0146] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A method for real-time parsing and synchronization of database log data, characterized in that, Includes the following steps: Change capture step S1: Parse the source database logs using the change capture component to obtain a data batch consisting of multiple data change records; Hash calculation step S2: Based on the data batches already loaded in memory, calculate the batch content hash corresponding to the data batches; Evidence construction step S3: Generate evidence record, wherein the evidence record includes at least a batch unique identifier, source library location information, message queue location information, and batch content hash; Asynchronous persistence step S4: Write the evidence record to the shared log in a non-blocking asynchronous manner; the shared log is physically isolated from the main link message queue that transmits the data batch, and the shared log adopts an append-only writing mode; Independent verification step S5: Independent of the sender, the audit end reads the evidence record in the shared log, reads the corresponding data batch from the target storage, recalculates the hash according to the serialization rules consistent with the hash calculation step, and compares it with the batch content hash in the evidence record to obtain the verification result.
2. The method according to claim 1, characterized in that, Step S4 includes: S41: Detect the service communication status of the shared log; S42: When the shared log service is unavailable, the evidence record to be written is cached in the local cache queue of the change capture component; S43: After the communication with the shared log service is restored, the evidence records in the local cache queue will be replayed in batches according to time order and written to the shared log.
3. The method according to claim 2, characterized in that, The local cache queue is set with a capacity threshold; when the local cache queue reaches the capacity threshold, the evidence records in the queue are persisted to the local disk.
4. The method according to claim 1, characterized in that, It also includes the recipient's collaborative signature step: The receiver recalculates the verification hash of the data batch written to the target storage. When the verification hash matches the batch content hash, the receiver generates a batch signature using its own key and appends the batch signature to the corresponding evidence record.
5. The method according to claim 4, characterized in that, Based on the preset trust anchor configuration parameters, selectively enable trusted timestamp signing and / or blockchain hash anchoring operations.
6. The method according to claim 5, characterized in that, The blockchain hash anchoring operation includes: periodically extracting the batch content hashes corresponding to multiple evidence records within a preset time window, aggregating them to generate an aggregated root hash, and submitting the aggregated root hash to the blockchain for evidence storage.
7. The method according to claim 1, characterized in that, It also includes an evidence aggregation and verification step, which specifically includes the following sub-steps: The audit plane periodically reads multiple evidence records from the shared log within a time window divided by a preset time granularity, extracts the batch content hash from the multiple evidence records, and incrementally constructs a Merkle Mountain Range hash tree; Write the root hash of the interval corresponding to the Merkle Mountain Range hash tree into the shared log; When performing large-scale historical data verification, the integrity of the entire interval root hash judgment window is first compared. If the interval root hash comparison is inconsistent, the data batch with abnormality is located by searching layer by layer along the Merkle Mountain Range hash tree path.
8. The method according to claim 7, characterized in that, When constructing the Merkle Mountain Range hash tree, leaf node type and intermediate node type are distinguished; leaf nodes store batch content hashes, and intermediate nodes store child node combination hashes; when constructing integrity proofs, single batch existence proofs and continuous interval integrity verification logic are distinguished.
9. The method according to claim 1, characterized in that, It also includes adaptive traffic scheduling steps: The scheduling component, independent of the change capture component, reads batch processing timing indicators from multiple evidence records in the shared log. Combined with source database load indicators, network transmission indicators, and target storage write load indicators collected by independent monitoring probes, the component dynamically adjusts the operating parameters of the change capture component through a feedback control mechanism. When the monitored indicators exceed the preset safety threshold, an emergency braking is triggered, locking the scheduling parameters to the preset safety range.
10. A real-time parsing and synchronization system for database log data, characterized in that, include: The change capture module is used to parse the source database logs to obtain a data batch consisting of multiple data change records; The hash calculation module is used to calculate the batch content hash corresponding to the data batch based on the data batch already loaded in memory; An evidence construction module is used to generate evidence records, which at least include a batch unique identifier, source library location information, message queue location information, and the batch content hash. An asynchronous persistence module is used to write the evidence records to a shared log in a non-blocking asynchronous manner; the shared log is physically isolated from the main link message queue that transmits the data batches, and the shared log adopts an append-only writing mode; An independent verification module is used to read the evidence record in the shared log, read the corresponding data batch from the target storage, recalculate the hash according to the serialization rules consistent with the hash calculation steps, and compare it with the batch content hash in the evidence record to obtain the verification result.
