Data writing method, system, device and medium

By performing multi-level write conflict verification and version number comparison in the active-active architecture storage system, write conflict issues are resolved, ensuring data consistency, improving system performance, and avoiding deadlocks.

CN119148942BActive Publication Date: 2025-09-26INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411391558.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-08
Publication Date
2025-09-26
Estimated Expiration
2044-10-08

AI Technical Summary

Technical Problem

In a storage system with an active-active architecture, write conflicts are likely to occur when two sites write to the same data block at the same time, leading to data inconsistency and performance bottlenecks. The existing pessimistic locking method is prone to deadlock problems.

Method used

By obtaining the version numbers and metadata of local and remote sites, multi-level write conflict verification is performed to determine the target data to be written and the operation range, and version numbers are compared before and after writing to ensure data consistency and concurrency.

Benefits of technology

It solves the write conflict problem, avoids the risk of deadlock, improves the system's concurrency performance, and ensures data consistency on the two sites.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119148942B_ABST
    Figure CN119148942B_ABST
Patent Text Reader

Abstract

The present application provides a data writing method, system, device, and medium, including: in response to detecting a data write request initiated by a local site to a target data block, obtaining a local version number currently maintained by the local site; generating local metadata based on the local write operation range and local version number corresponding to the data write request, and writing the local data to be written and the local metadata in the data write request to the target data block; in response to detecting that the local site has received a synchronous write request initiated by a remote site to the target data block, triggering the local site to respond to the synchronous write request, including: obtaining the remote data to be written and remote metadata contained in the synchronous write request; determining the target data to be written and the target write operation range corresponding to the synchronous write request based on the local metadata, remote metadata, remote data to be written, and preset rules, and writing the target data to be written into the target write operation range. This solves the write conflict problem and improves concurrency performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of storage technology, and in particular to a data writing method, system and device. Background Art

[0002] In existing centralized storage systems, to improve system availability, fault tolerance, and read / write performance, active-active storage systems are deployed in some business scenarios. This means that two storage systems provide read / write services simultaneously and back up each other.

[0003] However, in an active-active architecture, the complexity and cost of the storage system increase. For example, when two sites receive write operations for the same data block at the same time, write conflicts arise.

[0004] Therefore, there is an urgent need for a data writing method that can resolve conflict issues and ensure data consistency to solve the above technical problems. Summary of the Invention

[0005] Based on this, it is necessary to provide a data writing method, system equipment and termination to address the above technical problems.

[0006] In a first aspect, the present application provides a data writing method, the method comprising:

[0007] In response to detecting a data write request initiated by a local site to a target data block, obtaining a local version number currently maintained by the local site;

[0008] Generate local metadata according to the local write operation range corresponding to the data write request and the local version number, and write the local data to be written in the data write request and the local metadata into the target data block;

[0009] In response to detecting that the local site receives a synchronous write request initiated by the remote site to the target data block, triggering the local site to respond to the synchronous write request includes:

[0010] Acquire the remote data to be written and remote metadata contained in the synchronous write request, wherein the remote metadata includes a remote write operation range corresponding to the synchronous write request and a remote version number currently maintained by the remote site;

[0011] Based on the local metadata, remote metadata, the remote data to be written and preset rules, determine the target data to be written and the target write operation range corresponding to the synchronous write request, and write the target data to be written into the target write operation range to respond to the synchronous write request initiated by the remote site.

[0012] In some embodiments, the method further comprises:

[0013] In response to detecting a data write request initiated by the local site to the target data block, generating a synchronous write request according to the local data to be written and the local metadata;

[0014] The synchronous write request generated by the local site is sent to the remote site.

[0015] In some embodiments, determining the target data to be written and the target write operation range corresponding to the synchronous write request according to the local metadata, the remote metadata, the remote data to be written, and the preset write rule includes:

[0016] determining, based on the local version number in the local metadata and the remote version number in the remote metadata, whether the synchronous write request initiated to the target data block and received by the local site and the data write request initiated by the local site to the target data block pass a first write conflict verification;

[0017] If the first write conflict verification is passed, determining the remote data to be written as the target data to be written and determining the remote write operation range in the remote metadata as the target write operation range;

[0018] If the first write conflict verification fails, determining, based on the remote write operation range and the local write operation range, whether the synchronous write request initiated to the target data block received by the local site and the data write request initiated to the target data block by the local site pass a second write conflict verification;

[0019] If the second write conflict verification is passed, determining the remote data to be written as the target data to be written and determining the remote write operation range as the target write operation range;

[0020] If the second write conflict verification fails, a target write operation range is determined according to the remote write operation range and the local write operation range, and remote data to be written that matches the target write operation range is determined as the target data to be written.

[0021] In some embodiments, determining, based on the local version number in the local metadata and the remote version number in the remote metadata, whether the synchronous write request initiated by the local site to the target data block and the data write request initiated by the local site to the target data block pass a first write conflict verification includes:

[0022] Read the local serial number in the local version number and the remote serial number in the remote version number;

[0023] If the local sequence number is smaller than the remote sequence number, it is determined that the first write conflict verification is passed;

[0024] If the local sequence number is greater than the remote sequence number, it is determined that the first write conflict verification fails.

