Data processing method, system, equipment and medium

By detecting and verifying the local and remote site version numbers in the dual-live architecture storage system, generating metadata and determining the write operation range, the write conflict problem in the dual-live architecture is solved, and system performance and data consistency are improved.

CN119148942AActive Publication Date: 2024-12-17INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The write conflicts in the dual-live architecture storage system caused by the data writing of two sites to a data block at the same time lead to performance bottlenecks and deadlock risks, and the existing pessimistic locking methods are difficult to effectively solve.

Method used

By detecting the version numbers of local and remote sites, generating metadata and performing multi-level write conflict verification, determining the target data to be written and the write operation range to ensure data consistency and concurrency performance.

Benefits of technology

It effectively resolves 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 CN119148942A_ABST
    Figure CN119148942A_ABST
Patent Text Reader

Abstract

The invention provides a data writing method, system and device and a medium, and the method comprises the steps: obtaining a local version number currently maintained by a local site in response to the detection of a data writing request initiated by the local site to a target data block; generating local metadata according to a local write operation range and a local version number corresponding to the data write request, and writing local to-be-written data in the data write request and the local metadata into a 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, comprising the following steps: acquiring remote to-be-written data and remote metadata contained in the synchronous write request; and according to the local metadata, the far-end metadata, the far-end to-be-written data and a preset rule, determining target to-be-written data corresponding to the synchronous write request and a target write operation range, and writing the target to-be-written data into the target write operation range. The write conflict problem is solved, and the concurrency performance is improved.
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 processing method, system and device. Background Art

[0002] In existing centralized storage systems, in order to improve system availability, fault tolerance, and read / write performance, storage systems with active-active architecture are deployed in some business scenarios. That is, two storage systems provide read / write services at the same time 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 simultaneously receive write operations for the same data block, write conflicts may 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 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 includes:

[0010] Acquire the remote data to be written and the 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;

[0011] Based on the local metadata, remote metadata, the 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.

