Write-in conflict processing method and device, equipment, medium and program product
By reading and analyzing service identifier information, the master service election mechanism resolves the problem of write conflicts when multiple backend services share resources, thus achieving data consistency and system reliability under network failures.
Patent Information
- Application Number
- CN202511081813.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-04
- Publication Date
- 2025-11-18
AI Technical Summary
In high-reliability business systems, write conflicts are prone to occur when multiple backend service software share resources for writing, especially when network failures occur, making it difficult to effectively avoid redundant writes, leading to data inconsistency and security risks.
By reading service identifier information from shared resources, including heartbeat words, working status, primary service identifier, and requesting primary service identifier, a primary service is identified and elected. An election mechanism is used to coordinate write operations among redundant services to avoid conflicts.
It effectively avoids write conflicts caused by network failures between services, ensuring data consistency and system reliability, and is suitable for multi-service collaborative processing scenarios.
Smart Images

Figure CN120973433A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, and in particular, to a write conflict processing method and device, equipment, medium and program product. BACKGROUND
[0002] With the development of Internet technology, more and more enterprises handle business through electronic services. Many businesses need to be handled by multiple background service software, and the processing results are written into storage resources. The system has high reliability requirements for these background service software, and in the case of a single fault point, it is not allowed to affect the normal service function.
[0003] Therefore, for businesses with high reliability requirements, the background service usually adopts two or more hot standby redundant operation modes. Therefore, in the process of writing results into the same shared resource, the problem of write conflict needs to be solved.
[0004] The common way to avoid write conflict in the prior art is that the two services are connected through a heartbeat line and communicate to determine the master service. When the service is running, if it is found that the other party cannot be connected, it is considered that the other party is not running, and the self is automatically set as the master service for data writing. When the network has problems, the scenario of two services writing at the same time may occur, and it cannot be extended to the multi-service cooperative processing scenario. SUMMARY
[0005] The present application provides a write conflict processing method, device, equipment, medium and program product to solve the problem of redundant writing when the communication between services fails.
[0006] According to an aspect of the present application, a write conflict processing method is provided, comprising:
[0007] reading service flag information of a redundant service associated with the service in a shared resource; the service flag information includes a heartbeat word, a working state, a master service flag, an application master service flag, and a master service election flag;
[0008] determining whether there is a master service in a normal working state in the redundant service based on the heartbeat word and the working state in the service flag information;
[0009] If there is no master service in a normal working state, at least one application redundant service that initiates a master service application in a redundant service in a normal working state is obtained according to the application service flag in the service flag information;
[0010] According to the service flag information of the application redundant service, a target service that meets the master service condition is determined in at least one application redundant service, and the target service is elected as the master service by updating the master service election flag in the service flag information of the service.
[0011] According to another aspect of the present application, there is provided a write conflict processing apparatus, comprising:
[0012] a flag information obtaining module configured to read service flag information of a redundant service associated with the service in a shared resource, the service flag information comprising a heartbeat word, an operating state, a primary service flag, a primary service application flag, and a primary service election flag;
[0013] a primary service determining module configured to determine whether there is a primary service in a normal operating state in the redundant service based on the heartbeat word and the operating state in the service flag information;
[0014] an application service obtaining module configured to, if there is no primary service in a normal operating state, obtain at least one application redundant service in a normal operating state that initiates a primary service application in the redundant service according to the primary service application flag in the service flag information;
[0015] a primary service election module configured to determine a target service that meets a primary service condition in the at least one application redundant service according to the service flag information of the application redundant service, and elect the target service as the primary service by updating the primary service election flag in the service flag information of the service.
[0016] According to another aspect of the present application, there is provided an electronic device, comprising:
[0017] at least one processor; and
[0018] a memory communicatively connected to the at least one processor; wherein,
[0019] the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the write conflict processing method according to any one of the embodiments of the present application.
[0020] According to another aspect of the present application, there is provided a computer readable storage medium storing computer instructions for enabling a processor to perform the write conflict processing method according to any one of the embodiments of the present application.
[0021] According to another aspect of the present application, there is provided a computer program product comprising a computer program for enabling a processor to perform the write conflict processing method according to any one of the embodiments of the present application.
[0022] The technical scheme of the embodiment of the application reads service mark information of a redundant service associated with the service in a shared resource, the service mark information includes a heartbeat word, a working state, a primary service mark, a primary service application mark and a primary service election mark, determines whether there is a primary service in a normal working state in the redundant service based on the heartbeat word and the working state in the service mark information, if there is no primary service in a normal working state, acquires at least one application redundant service which initiates a primary service application in the redundant service in a normal working state according to the primary service application mark in the service mark information, determines a target service which meets a primary service condition in the at least one application redundant service according to the service mark information of the application redundant service, and elects the target service as the primary service by updating the primary service election mark in the service mark information of the service, writes the service mark information of each service into the shared resource, and determines a new primary service by election in the case of failure of the original primary service, thereby avoiding write conflict caused by network failure between services.
[0023] It should be understood that the content described in this part is not intended to identify key or important features of the embodiments of the application, nor is it used to limit the scope of the application. Other features of the application will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the application, the drawings needed in the embodiment description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the application, and other drawings can be obtained by those skilled in the art without creative labor.
[0025] Figure 1 is a flow chart of a write conflict processing method according to the first embodiment of the application;
[0026] Figure 2a is a flow chart of a write conflict processing method according to the second embodiment of the application;
[0027] Figure 2b is a flow chart of primary service election according to the second embodiment of the application;
[0028] Figure 3 is a structural schematic diagram of a write conflict processing device according to the third embodiment of the application;
[0029] Figure 4 is a structural schematic diagram of an electronic device for implementing the write conflict processing method of the embodiment of the application. DETAILED DESCRIPTION
[0030] In the following, the technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of embodiments of the present application, rather than all embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work should fall within the protection scope of the present application.
[0031] It should be noted that the terms "first", "second", and the like in the description and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not necessarily have to include only those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to the process, method, product or device.
[0032] Embodiment one
[0033] Figure 1 A flowchart of a write conflict processing method is provided for the first embodiment of the present application. The present embodiment can be applied to the case where the primary service is determined by multi-service election. The method can be executed by a write conflict processing device, which can be implemented in the form of hardware and / or software, and can be configured in various general-purpose computing devices. As shown in the figure, the method comprises: Figure 1
[0034] S110, reading service flag information of a redundant service associated with the service in the shared resource; the service flag information includes a heartbeat word, a working state, a primary service flag, an application primary service flag, and a primary service election flag.
[0035] For services with high reliability requirements, the background service usually adopts a redundant operation mode of two or more services. Therefore, in the process of writing results into the same shared resource, the problem of write conflict needs to be solved.
[0036] The shared resource is a storage area shared by the service and at least one redundant service associated with the service. In order to enable each service to obtain the working state of other redundant services, a setting space can be divided in the shared resource for storing service flag information of each service. The service flag information of each service includes a heartbeat word, a working state, a primary service flag, an application primary service flag and a primary service election flag. Each service can read the service flag information of other services in the shared resource, but the service flag information of each service is only written by the service itself.
[0037] In a specific example, a specific space in the shared resource is determined for storing a service flag information table. The service flag information table stores service flag information of each service. Each service is previously set with a service number, and the service number is included in the variable name in the service flag information table so that the service can determine the service flag information of each service in the service flag information table according to the service number. For example, the variable name of the service with the service number 1 in the service flag information table is shown in Table 1.
[0038] Table 1
[0039]
[0040]
[0041] The number "1" included in the variable name in the service flag information is used to determine that the variable corresponds to the service with the service number 1. The heartbeat word is an integer value starting from 0, increasing to a set value (for example, 10000) and then returning to 0, and then increasing from 0 again. The working state is a Boolean value, and the working state is 1 when the service is in a normal working state, and the working state is 0 when the service is in an abnormal state. The primary service flag is a Boolean value, and the primary service flag is 1 when the service is running as a primary service, and the primary service flag is 0 when the service is running as a backup service. In order to avoid redundant writing, only the primary service writes business data to the shared resource. The application primary service flag is a Boolean value, and the application primary service flag is 1 when the service is applying to be a primary service, and the application primary service flag is 0 when the service is not applying to be a primary service. The primary service election flag is an integer value used to indicate the service number of the service that agrees to be a primary service.
[0042] In the embodiment of the application, after the service is started, the service flag information of the service is accessed first to clear all data to 0, and after it is determined that the service is in a normal working state, the working state in the service flag information of the service is set to 1, and the heartbeat word is written from 0 according to a set period. Further, the service flag information of the redundant service associated with the service is read in the shared resource to determine the working state of each redundant service according to the service flag information of other redundant services.
[0043] S120, determining whether there is a main service in a normal working state in the redundant services based on the heartbeat word and the working state in the service mark information.
[0044] In the embodiment of the application, the redundant service in a normal working state is determined in all redundant services based on the heartbeat word and the working state in the service mark information of each redundant service. Specifically, the heartbeat word is incremented according to a set period, and the redundant service is determined to be in a normal working state when the working state is 1.
[0045] Further, if there is at least one redundant service in a normal working state in the associated redundant services, the service mark information of each redundant service in a normal working state is further determined to see whether there is a main service. Specifically, whether it is a main service is determined by reading the main service mark in the service mark information of each redundant service in a normal working state.
[0046] In addition, if there is no redundant service in a normal working state in the associated redundant services, the service can be directly run as a main service. Specifically, the main service mark in the service mark information of the service is directly set to 1, so that the corresponding business operation is performed, and the business data is written into the shared resource.
[0047] S130, if there is no main service in a normal working state, at least one application redundant service in a normal working state that initiates a main service application is obtained according to the application service mark in the service mark information.
[0048] In many scenarios where redundant services need to be run, redundant writing needs to be strictly avoided. For example, in the field of train integrated monitoring, redundant writing redundancy leads to incorrect control instructions, resulting in safety accidents.
[0049] In the embodiment of the application, if there is no main service in a normal working state, the main service is determined by the way of election to avoid redundant writing. The application service mark in the service mark information of each redundant service in a normal working state is read to obtain at least one application redundant service in a normal working state that initiates a main service application. Specifically, if the application service mark of the redundant service in a normal working state is 1, it indicates that it is applying to be a main service, and the redundant service that is applying to be a main service is referred to as an application redundant service.
[0050] S140, a target service that meets the main service condition is determined in the at least one application redundant service according to the service mark information of the application redundant service, and the target service is elected as a main service by updating the main service election mark in the service mark information of the service.
[0051] In the embodiment of the present application, in order to avoid conflict writing, in the scenario of multiple redundancy services working together, the main service is determined in an election manner. According to the service mark information of the redundancy service and the pre-set election rule, the target service meeting the main service condition is determined in at least one redundancy service, and the target service is elected as the main service by updating the main service election mark in the service mark information of the present service. The election rule can be that the main service is elected according to the service number of the redundancy service in a large number priority or small number priority manner.
[0052] In addition, if there is no redundancy service or none of the redundancy services meets the main service condition, the present service can be applied as the main service by setting the application main service mark bit to 1.
[0053] In a specific example, the election rule can be that the main service is elected according to the service number of the redundancy service in a large number priority manner, wherein the service number of the present service is 3, and the service numbers of the two redundancy services are 4 and 6 respectively by parsing the variable names corresponding to the two redundancy services. Further, the service numbers of the two redundancy services are compared with the service number of the present service respectively. If the service number of the redundancy service is greater than the service number of the present service, the redundancy service with the largest service number is selected to vote in the redundancy service. Specifically, the main service election mark of the present service is updated to vote for the largest service number in the redundancy service.
[0054] The technical solution of the embodiment of the present application reads the service mark information of the redundancy service associated with the present service in the shared resource, the service mark information includes a heartbeat word, a working state, a main service mark, an application main service mark and a main service election mark, determines whether there is a main service in the normal working state in the redundancy service based on the heartbeat word and the working state in the service mark information, if there is no main service in the normal working state, at least one redundancy service initiating the main service application in the redundancy service in the normal working state is obtained according to the application service mark in the service mark information, the target service meeting the main service condition is determined in at least one redundancy service according to the service mark information of the redundancy service, and the target service is elected as the main service by updating the main service election mark in the service mark information of the present service. The service mark information of each service is written into the shared resource, and in the case of original main service failure, the new main service is determined in an election manner, which avoids the writing conflict caused by network failure between services.
[0055] Embodiment two
[0056] Figure 2aA flow chart of a write conflict processing method provided for the second embodiment of the present application, the embodiment is further refined on the basis of the above-mentioned embodiment, and provides specific steps of determining a target service meeting the master service condition in at least one application redundancy service according to the service mark information of the application redundancy service, and electing the target service as the master service by updating the master service election mark in the service mark information of the present service. As shown in Figure 2a The method comprises the following steps.
[0057] S210, reading the service mark information of the redundancy service associated with the present service in the shared resource; the service mark information comprises a heartbeat word, an operating state, a master service mark, an application master service mark, and a master service election mark.
[0058] Optionally, before reading the service mark information of the redundancy service associated with the present service in the shared resource, the method further comprises the following steps.
[0059] clearing the data in the service mark information of the present service in the shared resource;
[0060] detecting the operating state of the present service, and updating the operating state in the service mark information of the present service if the operating state is normal;
[0061] updating the heartbeat word in the service mark information of the present service according to a set write period.
[0062] In the optional embodiment, the specific steps before reading the service mark information of the redundancy service associated with the present service in the shared resource are provided, as shown in Figure 2b After the present service is started, the data in the service mark information of the present service in the shared resource is first cleared, then the operating state of the present service is detected, and the operating state in the service mark information of the present service is updated if the operating state is normal, and the heartbeat word in the service mark information of the present service is updated according to a set write period, so that the other redundancy services can timely acquire the operating state of the present service, and avoid the conflict write caused by the error in the operating state determination. If the operating state is abnormal, the operation of detecting the operating state of the present service is performed after the present service is in sleep for a set time length.
[0063] S220, determining whether there is a master service in a normal operating state in the redundancy service based on the heartbeat word and the operating state in the service mark information.
[0064] S230, if there is no master service in a normal operating state, obtaining at least one application redundancy service initiating the master service application in the redundancy service in a normal operating state according to the application service mark in the service mark information.
[0065] S240, parsing the service number in the service mark information of the redundant service applied for, and comparing the service number of the redundant service applied for with the service number of the service.
[0066] In the embodiment of the application, the service number in the service mark information of the redundant service applied for is parsed, specifically, any variable name in the service mark information of a redundant service is parsed to obtain a number contained therein, and the number is determined as the service number of the redundant service.
[0067] Further, the service number of the redundant service applied for is compared with the service number of the service according to the preset main service determination rule to determine whether the redundant service applied for meets the main service condition.
[0068] S250, in the case that the service number of the redundant service applied for is greater than the service number of the service, the redundant service applied for is taken as a candidate service.
[0069] S260, the service number of the candidate service is determined as the largest, and the service number of the target service is taken as the main service election mark in the service mark information of the service to elect the target service as the main service.
[0070] In the embodiment of the application, the service number of the candidate service is determined as the largest according to the set main service selection rule, and the service number of the target service is taken as the main service election mark in the service mark information of the service to elect the target service as the main service.
[0071] In addition, in the case that there is no redundant service applied for, or the service number of the redundant service applied for is less than the service number of the service, the self application main service mark bit 1 can be directly set to apply for as the main service.
[0072] Optionally, the method further comprises:
[0073] In the case that there is no target service meeting the main service condition in the redundant service applied for, the main service mark in the service mark information of the service is updated to apply for as the main service;
[0074] The number of votes is determined according to the main service election mark in the service mark information of the associated redundant service, and in the case that the number of votes meets the election condition, the main service mark in the service mark information of the service is updated to make the service write the business data to the shared resource as the main service.
[0075] In the optional embodiment, in the case that there is no target service satisfying the condition of the main service in the application redundancy service, i.e. there is no application redundancy service with a service number greater than the service number of the current service, the current service applies for the main service by updating the application main service flag in the service flag information of the current service. The number of votes is determined according to the main service election flag in the service flag information of the associated redundancy service. In the case that the number of votes satisfies the election condition, for example, the number of votes is greater than 2 / 3 of the number of redundancy services in the normal working state, or is equal to the number of redundancy services in the normal working state, the current service writes the business data to the shared resource as the main service by updating the main service flag in the service flag information of the current service. On the contrary, if the number of votes does not satisfy the election condition, the operation of judging whether there is a main service in the normal working state is returned to be executed. The main service election is performed by each service based on the uniformly set main service election rule, which can ensure the uniqueness of the main service and strictly avoid redundancy writing.
[0076] Optionally, the method further comprises:
[0077] In the case that the current service writes the business data to the shared resource as the main service, in response to detecting that the current service runs abnormally, the working state in the service flag information of the current service is set to 0, and the heartbeat word is stopped from being updated.
[0078] In the optional embodiment, in the case that the current service writes the business data to the shared resource as the main service, it is continuously judged whether the current service works normally. In the normal working state, the heartbeat word of the current service is continuously written to enable other redundancy services to determine that there is a main service currently; in the abnormal state, it is judged whether the service ends, and if not, the working state in the service flag information of the current service in the shared resource is set to 0, and the heartbeat word is stopped from being updated, so that other redundancy services timely elect a new main service and avoid affecting the recording of the business data.
[0079] In addition, as a service running as a service, it is continuously judged whether the current service works normally. In the normal working state, the heartbeat word of the current service is continuously written to enable other redundancy services to determine the working state of the current service; in the abnormal state, it is judged whether the service ends, and if not, the working state in the service flag information of the current service in the shared resource is set to 0, and the heartbeat word is stopped from being updated, so as to avoid other redundancy services from taking the current service as a normal service in the main service election, and affecting the efficiency and accuracy of the election.
[0080] Optionally, after the target service is elected as the main service, the method further comprises:
[0081] Before the target service updates the main service flag in the service flag information of the target service, in response to detecting a new application redundancy service, the service number of the new application redundancy service is compared with the service number of the target service.
[0082] In the case that the service number of the new redundancy service is greater than the service number of the target service, the new redundancy service is elected as the master service by updating the master service election flag in the service flag information of the current service from the service number of the target service to the service number of the new redundancy service.
[0083] In the optional embodiment, after the target service is elected as the master service, other redundancy services may apply to be the master service before the target service updates the master service flag in the service flag information of the target service. In this case, in response to detecting a new redundancy service, the service number of the new redundancy service is compared with the service number of the target service. If the service number of the new redundancy service is greater than the service number of the target service, re-voting is performed, and the new redundancy service is elected as the master service by updating the master service election flag in the service flag information of the current service from the service number of the target service to the service number of the new redundancy service. Otherwise, if the service number of the new redundancy service is less than the service number of the target service, the original voting result is maintained. After detecting the new redundancy service, re-voting is performed to avoid voting errors caused by time difference of application initiation, further ensure the reliability of the voting result, and reduce the possibility of redundancy writing.
[0084] The technical solution of the embodiment of the application reads the service flag information of the redundancy service associated with the current service in the shared resource, determines whether there is a master service in a normal working state in the redundancy service based on the heartbeat word and the working state in the service flag information, acquires at least one application redundancy service that initiates a master service application in the redundancy service in a normal working state according to the application service flag in the service flag information, parses the service number in the service flag information of the application redundancy service, compares the service number of the application redundancy service with the service number of the current service, takes the application redundancy service as a candidate service in the case that the service number of the application redundancy service is greater than the service number of the current service, determines the target service with the maximum service number in the candidate service, and elects the target service as the master service by updating the master service election flag in the service flag information of the current service to the service number of the target service. The service flag information of each service is written into the shared resource, and in the case that the original master service fails, the new master service is determined through the election mode, so that the writing conflict caused by network failure between services is avoided, and the number of redundancy services can be flexibly adjusted according to actual needs through the mode of writing the service standard information into the shared resource.
[0085] Embodiment three
[0086] Figure 3A structure schematic diagram of a write conflict processing device provided for the third embodiment of the present application is shown in Figure 3. As shown in the figure, the device comprises: Figure 3
[0087] a flag information obtaining module 310, configured to read service flag information of a redundant service associated with the present service in a shared resource; the service flag information comprises a heartbeat word, an operating state, a master service flag, an application master service flag, and a master service election flag;
[0088] a master service determining module 320, configured to determine whether there is a master service in a normal operating state in the redundant service based on the heartbeat word and the operating state in the service flag information;
[0089] an application service obtaining module 330, configured to obtain at least one application redundant service in a normal operating state which initiates a master service application in the redundant service according to the application master service flag in the service flag information if there is no master service in a normal operating state;
[0090] a master service election module 340, configured to determine a target service meeting a master service condition in the at least one application redundant service according to the service flag information of the application redundant service, and elect the target service as the master service by updating the master service election flag in the service flag information of the present service.
[0091] The technical solution of the embodiment of the present application reads the service flag information of a redundant service associated with the present service in a shared resource, the service flag information comprises a heartbeat word, an operating state, a master service flag, an application master service flag, and a master service election flag, determines whether there is a master service in a normal operating state in the redundant service based on the heartbeat word and the operating state in the service flag information, obtains at least one application redundant service in a normal operating state which initiates a master service application in the redundant service according to the application master service flag in the service flag information if there is no master service in a normal operating state, determines a target service meeting a master service condition in the at least one application redundant service according to the service flag information of the application redundant service, and elects the target service as the master service by updating the master service election flag in the service flag information of the present service, writes the service flag information of each service into the shared resource, and determines a new master service by an election mode in the case of failure of the original master service, thereby avoiding write conflict caused by network failure between services.
[0092] Optionally, the master service election module 340 is specifically configured to:
[0093] analyze a service number in the service flag information of the application redundant service, and compare the service number of the application redundant service with the service number of the present service;
[0094] in a case where the service number of the application redundancy service is greater than the service number of the current service, taking the application redundancy service as a candidate service;
[0095] determining, among the candidate services, a service with the largest service number as a target service, and electing the target service as a master service by updating a master service election flag in the service flag information of the current service to the service number of the target service.
[0096] Optionally, the write conflict processing apparatus further comprises:
[0097] a master service application module configured to, in a case where no target service satisfying a master service condition exists in the application redundancy service, apply for being a master service by updating an application master service flag in the service flag information of the current service;
[0098] a vote determination module configured to determine a number of votes according to a master service election flag in the service flag information of the associated redundancy service, and in a case where the number of votes satisfies an election condition, make the current service write business data to the shared resource as the master service by updating the master service flag in the service flag information of the current service.
[0099] Optionally, the master service election module 340 is further configured to:
[0100] after electing the target service as the master service, before the target service updates a master service flag in its own service flag information, in response to detecting a new application redundancy service, comparing a service number of the new application redundancy service with the service number of the target service;
[0101] in a case where the service number of the new application redundancy service is greater than the service number of the target service, electing the new application redundancy service as the master service by updating the master service election flag in the service flag information of the current service from the service number of the target service to the service number of the new application redundancy service.
[0102] Optionally, the write conflict processing apparatus further comprises:
[0103] a data clearing module configured to, before reading the service flag information of the redundancy service associated with the current service from the shared resource, clear each item of data in the service flag information of the current service in the shared resource;
[0104] a working state writing module configured to detect a working state of the current service, and in a case where the working state of the current service is normal, update a working state in the service flag information of the current service;
[0105] a heartbeat word updating module configured to update a heartbeat word in the service flag information of the current service according to a set writing period.
[0106] Optionally, the write conflict processing apparatus further comprises:
[0107] The master node exception module is configured to, in a case where the service is a master service writing service data to the shared resource, in response to detecting that the service is running abnormally, set the working state in the service flag information of the service to 0 and stop updating the heartbeat word.
[0108] The write conflict processing apparatus provided by the embodiments of the present application can execute the write conflict processing method provided by any of the embodiments of the present application, and has the corresponding function modules and beneficial effects of the execution method.
[0109] In the technical solution of the present application, the collected information is information and data authorized by the user or authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data all comply with relevant laws, regulations and standards of the country and region, necessary security measures are taken, public order and good customs are not violated, and corresponding operation portals are provided for the user to select authorization or refusal.
[0110] Embodiment four
[0111] According to embodiments of the present application, the present application further provides an electronic device, a readable storage medium and a computer program product.
[0112] Figure 4 A structural schematic diagram of an electronic device 10 that can be used to implement embodiments of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, appliances, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular telephones, smart phones, wearable devices (e.g., headsets, glasses, watches, etc.), and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not intended to limit implementations of the present application described and / or claimed in this document.
[0113] As Figure 4As shown, the electronic device 10 includes at least one processor 11, and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., communicatively connected to the at least one processor 11, where the memory stores a computer program executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or loaded into the random access memory (RAM) 13 from the storage unit 18. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0114] Various components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc., an output unit 17, such as various types of displays, a speaker, etc., a storage unit 18, such as a magnetic disk, an optical disk, etc., and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.
[0115] The processor 11 can be various general and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs various methods and processes described above, such as the write conflict processing method.
[0116] In some embodiments, the write conflict processing method can be implemented as a computer program tangibly embodied in a computer readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the write conflict processing method described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to perform the write conflict processing method by any other appropriate means, such as by means of firmware.
[0117] The various embodiments of the systems and techniques described above can be implemented in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a complex programmable logic device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0118] Computer programs used to implement the processes of the application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer program
[0119] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store computer programs for use by or in connection with an instruction execution system, apparatus, or device. Computer-readable storage media can include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of the machine-readable storage medium will include one or more lines of a program of instructions in a transitory signal, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0120] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0121] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data application server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0122] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. A server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing application system, and solves the defects of large management difficulty and weak business scalability in traditional physical host and VPS application.
[0123] It should be understood that various forms of flow shown above can be used, with steps reordered, added, or removed. For example, the steps recited in the present invention can be performed in parallel, in series, or in a different order, without limitation herein, as long as the desired results of the technical solutions of the present invention can be achieved.
[0124] The specific embodiments described above are not intended to be limiting, but rather to illustrate the principles of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations and alternatives can be made to the specific embodiments without departing from the spirit and principles of the present invention. Any further modifications, changes, improvements, and the like that come within the spirit and principles of the present invention should also be considered as falling within the scope of the present invention.
Claims
1. A write conflict handling method, characterized in that, include: Read the service identifier information of redundant services associated with this service from the shared resources; The service identifier information includes heartbeat text, working status, main service identifier, application for main service identifier, and main service election identifier; Based on the heartbeat word and working status in the service identifier information, determine whether there is a primary service in normal working status among the redundant services; If there is no primary service in normal working condition, then based on the application service flag in the service flag information, at least one redundant service that initiated the application for primary service from the redundant services in normal working condition is obtained. Based on the service identifier information of the requested redundancy service, a target service that meets the main service condition is determined among at least one requested redundancy service, and the target service is elected as the main service by updating the main service election flag in the service identifier information of this service.
2. The method according to claim 1, characterized in that, Based on the service identifier information of the requested redundancy service, a target service that meets the primary service condition is determined among at least one requested redundancy service, and the primary service election flag is updated in the service identifier information of this service to elect the target service as the primary service, including: The service number is parsed from the service identifier information of the redundancy service request, and the service number of the redundancy service request is compared with the service number of this service. If the service number of the requested redundant service is greater than the service number of this service, the requested redundant service will be considered as a candidate service. Among the candidate services, the service with the largest service number is selected as the target service, and the target service is elected as the main service by updating the main service election flag in the service identifier information of this service to the service number of the target service.
3. The method according to claim 1, characterized in that, Also includes: If no target service that meets the conditions for a primary service is found in the application for redundant services, the application for a primary service is made by updating the service identifier information of this service to apply for the primary service status. Based on the primary service election flag in the service flag information of the associated redundant service, the number of votes is determined. If the number of votes meets the election conditions, the primary service flag in the service flag information of this service is updated, so that this service writes business data to the shared resource as the primary service.
4. The method according to claim 2, characterized in that, After electing the target service as the primary service, the following is also included: Before the target service updates the main service identifier in its service identifier information, in response to the detection of a new request for redundant service, the service number of the new request for redundant service is compared with the service number of the target service; If the service number of the new redundant service is greater than the service number of the target service, the new redundant service is elected as the main service by updating the main service election flag in the service flag information of this service from the service number of the target service to the service number of the new redundant service.
5. The method according to claim 1, characterized in that, Before reading the service identifier information of redundant services associated with this service from shared resources, the process also includes: Clear all data in the service identifier information of this service in the shared resources; Detect the working status of this service, and update the working status in the service identifier information if the working status is normal. Update the heartbeat word in the service identifier information of this service according to the set write cycle.
6. The method according to claim 1, characterized in that, Also includes: When this service writes business data to the shared resource as the main service, in response to detecting its own operational abnormality, the working status in the service flag information of this service is set to 0, and the heartbeat word is stopped from being updated.
7. A write conflict handling apparatus, characterized in that, include: The flag information acquisition module is used to read the service flag information of redundant services associated with this service from shared resources; The service identifier information includes heartbeat text, working status, main service identifier, application for main service identifier, and main service election identifier; The main service determination module is used to determine whether there is a main service in normal working state among the redundant services based on the heartbeat word and working status in the service identifier information; The service request acquisition module is used to, if there is no main service in normal working state, obtain at least one redundant service that has initiated the main service request from the redundant services in normal working state, based on the service request service flag in the service flag information. The main service election module is used to determine the target service that meets the main service conditions among at least one application for redundancy services based on the service identifier information of the application for redundancy services, and to elect the target service as the main service by updating the main service election flag in the service identifier information of this service.
8. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the write conflict handling method according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the write conflict handling method according to any one of claims 1-6.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the write conflict handling method according to any one of claims 1-6.
Citation Information
Patent Citations
Database cluster split-brain prevention method and device, electronic equipment and storage medium
CN117992501A
Data processing method and device, storage medium and electronic equipment
CN118838965A
Data writing and reading method and device
CN119513122A
Data acquisition component optimization method based on distributed storage all-in-one machine, medium and equipment
CN119520540A
Tolerating server failures in a consensus protocol down to one surviving server using shared storage as a voter
US12217550B1