[0025] In some embodiments, the root determines, based on the remote write operation range and the local write operation range, whether the synchronous write request initiated by the local site to the target data block and the data write request initiated by the local site to the target data block pass a second write conflict verification, including:

[0026] Acquire a local range start point and a local range end point corresponding to the local write operation range, and acquire a remote range start point and a remote range end point corresponding to the remote write operation range;

[0027] If the local range start point is greater than the remote range end point or the local range end point is less than the remote range start point, determining that the second write conflict verification is passed;

[0028] If the local range start point is smaller than the remote range start point or the local range end point is larger than the remote range end point, it is determined that the second write conflict verification fails.

[0029] In some embodiments, before determining the target write operation range according to the remote write operation range and the local write operation range, the method includes:

[0030] In response to detecting that the local range start point is smaller than the remote range start point and the local range end point is larger than the remote range end point, determining that the target write operation range does not exist;

[0031] In response to detecting that the local range start point is smaller than the remote range start point and the local range end point is smaller than the remote range end point, determining that the target write operation range exists;

[0032] In response to detecting that the local range start point is greater than the remote range start point and the local range end point is greater than the remote range end point, it is determined that the target write operation range exists.

[0033] In some embodiments, determining the target write operation range according to the remote write operation range and the local write operation range includes:

[0034] In response to detecting that the local range start point is smaller than the remote range start point and the local range end point is smaller than the remote range end point, determining a write operation range formed by the remote range start point and the local range end point as a target write operation range;

[0035] In response to detecting that the local range start point is larger than the remote range start point and the local range end point is larger than the remote range end point, a write operation range formed by the local range start point and the remote range end point is determined as a target write operation range.

[0036] In a second aspect, the present application provides a data writing system, the system comprising:

[0037] a data preparation module, configured to, in response to detecting a data write request initiated by a local site to a target data block, obtain a local version number currently maintained by the local site;

[0038] A data processing module, configured to generate local metadata according to a local write operation range corresponding to the data write request and the local version number, and write the local data to be written in the data write request and the local metadata into the target data block;

[0039] The data processing module is further configured to, in response to detecting that the local site receives a synchronous write request initiated by the remote site to the target data block, trigger the local site to respond to the synchronous write request, including:

[0040] Acquire the remote data to be written and remote metadata contained in the synchronous write request, wherein the remote metadata includes a remote write operation range corresponding to the synchronous write request and a remote version number currently maintained by the remote site;

[0041] Based on the local metadata, remote metadata, the remote data to be written and preset rules, determine the target data to be written and the target write operation range corresponding to the synchronous write request, and write the target data to be written into the target write operation range to respond to the synchronous write request initiated by the remote site.

[0042] In a third aspect, the present application provides a computer program product, including a computer program, characterized in that when the computer program is executed by a processor, the steps of the following method are performed:

[0043] In response to detecting a data write request initiated by a local site to a target data block, obtaining a local version number currently maintained by the local site;

[0044] Generate local metadata according to the local write operation range corresponding to the data write request and the local version number, and write the local data to be written in the data write request and the local metadata into the target data block;

[0045] In response to detecting that the local site receives a synchronous write request initiated by the remote site to the target data block, triggering the local site to respond to the synchronous write request includes:

[0046] Acquire the remote data to be written and remote metadata contained in the synchronous write request, wherein the remote metadata includes a remote write operation range corresponding to the synchronous write request and a remote version number currently maintained by the remote site;

[0047] Based on the local metadata, remote metadata, the remote data to be written and preset rules, determine the target data to be written and the target write operation range corresponding to the synchronous write request, and write the target data to be written into the target write operation range to respond to the synchronous write request initiated by the remote site.

[0048] In a third aspect, the present application provides an electronic device, the electronic device comprising:

[0049] one or more processors;

[0050] and a memory associated with one or more processors, the memory being used to store program instructions, which, when read and executed by the one or more processors, perform the following operations:

[0051] In response to detecting a data write request initiated by a local site to a target data block, obtaining a local version number currently maintained by the local site;

[0052] Generate local metadata according to the local write operation range corresponding to the data write request and the local version number, and write the local data to be written in the data write request and the local metadata into the target data block;

[0053] In response to detecting that the local site receives a synchronous write request initiated by the remote site to the target data block, triggering the local site to respond to the synchronous write request includes:

[0054] Acquire the remote data to be written and remote metadata contained in the synchronous write request, wherein the remote metadata includes a remote write operation range corresponding to the synchronous write request and a remote version number currently maintained by the remote site;

[0055] Based on the local metadata, remote metadata, the remote data to be written and preset rules, determine the target data to be written and the target write operation range corresponding to the synchronous write request, and write the target data to be written into the target write operation range to respond to the synchronous write request initiated by the remote site.

[0056] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, which causes a computer to perform the following operations:

[0057] In response to detecting a data write request initiated by a local site to a target data block, obtaining a local version number currently maintained by the local site;

[0058] Generate local metadata according to the local write operation range corresponding to the data write request and the local version number, and write the local data to be written in the data write request and the local metadata into the target data block;

[0059] In response to detecting that the local site receives a synchronous write request initiated by the remote site to the target data block, triggering the local site to respond to the synchronous write request includes:

[0060] Acquire the remote data to be written and remote metadata contained in the synchronous write request, wherein the remote metadata includes a remote write operation range corresponding to the synchronous write request and a remote version number currently maintained by the remote site;