[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, according to 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 the data write request initiated to the target data block by the local site 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, judging whether the synchronous write request initiated to the target data block and the data write request initiated to the target data block by the local site and received by the local site pass the second write conflict verification according to the remote write operation range and the local write operation range;

[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, judging, according to 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 received by the local site and the data write request initiated to the target data block by the local site pass the 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 has not passed.

[0025] In some embodiments, the root determines, according to 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 the 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, it is determined 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 has not been passed.

[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, determining a write operation range formed by the local range start point and the remote range end point 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 obtain a local version number currently maintained by the local site in response to detecting a data write request initiated by the local site to the target data block;

[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 the 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;

[0041] Based on the local metadata, remote metadata, the 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.

[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 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 includes:

[0046] Acquire the remote data to be written and the 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;

[0047] Based on the local metadata, remote metadata, the 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.

[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 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 includes:

[0054] Acquire the remote data to be written and the 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;

[0055] Based on the local metadata, remote metadata, the 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.

[0056] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program enables 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 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 includes:

[0060] Acquire the remote data to be written and the 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;

[0061] Based on the local metadata, remote metadata, the 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.

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

[0063] The present application provides a data writing method, 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 according to 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, including: obtaining the remote data to be written and the 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 according to the local metadata, the remote metadata, the remote data to be written and the 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 write conflict problem in the storage active-active system is solved, the possible deadlock risk is avoided, the concurrency performance of the system is improved, and the data consistency on the two sites is guaranteed. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work, among which:

[0065] Figure 1 It 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 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0069] In order to make the purpose, technical solutions and advantages of this application clearer, 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 them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0070] It should be understood that in the description of the present application, unless the context clearly requires otherwise, words such as "include", "comprises", and the like in the entire specification and claims should be interpreted as having an inclusive meaning rather than an exclusive or exhaustive meaning; that is, the meaning of "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, "plurality" means two or more.

[0072] It should be noted that the terms "S1", "S2", etc. are only used for the purpose of describing the steps, and do not specifically refer to the order or sequence, nor are they used to limit the present application. They are only for the convenience of describing the method of the present application, and cannot 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 they must be based on the ability of ordinary technicians in this field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by the present application.

[0073] Currently, the pessimistic locking method is mainly used to solve the data write conflict problem caused by two sites writing data to a data block at the same time in the active-active storage system. The data block is locked between write operations to prevent other write operations from being carried out, ensuring that only one site can read and write the data block at any time, thereby avoiding data inconsistency caused by concurrent writes. However, this method has obvious disadvantages and is prone to cause storage performance bottlenecks and deadlock problems, especially in high-concurrency active-active storage systems.

[0074] Embodiment 1

[0075] The present application embodiment provides a data writing method, which is applied to a storage system under a dual-active architecture. Specifically, the method disclosed in the present application embodiment 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 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 according to the local data to be written and the 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, the local site generates a synchronous write request according to the local data to be written and the 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, triggering the local site to respond to the synchronous write request.

[0082] The specific local site responds to the synchronous write request specifically including: 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] In the method disclosed in the present application, a multi-level write conflict judgment logic is set, which greatly improves the efficiency and accuracy of write conflict judgment. Among them, according to 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 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 the first write conflict verification.

[0085] Specifically, in some implementation scenarios, the above-mentioned method of judging 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 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 not been passed. It can be understood that both the local site and the remote site maintain an incremental version number corresponding to the data block, which includes the globally unique serial number of this data block and the site identifier; it is achieved to ensure 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, according to the above content, each time a data write request issued by a site is responded to, the data to be written (i.e., the data to be written) and the version number of this write operation will be synchronously transmitted to the other site to ensure that the two sites can know the latest data version of each 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 serial number in the latest version number of the data block maintained in the remote site corresponding to the synchronous write request, and further compare it with the serial number in the locally maintained version number to quickly determine whether there is a write conflict, which greatly speeds up the judgment speed 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 determined 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, judging whether a synchronous write request initiated to a target data block and a data write request initiated to the target data block by the local site and received by the local site passes the second write conflict verification according to the remote write operation range and the local write operation range includes:

[0088] Get the local range start point and the local range end point corresponding to the local write operation range, and get the remote range start point and the 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 can be understood that when it is detected that the starting point of the local range is smaller than the starting point of the remote range and the end point of the local range is larger than the end point of the remote range, 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 that has been written after the local site responds to the data write request initiated by the data block. At this time, there is no need to respond to the synchronous write request initiated by the remote site, and the instruction or information of the completion of the synchronous write operation is directly fed back to the remote site, so that the remote site confirms the completion of the synchronous write request and further confirms 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 included in the write conflict, 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 can be understood 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 and the near-end write operation range contained in the synchronous write request is obtained, and the remote data to be written is written into the target range.

[0094] Among them, the above-mentioned determining 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, the present application also proposes to establish a patrol mechanism, which reads the version number of each data block in the local site and the version number of each data block in the remote site at every preset time interval; by comparing the version number of the data block in the local site with the version number of the data block in the remote site, it is quickly confirmed whether the data in the data blocks in the local site and the remote site are consistent at the current time node. If inconsistent, an alarm prompt is triggered, wherein the alarm prompt at least includes the version number of the inconsistent version and the corresponding data block, so that the user can find the corresponding difference data based on the version number and the data block, and re-initiate a synchronous write request after determining the difference data, so as to further ensure the consistency of the data written by the remote site and the local site.

[0096] This application avoids possible deadlock problems by comparing version numbers before and after write operations. Furthermore, by allowing multiple write operations to be performed in parallel, the version number is checked and updated only when data is actually written, thereby improving the concurrency and overall performance of the system. In addition, the version number mechanism ensures the uniqueness and order of the results of the write operations on the two sites, thereby ensuring the consistency of data in the active-active system.

[0097] The specific examples are described below. Figure 2 As shown in the figure, the storage active-active 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 judging whether a write operation has a conflict through the local version number and the version number attached to the remote synchronous write. Conflict resolution module: mainly responsible for resolving the conflict between two write operations in the event of a conflict, to ensure that the data finally written by the two sites is consistent.

[0099] Site 1 receives a data write request for the [0,64k] range of data block 1 from this site. After receiving the 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 3 and increases the version number by 1. The write operation module writes the data in the [0,64k] range and version number 3 to the disk and forwards the data and version number 3 to site 2. It can be understood that here, site 1 is a local site relative to site 2, and site 2 is a remote site.

[0100] At the same time, site 2 receives the data write request for the data block 1 in the range of [32k, 96k] from this site. 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 increases the version number by 1. The write operation module writes the data in the range of [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 here, site 2 is a local site relative to site 1, and site 1 is a remote site.

[0101] Site 1 receives the synchronous write request from Site 2 and sends the version number to the version number management module. The module finds that the remote version number is smaller than the local version number and will not update the local version number. Then, the write operation module sends the data to the conflict detection module. The conflict detection module reads the version number of data block 1 from the disk as 3, indicating a conflict, so it returns the 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 high version write is [0,64k], while the operation range of the low version synchronous write request is [32k,96k]. Therefore, the data in the synchronous write operation with a range of [64k,96k] is returned to the write operation module. After receiving the request, the write operation module writes the [64k,96k] part of the data to the disk and responds to Site 2.

[0102] Site 2 also receives the synchronous write request from Site 1 and sends the version number 3 to the version number management module. The module finds that the remote version number is larger than the local version number and updates the local version number. Then, the write operation module sends the data to the conflict detection module. The conflict detection module reads the version number of data block 1 from the disk as 2, indicating that no conflict occurs, so it returns the result of successful conflict detection. After receiving the write operation module, it writes the data in the range [0,64k] and version number 3 to the disk and responds to Site 1.

[0103] After site 1 and site 2 receive each other's response, it indicates that the write operation for data block 1 is completed. Finally, the written content of data block 1 is consistent on site 1 and site 2, that is, the data in the range of [0,64k] corresponds to version number 3, and the data in the range of [64k,96k] corresponds to version number 2.

[0104] Embodiment 2

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

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

[0107] A data processing module 320, 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 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:

[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 used to generate a synchronous write request according to 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 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 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; 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, determining 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 the second write conflict verification; if they pass the second write conflict verification, 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 they do not pass the second write conflict verification, determining the 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.

[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 judged that the first write conflict verification has passed; if the local serial number is greater than the remote serial number, it is judged that the first write conflict verification has not passed.

[0114] In some embodiment scenarios, the data processing module 320 is also 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, 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.

[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, determining a write operation range formed by the local range start point and the remote range end point as a target write operation range.

[0119] Embodiment 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 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 includes:

[0124] Acquire the remote data to be written and the 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;

[0125] Based on the local metadata, remote metadata, the 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.

[0126] Embodiment 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 is used to store program instructions, and when the program instructions are read and executed by the one or more processors, the following operations are performed:

[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 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 includes:

[0131] Acquire the remote data to be written and the 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;

[0132] Based on the local metadata, remote metadata, the 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.

[0133] in, Figure 4 The architecture of the electronic device is exemplarily shown, which 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 (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solution provided in this application.

[0135] The memory 420 can be implemented in the form of ROM (Read Only Memory), RAM (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 in 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 the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.

[0137] The network interface 414 is used to connect to a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (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 a processor 410, a video display adapter 411, a disk drive 412, an input / output interface 413, a network interface 414, a memory 420, a bus 430, etc., in the specific implementation process, the device may also include other components necessary for normal execution. In addition, it can be understood by those skilled in the art that the above device may also only include components necessary for implementing the solution of the present application, and does not necessarily include all the components shown in the figure.

[0141] It can be seen from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution of the present application can essentially or in other words, 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 disk, an optical disk, etc., including several instructions for a computer device (which can be a personal computer, a cloud service end, or a network device, etc.) to execute the methods of various embodiments of the present application or certain parts of the embodiments.

[0142] Embodiment 5

[0143] Corresponding to all the above embodiments, the embodiments of the present application further provide a computer-readable storage medium, characterized in that it stores a computer program, and the computer program enables 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 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 includes:

[0147] Acquire the remote data to be written and the 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;

[0148] Based on the local metadata, remote metadata, the 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.

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

[0150] The above are only preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope 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 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 includes: Acquire the remote data to be written and the 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; Based on the local metadata, remote metadata, the 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.

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 The determining, according to the local metadata, the remote metadata, the remote data to be written, and the preset writing rule, the target data to be written and the target write operation range corresponding to the synchronous write request includes: Determining, according to 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 the data write request initiated to the target data block by the local site 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, judging whether the synchronous write request initiated to the target data block and the data write request initiated to the target data block by the local site and received by the local site pass the second write conflict verification according to the remote write operation range and the local write operation range; 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, 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.

4. The method according to claim 3, characterized in that: The determining, according to 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 received by the local site and the data write request initiated to the target data block by the local site pass the first write conflict verification 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 has not passed.

5. The method according to claim 3, characterized in that: The root determines, according to the remote write operation range and the local write operation range, whether the synchronous write request initiated to the target data block and the data write request initiated to the target data block by the local site pass the second write conflict verification, 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, it is determined 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 has not been passed.

6. The method according to claim 5, 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.

7. The method according to claim 6, 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, determining a write operation range formed by the local range start point and the remote range end point as a target write operation range.

8. A data writing system, characterized in that: The system comprises: A data preparation module, configured to obtain a local version number currently maintained by the local site in response to detecting a data write request initiated by the local site to the target data block; 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 the 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; Based on the local metadata, remote metadata, the 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.

9. An electronic device, characterized in that: The electronic device comprises: one or more processors; And a memory associated with the one or more processors, 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-7 is executed.

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

Citation Information

Patent Citations

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

    CN102098344A

  • Method and system for solving data collision

    CN106802939A

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

    CN118151857A

  • Metadata backup method and system, storage medium and electronic device

    CN118519828A