[0061] Based on the local metadata, remote metadata, the remote data to be written and preset rules, determine the target data to be written and the target write operation range corresponding to the synchronous write request, and write the target data to be written into the target write operation range to respond to the synchronous write request initiated by the remote site.

[0062] The beneficial effects achieved by this application are:

[0063] The present application provides a data writing method, comprising: in response to detecting a data write request initiated by a local site to a target data block, obtaining a local version number currently maintained by the local site; generating local metadata based on the local write operation range corresponding to the data write request and the local version number, and writing the local data to be written in the data write request and the local metadata to the target data block; in response to detecting that the local site receives a synchronous write request initiated by a remote site to the target data block, triggering the local site to respond to the synchronous write request, comprising: obtaining the remote data to be written and remote metadata contained in the synchronous write request, the remote metadata including the remote write operation range corresponding to the synchronous write request and the remote version number currently maintained by the remote site; determining the target data to be written and the target write operation range corresponding to the synchronous write request based on the local metadata, remote metadata, the remote data to be written, and preset rules, and writing the target data to be written into the target write operation range to respond to the synchronous write request initiated by the remote site. The method solves the write conflict problem in a storage active-active system, avoids the risk of deadlock, improves the concurrency performance of the system, and ensures data consistency on the two sites. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present application. Those skilled in the art can also derive other drawings based on these drawings without inventive work, among which:

[0065] Figure 1 This is a schematic diagram of a data writing method provided by an embodiment of the present application;

[0066] Figure 2 This is a schematic diagram of data synchronous writing provided by an embodiment of the present application;

[0067] Figure 3 This is a data writing system architecture diagram provided by an embodiment of the present application;

[0068] Figure 4 This is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0069] To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0070] It should be understood that in the description of this application, unless the context clearly requires otherwise, words such as "include", "comprises", and the like throughout the specification and claims should be interpreted as inclusive rather than exclusive or exhaustive; that is, as "including but not limited to".

[0071] It should also be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, the meaning of "plurality" is two or more.

[0072] It should be noted that the terms "S1", "S2", etc. are used only for the purpose of describing the steps and do not specifically refer to the order or sequence, nor are they used to limit this application. They are merely for the convenience of describing the method of this application and should not be understood as indicating the order of the steps. In addition, the technical solutions between the various embodiments can be combined with each other, but this must be based on the fact that ordinary technicians in this field can implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0073] Currently, pessimistic locking is the primary approach used to address data write conflicts caused by two sites simultaneously writing to a data block in active-active storage systems. This approach locks the data block between write operations to prevent other writes from occurring, ensuring that only one site can read or write the data block at any given time, thus avoiding data inconsistencies caused by concurrent writes. However, this approach has significant drawbacks and can easily lead to storage performance bottlenecks and deadlocks, especially in highly concurrent active-active storage systems.

[0074] Example 1

[0075] The embodiment of the present application provides a data writing method, which is applied to a storage system under a dual-active architecture. Specifically, the method disclosed in the embodiment of the present application is used to solve the write conflict problem, such as Figure 1 As shown, including the following:

[0076] S100 : In response to detecting a data write request initiated by a local site to a target data block, obtaining a local version number currently maintained by the local site.

[0077] Among them, it is worth noting that the "local" and "remote" disclosed in this article are distinguished and explained based on the location relationship of the sites. For example, the first site and the second site are two sites with a dual-active relationship. The site that initiates a data write request for the data block is defined as the local site, and the other relative site is defined as the remote site; for example, when the first site initiates a data write request, the first site is the local site, and the second site is the remote site; when the second site initiates a data write request, the second site is the local site, and the first site is the remote site.

[0078] S200: Generate local metadata according to the local write operation range and the local version number corresponding to the data write request, and write the local data to be written and the local metadata in the data write request into the target data block.

[0079] This embodiment also discloses that, in response to detecting a data write request initiated by a local site to a target data block, a synchronous write request is generated based on the local data to be written and local metadata; and the synchronous write request generated by the local site is sent to the remote site. That is, while the local site writes the local data to be written to the target data block in response to the data write request, it also generates a synchronous write request based on the local data to be written and local metadata and sends it to the remote site.

[0080] It can be understood that in this embodiment, two sites initiate data write requests for the same target data block; the local site initiates a synchronous write request to the remote site while responding to the locally initiated data write request, and after the remote site responds to the synchronous write request (that is, the remote site writes the local data to be written contained in the locally initiated data write request), the local site completes writing the local data to be written to the local site and synchronously writes the local data to be written to the remote site.

[0081] S300 : In response to detecting that the local site receives a synchronous write request initiated by the remote site to a target data block, trigger the local site to respond to the synchronous write request.

[0082] The specific local site's response to the synchronous write request specifically includes: obtaining the remote data to be written and remote metadata contained in the synchronous write request, the remote metadata including the remote write operation range corresponding to the synchronous write request and the remote version number currently maintained by the remote site; determining the target data to be written and the target write operation range corresponding to the synchronous write request based on the local metadata, remote metadata, remote data to be written and preset rules, and writing the target data to be written into the target write operation range to respond to the synchronous write request initiated by the remote site.

[0083] The method disclosed in this application sets up a multi-level write conflict judgment logic, which greatly improves the efficiency and accuracy of write conflict judgment. Specifically, based on local metadata, remote metadata, remote data to be written, and preset rules, the target data to be written and the target write operation range corresponding to the synchronous write request are determined, and the target data to be written is written into the target write operation range to respond to the synchronous write request initiated by the remote site, including:

[0084] S310. Determine, based on the local version number in the local metadata and the remote version number in the remote metadata, whether the synchronous write request received by the local site and the data write request initiated by the local site to the target data block pass the first write conflict verification.

[0085] Specifically, in some implementation scenarios, the above-mentioned judgment of whether the synchronous write request initiated by the local site to the target data block and the data write request initiated by the local site to the target data block have passed the first write conflict verification based on the local version number in the local metadata and the remote version number in the remote metadata includes: reading the local sequence number in the local version number and the remote sequence number in the remote version number; if the local sequence number is less than the remote sequence number, it is judged that the first write conflict verification has been passed; if the local sequence number is greater than the remote sequence number, it is judged that the first write conflict verification has been passed. It can be understood that both the local site and the remote site maintain an incrementing version number corresponding to the data block, which includes the globally unique sequence number of this data block and the site identifier; this ensures the comparability of data write operations on different sites, and the version numbers corresponding to different data write operations will not be equal. Each write operation on a data block will cause the version number associated with the data block to increment. At the same time, as can be seen from the foregoing, each time a data write request is responded to from a site, the data to be written (i.e., the data to be written) and the version number of this write operation are synchronously transmitted to the other site, ensuring that both sites can obtain the latest data version of the other. Therefore, in the method disclosed in the application, if a site receives a synchronous write request from a remote site, it can directly obtain the sequence number within the latest version number of the data block maintained at the remote site corresponding to the synchronous write request, and further compare it with the sequence number within the locally maintained version number to quickly determine whether there is a write conflict. This greatly speeds up the determination of write conflicts and further improves the overall efficiency of synchronous data writing.

[0086] S320. If the first write conflict verification is passed, the remote data to be written is determined to be the target data to be written, and the remote write operation range in the remote metadata is determined to be the target write operation range; if the first write conflict verification is not passed, based on the remote write operation range and the local write operation range, it is judged whether the synchronous write request initiated by the local site to the target data block and the data write request initiated by the local site to the target data block have passed the second write conflict verification.

[0087] Specifically, in some implementation scenarios, determining, based on the remote write operation range and the local write operation range, whether a synchronous write request initiated to a target data block received by the local site and a data write request initiated by the local site to the target data block pass the second write conflict verification includes:

[0088] Obtain the local range start point and local range end point corresponding to the local write operation range, and obtain the remote range start point and remote range end point corresponding to the remote write operation range; if the local range start point is greater than the remote range end point or the local range end point is less than the remote range start point, determine that the second write conflict verification has passed; if the local range start point is less than the remote range start point or the local range end point is greater than the remote range end point, determine that the second write conflict verification has not passed.

[0089] In some embodiment scenarios, before determining the target write operation range based on the remote write operation range and the local write operation range, the method includes: in response to detecting that the local range starting point is smaller than the remote range starting point and the local range end point is larger than the remote range end point, determining that the target write operation range does not exist; in response to detecting that the local range starting point is smaller than the remote range starting point and the local range end point is smaller than the remote range end point, determining that the target write operation range exists; in response to detecting that the local range starting point is larger than the remote range starting point and the local range end point is larger than the remote range end point, determining that the target write operation range exists.

[0090] It is understood that when it is detected that the local range start point is smaller than the remote range start point and the local range end point is larger than the remote range end point, that is, the remote data to be written contained in the synchronous write request initiated by the remote site is completely contained in the data already written by the local site after responding to the data write request initiated by the data block. In this case, there is no need to respond to the synchronous write request initiated by the remote site, and the instruction or information indicating the completion of the synchronous write operation is directly fed back to the remote site, so that the remote site can confirm the completion of the synchronous write request and further confirm the completion of the write operation corresponding to the data write request.

[0091] S330. If the second write conflict verification is passed, the remote data to be written is determined to be the target data to be written and the remote write operation range is determined to be the target write operation range; if the second write conflict verification is not passed, the target write operation range is determined based on the remote write operation range and the local write operation range, and the remote data to be written that matches the target write operation range is determined to be the target data to be written.

[0092] In this application, the overlap of the local write operation range and the remote write operation range is defined as a scenario including write conflicts, and different processing measures are proposed for the overlapping range of the local write operation range and the remote write operation range to ensure data consistency between the two sites and improve the efficiency of data writing.

[0093] It is understandable that if the second write conflict verification is passed, that is, there is no write conflict between the synchronous write request initiated by the remote site and the data write request responded by the local site, then the synchronous write request can be directly responded to, and the remote data to be written contained in the synchronous write request is written into the remote write operation range of the target data block. If the second write conflict verification is not passed, that is, there is a write conflict between the synchronous write request initiated by the remote site and the data write request responded by the local site, then the remote data to be written corresponding to the non-overlapping range (i.e., the target range) between the remote write operation range contained in the synchronous write request and the near-end write operation range is obtained, and the remote data to be written is written into the target range.

[0094] Among them, the above-mentioned determination of the target write operation range based on the remote write operation range and the local write operation range includes: in response to detecting that the local range starting point is smaller than the remote range starting point and the local range end point is smaller than the remote range end point, determining the write operation range formed by the remote range starting point and the local range end point as the target write operation range; in response to detecting that the local range starting point is larger than the remote range starting point and the local range end point is larger than the remote range end point, determining the write operation range formed by the local range starting point and the remote range end point as the target write operation range.

[0095] In addition, this application proposes establishing a patrol inspection mechanism that reads the version numbers of each data block at the local site and each data block at the remote site at preset intervals. By comparing the version numbers of the data blocks at the local site with those at the remote site, the consistency of the data within the data blocks at the local and remote sites can be quickly confirmed at the current time point. If inconsistent, an alarm prompt is triggered, where the alarm prompt includes at least the version number of the inconsistent version and the corresponding data block, allowing the user to find the corresponding difference data based on the version number and data block. After determining the difference data, a synchronous write request is re-initiated, further ensuring the consistency of the data written by the remote site and the local site.

[0096] This application avoids potential deadlock issues by comparing version numbers before and after write operations. Furthermore, by allowing multiple write operations to proceed in parallel, version numbers are checked and updated only when data is actually written, thereby improving system concurrency and overall performance. Furthermore, the version number mechanism ensures the uniqueness and order of write operation results on both sites, thereby guaranteeing data consistency in the active-active system.

[0097] The following is described with reference to specific embodiments. Figure 2 As shown in the figure, the active-active storage system includes:

[0098] Write operation module: mainly responsible for receiving data write requests issued by this site, or synchronous write requests sent by remote sites; and is responsible for the final storage of data and version numbers. Version number management module: mainly responsible for maintaining the globally unique version number, providing the current version number value to other modules, and updating the version number when necessary. Conflict detection module: mainly responsible for determining whether a write operation conflicts by using the local version number and the version number included in the remote synchronous write. Conflict resolution module: mainly responsible for resolving conflicts between two write operations in the event of a conflict, ensuring that the data ultimately written by the two sites is consistent.

[0099] Site 1 receives a write request for data in the range [0, 64k] for data block 1. The write module obtains the current version number from the version number management module, which returns the current version number 3 and increments it by 1. The write module writes the data in the range [0, 64k] and version number 3 to disk and forwards the data and version number 3 to site 2. It should be understood that, here, site 1 is the local site relative to site 2, while site 2 is the remote site.

[0100] At the same time, Site 2 receives a request to write data in the range [32k, 96k] for data block 1. After receiving the data write request, the write operation module obtains the current version number from the version number management module. The version number management module returns the current version number 2 and increments the version number by 1. The write operation module writes the data in the range [32k, 96k] and version number 2 to the disk and forwards the data and version number 2 to Site 1. It can be understood that Site 2 is the local site relative to Site 1, and Site 1 is the remote site.

[0101] Site 1 receives a synchronous write request from Site 2 and sends the version number to the version number management module. This module finds that the remote version number is smaller than the local version number and does not update the local version number. The write operation module then sends the data to the conflict detection module. The conflict detection module reads the version number 3 of data block 1 from the disk, indicating a conflict, and returns a result of conflict detection failure. After receiving the request, the write operation module sends the data and the last written range to the conflict resolution module. The conflict resolution module determines that the range of the higher version write is [0,64k], while the operating range of the lower version synchronous write request is [32k,96k]. Therefore, the data in the range of [64k,96k] in the synchronous write operation is returned to the write operation module. After receiving the request, the write operation module writes the data in the [64k,96k] part to the disk and responds to Site 2.

[0102] Site 2 simultaneously receives a synchronous write request from Site 1 and sends version number 3 to the version number management module. This module detects that the remote version number is greater than the local version number and updates the local version number. The write operation module then sends the data to the conflict detection module. The conflict detection module reads version number 2 for data block 1 from the disk, indicating no conflict. Therefore, it returns a successful conflict detection result. Upon receiving this, the write operation module writes the data in the [0, 64k] range and version number 3 to the disk and responds to Site 1.

[0103] After Site 1 and Site 2 each receive a response from the other, the write operation for data block 1 is complete. Ultimately, Site 1 and Site 2 agree on the written content of data block 1: the data in the range [0, 64k] corresponds to version 3, and the data in the range [64k, 96k] corresponds to version 2.

[0104] Example 2

[0105] Corresponding to the above embodiment 1, the present application also provides a data writing system, such as Figure 3 As shown, specifically including:

[0106] The data preparation module 310 is configured to, in response to detecting a data write request initiated by a local site to a target data block, obtain a local version number currently maintained by the local site;

[0107] A data processing module 320 is configured to generate local metadata according to the local write operation range corresponding to the data write request and the local version number, and write the local data to be written in the data write request and the local metadata into the target data block;

[0108] The data processing module 320 is further configured to, in response to detecting that the local site has received a synchronous write request initiated by the remote site to the target data block, trigger the local site to respond to the synchronous write request, including:

[0109] Obtain the remote data to be written and remote metadata contained in the synchronous write request, wherein the remote metadata includes the remote write operation range corresponding to the synchronous write request and the remote version number currently maintained by the remote site; determine the target data to be written and the target write operation range corresponding to the synchronous write request based on the local metadata, remote metadata, the remote data to be written and preset rules, and write the target data to be written into the target write operation range to respond to the synchronous write request initiated by the remote site.

[0110] In some implementation scenarios, the data preparation module 310 is configured to generate a synchronous write request based on the local data to be written and the local metadata in response to detecting a data write request initiated by the local site to the target data block;

[0111] The synchronous write request generated by the local site is sent to the remote site.

[0112] In some implementation scenarios, the data processing module 320 is further used to determine whether the synchronous write request initiated by the local site to the target data block and the data write request initiated by the local site to the target data block pass the first write conflict verification based on the local version number in the local metadata and the remote version number in the remote metadata; if the first write conflict verification is passed, the remote data to be written is determined to be the target data to be written and the remote write operation range in the remote metadata is determined to be the target write operation range; if the first write conflict verification is not passed, the remote write operation range is determined based on the remote write operation range. and the local write operation range, determine whether the synchronous write request initiated by the local site to the target data block and the data write request initiated by the local site to the target data block pass the second write conflict verification; if they pass the second write conflict verification, determine that the remote data to be written is the target data to be written and determine that the remote write operation range is the target write operation range; if they fail the second write conflict verification, determine the target write operation range according to the remote write operation range and the local write operation range, and determine that the remote data to be written that matches the target write operation range is the target data to be written.

[0113] In some implementation scenarios, the data processing module 320 is also used to read the local serial number in the local version number and the remote serial number in the remote version number; if the local serial number is smaller than the remote serial number, it is determined that the first write conflict verification has passed; if the local serial number is greater than the remote serial number, it is determined that the first write conflict verification has not passed.

[0114] In some embodiment scenarios, the data processing module 320 is further used to obtain a local range start point and a local range end point corresponding to the local write operation range, and to obtain a remote range start point and a remote range end point corresponding to the remote write operation range; if the local range start point is greater than the remote range end point or the local range end point is less than the remote range start point, it is determined that the second write conflict verification has passed; if the local range start point is less than the remote range start point or the local range end point is greater than the remote range end point, it is determined that the second write conflict verification has not passed.

[0115] In some implementation scenarios, the data processing module 320 is also used for determining the target write operation range based on the remote write operation range and the local write operation range. The method includes: in response to detecting that the local range starting point is smaller than the remote range starting point and the local range end point is larger than the remote range end point, determining that the target write operation range does not exist; in response to detecting that the local range starting point is smaller than the remote range starting point and the local range end point is smaller than the remote range end point, determining that the target write operation range exists; in response to detecting that the local range starting point is larger than the remote range starting point and the local range end point is larger than the remote range end point, determining that the target write operation range exists.

[0116] In some implementation scenarios, the data processing module 320 is further configured to determine a target write operation range according to the remote write operation range and the local write operation range, including:

[0117] In response to detecting that the local range start point is smaller than the remote range start point and the local range end point is smaller than the remote range end point, determining a write operation range formed by the remote range start point and the local range end point as a target write operation range;

[0118] In response to detecting that the local range start point is larger than the remote range start point and the local range end point is larger than the remote range end point, a write operation range formed by the local range start point and the remote range end point is determined as a target write operation range.

[0119] Example 3

[0120] The present application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of the following method are implemented:

[0121] In response to detecting a data write request initiated by a local site to a target data block, obtaining a local version number currently maintained by the local site;

[0122] Generate local metadata according to the local write operation range corresponding to the data write request and the local version number, and write the local data to be written in the data write request and the local metadata into the target data block;

[0123] In response to detecting that the local site receives a synchronous write request initiated by the remote site to the target data block, triggering the local site to respond to the synchronous write request includes:

[0124] Acquire the remote data to be written and remote metadata contained in the synchronous write request, wherein the remote metadata includes a remote write operation range corresponding to the synchronous write request and a remote version number currently maintained by the remote site;

[0125] Based on the local metadata, remote metadata, the remote data to be written and preset rules, determine the target data to be written and the target write operation range corresponding to the synchronous write request, and write the target data to be written into the target write operation range to respond to the synchronous write request initiated by the remote site.

[0126] Example 4

[0127] Corresponding to all the above embodiments, an embodiment of the present application provides an electronic device, including: one or more processors; and a memory associated with the one or more processors, the memory being configured to store program instructions. When the program instructions are read and executed by the one or more processors, the program instructions perform the following operations:

[0128] In response to detecting a data write request initiated by a local site to a target data block, obtaining a local version number currently maintained by the local site;

[0129] Generate local metadata according to the local write operation range corresponding to the data write request and the local version number, and write the local data to be written in the data write request and the local metadata into the target data block;

[0130] In response to detecting that the local site receives a synchronous write request initiated by the remote site to the target data block, triggering the local site to respond to the synchronous write request includes:

[0131] Acquire the remote data to be written and remote metadata contained in the synchronous write request, wherein the remote metadata includes a remote write operation range corresponding to the synchronous write request and a remote version number currently maintained by the remote site;

[0132] Based on the local metadata, remote metadata, the remote data to be written and preset rules, determine the target data to be written and the target write operation range corresponding to the synchronous write request, and write the target data to be written into the target write operation range to respond to the synchronous write request initiated by the remote site.

[0133] in, Figure 4 The electronic device architecture is shown as an example, and may include a processor 410, a video display adapter 411, a disk drive 412, an input / output interface 413, a network interface 414, and a memory 420. The processor 410, the video display adapter 411, the disk drive 412, the input / output interface 413, the network interface 414, and the memory 420 may be communicatively connected via a bus 430.

[0134] Among them, the processor 410 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, etc., to execute relevant programs to implement the technical solutions provided in this application.

[0135] The memory 420 can be implemented in the form of ROM (Read Only Memory, programmable memory), RAM (Random Access Memory, random access memory), static storage device, dynamic storage device, etc. The memory 420 can store an operating system 421 for controlling the execution of the electronic device 400, and a basic input and output system (BIOS) 422 for controlling the low-level operations of the electronic device 400. In addition, a web browser 423, a data storage management system 424, and an icon font processing system 425, etc. can also be stored. The above-mentioned icon font processing system 425 can be an application program that specifically implements the operations of the aforementioned steps in the embodiment of the present application. In short, when the technical solution provided by the present application is implemented by software or firmware, the relevant program code is stored in the memory 420 and is called and executed by the processor 410.

[0136] The input / output interface 413 is used to connect input / output modules to implement information input and output. The input / output modules can be configured as components in the device (not shown in the figure) or can be externally connected to the device to provide corresponding functions. Input devices may include a keyboard, mouse, touch screen, microphone, various sensors, etc., and output devices may include a display, speaker, vibrator, indicator light, etc.

[0137] The network interface 414 is used to connect to a communication module (not shown) to enable communication between the device and other devices. The communication module can communicate via a wired method (such as USB, network cable, etc.) or a wireless method (such as mobile network, WiFi, Bluetooth, etc.).

[0138] The bus 430 comprises a pathway for transmitting information between the various components of the device (eg, the processor 410 , the video display adapter 411 , the disk drive 412 , the input / output interface 413 , the network interface 414 , and the memory 420 ).

[0139] In addition, the electronic device 400 can also obtain information on specific collection conditions from the virtual resource object collection condition information database for use in condition judgment, etc.

[0140] It should be noted that although the above device only shows the processor 410, video display adapter 411, disk drive 412, input / output interface 413, network interface 414, memory 420, bus 430, etc., in the specific implementation process, the device may also include other components necessary for normal execution. In addition, those skilled in the art will understand that the above device may also include only the components necessary to implement the solution of the present application, and does not necessarily include all the components shown in the figure.

[0141] Through the description of the above implementation methods, it can be seen that those skilled in the art can clearly understand that the present application can be implemented by means of software plus the necessary general hardware platform. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a cloud service terminal, or a network device, etc.) to execute the methods of each embodiment of the present application or certain parts of the embodiments.

[0142] Example 5

[0143] Corresponding to all the above embodiments, an embodiment of the present application further provides a computer-readable storage medium, characterized in that it stores a computer program that causes a computer to perform the following operations:

[0144] In response to detecting a data write request initiated by a local site to a target data block, obtaining a local version number currently maintained by the local site;

[0145] Generate local metadata according to the local write operation range corresponding to the data write request and the local version number, and write the local data to be written in the data write request and the local metadata into the target data block;

[0146] In response to detecting that the local site receives a synchronous write request initiated by the remote site to the target data block, triggering the local site to respond to the synchronous write request includes:

[0147] Acquire the remote data to be written and remote metadata contained in the synchronous write request, wherein the remote metadata includes a remote write operation range corresponding to the synchronous write request and a remote version number currently maintained by the remote site;

[0148] Based on the local metadata, remote metadata, the remote data to be written and preset rules, determine the target data to be written and the target write operation range corresponding to the synchronous write request, and write the target data to be written into the target write operation range to respond to the synchronous write request initiated by the remote site.

[0149] Each embodiment in this specification is described in a progressive manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for system or system embodiments, since they are basically similar to method embodiments, the description is relatively simple. For relevant parts, refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without making any creative efforts.

[0150] The above are only preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.

Claims

1. A data writing method, characterized in that: The method comprises: In response to detecting a data write request initiated by a local site to a target data block, obtaining a local version number currently maintained by the local site; Generate local metadata according to the local write operation range corresponding to the data write request and the local version number, and write the local data to be written in the data write request and the local metadata into the target data block; In response to detecting that the local site receives a synchronous write request initiated by the remote site to the target data block, triggering the local site to respond to the synchronous write request includes: Acquire the remote data to be written and remote metadata contained in the synchronous write request, wherein the remote metadata includes a remote write operation range corresponding to the synchronous write request and a remote version number currently maintained by the remote site; Determining target data to be written and a target write operation range corresponding to the synchronous write request according to the local metadata, the remote metadata, the remote data to be written, and a preset rule, and writing the target data to be written into the target write operation range to respond to the synchronous write request initiated by the remote site, including: determining, based on the local version number in the local metadata and the remote version number in the remote metadata, whether the synchronous write request initiated to the target data block and received by the local site and the data write request initiated by the local site to the target data block pass a first write conflict verification; If the first write conflict verification is passed, determining the remote data to be written as the target data to be written and determining the remote write operation range in the remote metadata as the target write operation range; If the first write conflict verification fails, determining, based on the remote write operation range and the local write operation range, whether the synchronous write request initiated to the target data block received by the local site and the data write request initiated to the target data block by the local site pass a second write conflict verification; If the second write conflict verification is passed, determining the remote data to be written as the target data to be written and determining the remote write operation range as the target write operation range; If the second write conflict verification fails, determining a target write operation range according to the remote write operation range and the local write operation range, and determining the remote data to be written that matches the target write operation range as the target data to be written; Determining whether the first write conflict verification is passed includes: Read the local serial number in the local version number and the remote serial number in the remote version number; If the local sequence number is smaller than the remote sequence number, it is determined that the first write conflict verification is passed; If the local sequence number is greater than the remote sequence number, it is determined that the first write conflict verification fails; Determining whether the second write conflict verification is passed includes: Acquire a local range start point and a local range end point corresponding to the local write operation range, and acquire a remote range start point and a remote range end point corresponding to the remote write operation range; If the local range start point is greater than the remote range end point or the local range end point is less than the remote range start point, determining that the second write conflict verification is passed; If the local range start point is smaller than the remote range start point or the local range end point is larger than the remote range end point, it is determined that the second write conflict verification fails.

2. The method according to claim 1, characterized in that The method further comprises: In response to detecting a data write request initiated by the local site to the target data block, generating a synchronous write request according to the local data to be written and the local metadata; The synchronous write request generated by the local site is sent to the remote site.

3. The method according to claim 1, characterized in that Before determining the target write operation range according to the remote write operation range and the local write operation range, the method includes: In response to detecting that the local range start point is smaller than the remote range start point and the local range end point is larger than the remote range end point, determining that the target write operation range does not exist; In response to detecting that the local range start point is smaller than the remote range start point and the local range end point is smaller than the remote range end point, determining that the target write operation range exists; In response to detecting that the local range start point is greater than the remote range start point and the local range end point is greater than the remote range end point, it is determined that the target write operation range exists.

4. The method according to claim 3, characterized in that The determining a target write operation range according to the remote write operation range and the local write operation range includes: In response to detecting that the local range start point is smaller than the remote range start point and the local range end point is smaller than the remote range end point, determining a write operation range formed by the remote range start point and the local range end point as a target write operation range; In response to detecting that the local range start point is larger than the remote range start point and the local range end point is larger than the remote range end point, a write operation range formed by the local range start point and the remote range end point is determined as a target write operation range.

5. A data writing system, characterized in that: The system comprises: a data preparation module, configured to, in response to detecting a data write request initiated by a local site to a target data block, obtain a local version number currently maintained by the local site; A data processing module, configured to generate local metadata according to a local write operation range corresponding to the data write request and the local version number, and write the local data to be written in the data write request and the local metadata into the target data block; The data processing module is further configured to, in response to detecting that the local site receives a synchronous write request initiated by the remote site to the target data block, trigger the local site to respond to the synchronous write request, including: Acquire the remote data to be written and remote metadata contained in the synchronous write request, wherein the remote metadata includes a remote write operation range corresponding to the synchronous write request and a remote version number currently maintained by the remote site; Determining target data to be written and a target write operation range corresponding to the synchronous write request based on the local metadata, the remote metadata, the remote data to be written, and a preset rule, and writing the target data to be written into the target write operation range to respond to the synchronous write request initiated by the remote site; The data processing module is further used to: determining, based on the local version number in the local metadata and the remote version number in the remote metadata, whether the synchronous write request initiated to the target data block and received by the local site and the data write request initiated by the local site to the target data block pass a first write conflict verification; If the first write conflict verification is passed, determining the remote data to be written as the target data to be written and determining the remote write operation range in the remote metadata as the target write operation range; If the first write conflict verification fails, determining, based on the remote write operation range and the local write operation range, whether the synchronous write request initiated to the target data block received by the local site and the data write request initiated to the target data block by the local site pass a second write conflict verification; If the second write conflict verification is passed, determining the remote data to be written as the target data to be written and determining the remote write operation range as the target write operation range; If the second write conflict verification fails, determining a target write operation range according to the remote write operation range and the local write operation range, and determining the remote data to be written that matches the target write operation range as the target data to be written; The data processing module is further configured to determine whether the first write conflict verification is passed, including: Read the local serial number in the local version number and the remote serial number in the remote version number; If the local sequence number is smaller than the remote sequence number, it is determined that the first write conflict verification is passed; If the local sequence number is greater than the remote sequence number, it is determined that the first write conflict verification fails; The data processing module is further configured to determine whether the second write conflict verification is passed, including: Acquire a local range start point and a local range end point corresponding to the local write operation range, and acquire a remote range start point and a remote range end point corresponding to the remote write operation range; If the local range start point is greater than the remote range end point or the local range end point is less than the remote range start point, determining that the second write conflict verification is passed; If the local range start point is smaller than the remote range start point or the local range end point is larger than the remote range end point, it is determined that the second write conflict verification fails.

6. An electronic device, characterized in that: The electronic device comprises: one or more processors; and a memory associated with the one or more processors, wherein the memory is used to store program instructions, and when the program instructions are read and executed by the one or more processors, the method according to any one of claims 1 to 4 is executed.

7. A computer-readable storage medium, characterized in that The computer program stores a computer program, which enables a computer to execute the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Method and device for synchronizing editions during cache management and cache management system

    CN102098344A

  • Data synchronization method, system and device, computer equipment and storage medium

    CN118151857A