Document data processing method and device for multiple ES clusters, equipment and storage medium
Document change requests are written asynchronously in multiple ES clusters through the proxy service system and message queue, which solves the problem of low document data update efficiency in multiple ES clusters, improves data communication efficiency, enhances the system's risk resistance, and ensures medical services. reliability.
Patent Information
- Application Number
- CN202410874214.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-10-29
AI Technical Summary
The document data update efficiency of multi-ES clusters is low, which may lead to system failures in extreme scenarios, affecting the reliability and security of medical services. In particular, long delays in data communication across computer rooms lead to failure of shard migration and master selection. problem.
Use a proxy service system to cache request messages through message queues, and write asynchronously to at least two ES clusters on consumers to ensure the orderliness and independence of document changes, avoid data synchronization changes, and improve data communication efficiency.
It improves the efficiency of multi-ES cluster document data update, avoids service unavailability problems caused by data communication delays and master selection failures, and enhances the risk resistance and reliability of the system.
Smart Images

Figure CN118860971A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the fields of data processing and digital medicine, and in particular to a document data processing method, device, equipment and storage medium for a multi-ES cluster. Background Art
[0002] With the in-depth development of mobile Internet, when user growth reaches a certain scale, many companies will face the challenges of high-concurrency business and massive data, especially data processing in the field of digital medicine. The storage and change of medical data must be safe and efficient to ensure the reliability and security of the medical system.
[0003] The traditional single-computer room data processing architecture has bottlenecks in machine capacity. In some extreme scenarios, all servers may fail. For example, power outages in the computer room, fires in the computer room, earthquakes and other force majeure factors may cause all servers in the system to fail, resulting in the overall paralysis of medical service businesses (such as online consultations, pathological analysis, case filing, drug statistics, and auxiliary medical care, etc.), making it impossible to quickly and accurately process medical data (such as personal health records, prescriptions, and examination reports, etc.), seriously affecting the efficiency of medical services, and even delaying the diagnosis and treatment of patients, causing medical accidents, etc. Therefore, in order to meet the continuity of the center's business and enhance risk resistance, a multi-active architecture system is usually used to provide data services.
[0004] The multi-active system requires the establishment of multiple computer rooms, each of which is an independent ES cluster. In the multi-computer room cluster architecture, when the document data in the cluster is changed, the data communication between computer rooms will cause the node data between clusters to time out due to the long delay, and then trigger the shard migration by mistake, which will occupy a large amount of I / O and affect the data communication efficiency; and if the replica shard is not configured during the shard migration, the data is not backed up, which will cause the service to be unavailable, resulting in the failure of document data update. In addition, when the ES cluster is established in multiple computer rooms, there will be a "brain split" problem. When a computer room is unavailable, there will be a failure to select the master, which will affect the data communication efficiency between ES clusters.
[0005] Therefore, how to solve the low efficiency of document data update in multiple ES clusters has become a technical problem that needs to be solved urgently. Summary of the invention
[0006] The present application provides a document data processing method, apparatus, device and storage medium for a multi-ES cluster, aiming to improve the document data update efficiency of a multi-ES cluster.
[0007] In a first aspect, the present application provides a document data processing method for a multi-ES cluster, which is used in a proxy service system, wherein the proxy service system includes a proxy service, a message queue, and a consumer, wherein the proxy service is used to receive a service request, the message queue is used to cache the request message, and the consumer is used to perform a document update of the multi-ES cluster. The document data processing method for the multi-ES cluster includes the following steps:
[0008] When the proxy service receives a change write request for a target document sent by a business service, a document change message is generated, wherein the change write request includes a document ID of the target document;
[0009] Based on the document ID, determine the storage partition corresponding to the target document in the message queue, and based on the storage partition, store the document change message;
[0010] When the consumer executes the document change message stored in the message queue, the document change write request is asynchronously written to at least two of the ES clusters to implement the change to the target document.
[0011] In a second aspect, the present application further provides a document data processing device for a multi-ES cluster, the document data processing device for a multi-ES cluster comprising:
[0012] A document change message generation module, configured to generate a document change message when the proxy service receives a change write request for a target document sent by a business service, wherein the change write request includes a document ID of the target document;
[0013] A message queue module, used to determine the storage partition corresponding to the target document in the message queue based on the document ID, and store the document change message based on the storage partition;
[0014] The document change module is used to asynchronously write the document change write request to at least two of the ES clusters when the consumer executes the document change message stored in the message queue, so as to realize the change of the target document.
[0015] In a third aspect, the present application also provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, the steps of the document data processing method of the multi-ES cluster as described above are implemented.
[0016] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of the document data processing method of the multi-ES cluster as described above are implemented.
[0017] The present application provides a document data processing method, device, equipment and storage medium for multiple ES clusters. The method of the present application receives a change write request sent by a business service through a proxy service, and encapsulates the change write request into a message form and stores it in a message queue to ensure the orderliness of changes to the same document; according to the document ID in the change write request, the storage partition corresponding to the target document in the message queue is determined, so that the change request message is stored in the storage partition corresponding to the target document, thereby ensuring the independence of different documents, avoiding the impact on other document update processes when a document update fails, and improving the efficiency of document data updates; when a consumer executes a document change message, the consumer can asynchronously apply the document change write request in multiple ES clusters, and change the target document in each ES cluster in turn, without the need to synchronize data changes to multiple ES clusters, thereby avoiding the problem of data communication delay caused by the deployment of multiple ES clusters in multiple computer rooms, thereby improving the efficiency of document data changes in multiple ES clusters. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0019] Figure 1 A document data processing system for multiple ES clusters provided in an embodiment of the present application;
[0020] Figure 2 A flowchart of a first embodiment of a document data processing method for multiple ES clusters provided by the present application;
[0021] Figure 3 Workflow diagram of the proxy service system provided in the embodiment of the present application;
[0022] Figure 4 A flowchart of a second embodiment of a method for processing document data in a multi-ES cluster provided by the present application;
[0023] Figure 5 It is a structural diagram of a first embodiment of a document data processing device for multiple ES clusters provided by the present application;
[0024] Figure 6It is a schematic block diagram of the structure of a computer device provided in an embodiment of the present application.
[0025] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0026] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0027] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0028] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0029] The embodiments of the present application provide a document data processing method, apparatus, device and storage medium for multiple ES clusters.
[0030] like Figure 1 As shown, Figure 1 A document data processing system of multiple ES clusters is provided for an embodiment of the present application. The system includes a terminal, a server and at least two ES clusters. The terminal is communicatively connected to the server, and the server is communicatively connected to the ES cluster.
[0031] The terminals include electronic devices such as mobile phones, tablet computers, laptop computers, desktop computers, personal digital assistants and wearable devices.
[0032] The server includes an independent server or a server cluster.
[0033] Hereinafter, the document data processing method of the multi-ES cluster provided by the embodiment of the present application will be introduced in detail based on the document data processing system of the multi-ES cluster.
[0034] An ES cluster is a group of interconnected complete computers that work together as a unified computing resource. Each node in an ES cluster is an independent computer (or is deployed on it). An ES cluster is deployed in one computer room, and multiple ES clusters can be deployed in multiple computer rooms to build a multi-active architecture. For example, an active-active architecture is a mirrored deployment of two independent clusters in two computer rooms. Data is still written to the database in the main computer room at a single point, and then synchronized to the other computer room in real time.
[0035] During the operation of multiple ES clusters, service calls are basically closed-loop in the same computer room. Data is still written to the main computer room data storage at a single point, and then synchronized and replicated to the backup computer room in the same city in real time. When a problem occurs in computer room A, the operation and maintenance personnel only need to manually change the routing method through GSLB or other solutions to route the traffic to computer room B, which can effectively prevent computer room disasters caused by fire, building damage, power failure, computer system and man-made damage.
[0036] Please refer to Figure 2 , Figure 2 This is a flowchart of a first embodiment of a method for processing document data in a multi-ES cluster provided by the present application. The method for processing document data in a multi-ES cluster can be used in a server of a document data processing system in a multi-ES cluster.
[0037] In this embodiment, the document data processing method of the multi-ES cluster is used in a proxy service system, and the proxy service system includes a proxy service, a message queue, and a consumer, wherein the proxy service is used to receive a service request, the message queue is used to cache the request message, and the consumer is used to execute the document update of the multi-ES cluster. The proxy service system can run in a server of the document data processing system of the multi-ES cluster.
[0038] like Figure 2 As shown, the document data processing method of the multi-ES cluster includes steps S101 to S103.
[0039] Step S101: When the proxy service receives a change write request for a target document sent by a business service, a document change message is generated, wherein the change write request includes a document ID of the target document;
[0040] Furthermore, when the proxy service receives the change write request, a transaction ID corresponding to the change write request of the target document is generated; and based on the change write request and the transaction ID, the document change message is generated.
[0041] In one embodiment, after receiving a write request, the proxy service generates a unique transaction ID, and then the transaction ID and request details are encapsulated into a message. The transaction ID corresponds to the document change request service one-to-one. When performing a document change service, the transaction ID and the change write request are stored in the database for subsequent traceability.
[0042] In one embodiment, the change write request is to change a document in the ES cluster, so the document ID of the target document to be changed is attached to the change write request to facilitate rapid location of the target document from the ES cluster.
[0043] In one embodiment, the documents in the ES cluster include personal health records, prescriptions, examination reports and other data, as well as electronic medical records, such as medical records, electrocardiograms, medical images and other electronic records that are worth preserving for future reference.
[0044] Please refer to Figure 3 , Figure 3 The workflow diagram of the proxy service system provided in the embodiment of the present application, wherein BusinessService is a business service, Proxy is a proxy service, MQ is a message queue, Consumer is a consumer, ES1 and ES2 are two ES clusters, DB is a database, and Async consume is an asynchronous consumption function.
[0045] like Figure 3 As shown, the business service forwards the change write request for the ES cluster document to the proxy service. After receiving the write request, the proxy service encapsulates the details of the change write request into a message for storage through the message queue (MQ).
[0046] Proxy service refers to proxy software or proxy server, which can also be considered as a network access method. It can copy the files and webpage data that have been accessed by the remote end to the local proxy. For example, if the connection setting has a designated proxy, every time you connect to a webpage, it will first check whether there is a webpage record before. If there is, it can directly transmit the data back without connecting to the outside.
[0047] Step S102: determining the storage partition corresponding to the target document in the message queue based on the document ID, and storing the document change message based on the storage partition;
[0048] In one embodiment, the Proxy will deliver the same document ID to the same Partition of the same Topic of MQ. The order of message arrangement of the Partition of MQ depends on the writing order. In this way, changes to the same document will also be stored in the Partition in order. After delivering the message to MQ, the Proxy will return the result to the request.
[0049] MQ (Message Queue) refers to a message queue, which is a "first-in, first-out" data structure in the basic data structure. It means putting the data (message) to be transmitted in the queue and using the queue mechanism to realize message transmission - the producer generates the message and puts the message into the queue, and then the consumer processes it. Consumers can pull messages from the specified queue, or subscribe to the corresponding queue, and the MQ server will push messages to them.
[0050] Topic refers to the logical classification of a message. When providing services to multiple modules in a message system, different types of messages need to be logically classified. The specific classification method is to use Topics to distinguish them. Different types of messages have different Topics. Each message belongs to and only belongs to one Topic.
[0051] Partition refers to the partition within the topic, which is the partition of the Topic. Topic is a logical concept. Partition is the smallest storage unit, which holds part of the data of a Topic. If there is no partition, the message set corresponding to a Topic will be unevenly distributed in the distributed cluster service group, which may cause a server to record a large number of message sets of the current Topic. If the message pressure of this Topic is very high, the server may be under great pressure, and the throughput may easily lead to bottlenecks. If the Topic is divided into multiple Partitions, these multiple Partitions can be evenly distributed to different servers, and the load balancing effect can be achieved through multiple partitions.
[0052] Step S103: When the consumer executes the document change message stored in the message queue, the document change write request is asynchronously written to at least two of the ES clusters to implement the change to the target document.
[0053] In one embodiment, the consumer pulls document change messages from MQ, first obtains a snapshot of the current document from the ES cluster based on the document ID in the pulled message, then writes the document snapshot and message record to the DB, and then applies this write request to multiple ES clusters, such as Figure 3 ES1 and ES2 shown.
[0054] In one embodiment, the consumer must pull messages from the Topic's Partition by itself. A Consumer connects to a Partition and reads messages from it in sequence.
[0055] In a specific embodiment, if Figure 3 As shown, the consumer executes the document update message of multiple ES clusters according to the asynchronous consumption function (Asyncconsume). When executing the document update message, the consumer executes the document update of one ES cluster each time. Therefore, each document update data is communicated between the nodes of the same ES cluster, that is, the update of the target document is actually for the ES cluster in one computer room, and there is no need for synchronous update across computer rooms, thereby reducing the amount of data processing and improving data communication efficiency.
[0056] In one embodiment, the message queue can ensure the orderliness of update requests for the same document, ensure the order of message execution, avoid version confusion and errors in document updates, and facilitate subsequent tracing of document update transactions.
[0057] Furthermore, after completing the change of the target document, the storage address of the target document in the storage partition is obtained; based on the database, the storage address and the transaction ID are stored, and a change log corresponding to the change write request of the target document is generated.
[0058] In one embodiment, after the document update of multiple ES clusters is completed, the offset of the message on the MQ Partition and the transaction ID of the document change message are saved in the database DB.
[0059] In a specific embodiment, each record in a Partition is assigned a unique serial number, called an Offset. Offset is an increasing, immutable number that is automatically maintained by Kafka. When a record is written to a Partition, it is appended to the end of the log file and assigned a serial number, the Offset, which can be used as the storage address of the document change message in the storage partition.
[0060] In a specific embodiment, by storing the transaction ID and storage sequence number of the document change message in the database DB, the update information of the current transaction can be saved when the update is completed or fails, including document version information, transaction information, and update results. In the subsequent backtracking process, the document update process and version information can be queried based on the transaction ID, and the storage sequence number can be used to query and trace the storage partition of the document change message, thereby realizing the traceability of the document change process in multiple ES clusters.
[0061] This embodiment provides a document data processing method for multiple ES clusters. The method of this application receives a change write request sent by a business service through a proxy service, and encapsulates the change write request into a message form and stores it in a message queue to ensure the orderliness of changes to the same document; according to the document ID in the change write request, the storage partition corresponding to the target document in the message queue is determined, so that the change request message is stored in the storage partition corresponding to the target document, thereby ensuring the independence of different documents, avoiding the impact on other document update processes when a document update fails, and improving the efficiency of document data updates; when a consumer executes a document change message, the consumer can asynchronously apply the document change write request in multiple ES clusters, and change the target document in each ES cluster in turn, without the need to synchronize data changes to multiple ES clusters, thereby avoiding the data communication delay problem caused by the deployment of multiple ES clusters in multiple computer rooms, thereby improving the document data change efficiency of multiple ES clusters.
[0062] Please refer to Figure 4 , Figure 4 This is a flowchart of the second embodiment of the document data processing method for multiple ES clusters provided in this application.
[0063] like Figure 3 As shown, the proxy service system also includes a database, and the database is used to store update data.
[0064] In this embodiment, Figure 4 As shown, based on the above Figure 2 In the illustrated embodiment, before asynchronously writing the document change write request to at least two ES clusters to implement the change to the target document, the process further includes:
[0065] Step S201: Based on the document ID of the target document, query the target document from the ES cluster and read the current document snapshot of the target document;
[0066] Step S202: Based on the database, store the current document snapshot and the document change message.
[0067] In this embodiment, before updating the target document in the ES cluster, the current document snapshot of the target document is extracted from the ES cluster according to the document ID of the target document, and then the current document snapshot and the document change message record are written into the database DB.
[0068] Furthermore, when an abnormality occurs in a document change in the ES cluster, based on the document ID, the current document snapshot of the target document stored in the database is read, and a document recovery write request for the current document snapshot is generated; the document recovery write request is executed, and the current document snapshot of the target document is written to each of the ES clusters to complete the data recovery of the target document.
[0069] A file snapshot is to lock the virtual hard disk file of the current virtual machine and stop changing it; then create a new file and put all the changes in the new file. When reading, the document data in the new file is read first, and if there is no document data in the new file, the locked data is read first.
[0070] In a specific embodiment, based on the message compensation mechanism, when a message processing exception occurs, that is, a document change in the ES cluster occurs abnormally, the current document snapshot of the target document can be searched from the database based on the document ID, and the document data in the ES cluster can be restored to the version document before the update, thereby avoiding large differences in data versions between clusters.
[0071] Furthermore, when the target document of the ES cluster fails to be changed, based on the retry mechanism, the document change message stored in the database is re-read and executed to update the target document; if the ES cluster document is not changed successfully after the retry mechanism has retried a preset number of times, the abnormal factors of the ES cluster document change abnormality are recorded, and the change failure information is sent to the business service.
[0072] In one embodiment, the change failure information includes the document ID and abnormal factors, and the abnormal factors include network, timeout and node.
[0073] In a specific embodiment, if an exception is encountered when updating the ES cluster, such as network, timeout, node, etc., the document snapshot stored in the DB before the change will be restored to the processed cluster, and then the reason for the change failure will be recorded and retried.
[0074] It is understandable that the retry mechanism is to avoid document update failures caused by occasional network anomalies. However, if the anomaly is persistent, the document update will continue to fail. At this time, it is necessary to identify the anomaly to avoid continuous retries, which will hinder the update process.
[0075] In a specific embodiment, the number of retries can be set. If the update fails after repeated retries, the update process of the document is terminated when the preset number of retries is reached. For example, if the update still does not fail after five retries, the change failure information is sent to the business service to remind the business service that the target document update has failed. The business service can check whether the document change information is normal and choose to re-request the change.
[0076] In a specific embodiment, the change failure information may include the reason for the document update failure determined by the server, and the business service end may perform targeted detection on the reason to achieve rapid troubleshooting.
[0077] The retry mechanism can solve the problem of update failure caused by occasional network factors. Because the update request message partition storage is adopted, the update process of each document is carried out independently, so it can avoid that when the update fails due to data anomalies of a small number of documents, the update of other documents will be affected.
[0078] In this embodiment, before executing the document change in the ES cluster, the document snapshot of the current version of the target document in the ES cluster is saved in the database, which can provide compensation for the failure of the target document update execution, avoiding the loss or destruction of the document version due to the update failure. And on this basis, multiple update attempts can be implemented, fault tolerance can be improved, document update failures caused by occasional exceptions can be avoided, and exceptions can be quickly checked, thereby improving the efficiency of document updates.
[0079] See also Figure 5 , Figure 5 This is a schematic diagram of the structure of a first embodiment of a document data processing device for a multi-ES cluster provided by the present application, wherein the document data processing device for a multi-ES cluster is used to execute the document data processing method for a multi-ES cluster described above. The document data processing device for a multi-ES cluster can be configured in a server.
[0080] like Figure 5 As shown, the document data processing device 300 of the multi-ES cluster includes: a document change message generation module 301, a message queue module 302 and a document change module 303.
[0081] The document change message generation module 301 is used to generate a document change message when the proxy service receives a change write request of a target document sent by the business service, wherein the change write request includes the document ID of the target document;
[0082] The message queue module 302 is used to determine the storage partition corresponding to the target document in the message queue based on the document ID, and store the document change message based on the storage partition;
[0083] The document change module 303 is used to asynchronously write the document change write request to at least two of the ES clusters when the consumer executes the document change message stored in the message queue, so as to realize the change of the target document.
[0084] In one embodiment, the document data processing device 300 of the multi-ES cluster also includes a data storage module, which is used to query the target document from the ES cluster based on the document ID of the target document and read the current document snapshot of the target document; based on the database, store the current document snapshot and the document change message.
[0085] In one embodiment, the document data processing device 300 of the multiple ES clusters also includes a data recovery module, which is used to read the current document snapshot of the target document stored in the database based on the document ID when an abnormality occurs in a document change in the ES cluster, and generate a document recovery write request for the current document snapshot; execute the document recovery write request, and write the current document snapshot of the target document to each of the ES clusters to complete the data recovery of the target document.
[0086] In one embodiment, the document data processing device 300 of the multiple ES clusters also includes an update retry module, which is used to reread the document change message stored in the database and execute it based on a retry mechanism when the target document change of the ES cluster fails, so as to update the target document; if the ES cluster document is not changed successfully after the retry mechanism has retried a preset number of times, the abnormal factors of the ES cluster document change abnormality are recorded, and the change failure information is sent to the business service.
[0087] In one embodiment, the change failure information includes the document ID and abnormal factors, and the abnormal factors include network, timeout and node.
[0088] In one embodiment, the message queue module 302 is also used to generate a transaction ID corresponding to the change write request of the target document when the proxy service receives the change write request; and generate the document change message based on the change write request and the transaction ID.
[0089] In one embodiment, the document data processing device 300 of the multi-ES cluster also includes a change log generation module, which is used to obtain the storage address of the target document in the storage partition; based on the database, the storage address and the transaction ID are stored, and a change log corresponding to the change write request of the target document is generated.
[0090] It should be noted that technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described device and each module can refer to the corresponding process in the aforementioned multi-ES cluster document data processing method embodiment, and will not be repeated here.
[0091] The apparatus provided in the above embodiment may be implemented in the form of a computer program. The computer program may be Figure 6 Runs on the computer device shown.
[0092] See also Figure 6 , Figure 6 1 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device may be a server.
[0093] See also Figure 6 The computer device includes a processor, a memory and a network interface connected through a system bus, wherein the memory may include a non-volatile storage medium and an internal memory.
[0094] The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any document data processing method of multiple ES clusters.
[0095] The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
[0096] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any document data processing method of multiple ES clusters.
[0097] The network interface is used for network communication, such as sending assigned tasks, etc. Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0098] It should be understood that the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0099] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0100] When the proxy service receives a change write request for a target document sent by a business service, a document change message is generated, wherein the change write request includes a document ID of the target document;
[0101] Based on the document ID, determine the storage partition corresponding to the target document in the message queue, and based on the storage partition, store the document change message;
[0102] When the consumer executes the document change message stored in the message queue, the document change write request is asynchronously written to at least two of the ES clusters to implement the change to the target document.
[0103] In one embodiment, before implementing the asynchronous writing of the document change write request to at least two ES clusters to implement the change to the target document, the processor is further configured to implement:
[0104] Based on the document ID of the target document, query the target document from the ES cluster and read the current document snapshot of the target document;
[0105] Based on the database, the current document snapshot and the document change message are stored.
[0106] In one embodiment, after the processor implements asynchronously writing the document change write request to at least two ES clusters to implement the change to the target document when the consumer executes the document change message stored in the message queue, the processor is further configured to implement:
[0107] When an abnormality occurs in a document change in the ES cluster, based on the document ID, a current document snapshot of the target document stored in the database is read, and a document recovery write request for the current document snapshot is generated;
[0108] The document recovery write request is executed to write the current document snapshot of the target document into each of the ES clusters to complete data recovery of the target document.
[0109] In one embodiment, after the processor implements asynchronously writing the document change write request to at least two ES clusters to implement the change to the target document when the consumer executes the document change message stored in the message queue, the processor is further configured to implement:
[0110] When the target document of the ES cluster fails to be changed, based on a retry mechanism, the document change message stored in the database is re-read and executed to update the target document;
[0111] If the ES cluster document is not changed successfully after the retry mechanism has retried a preset number of times, the abnormal factors of the abnormal change of the ES cluster document are recorded, and change failure information is sent to the business service.
[0112] In one embodiment, the change failure information includes the document ID and abnormal factors, and the abnormal factors include network, timeout and node.
[0113] In one embodiment, when the processor generates a document change message when the proxy service receives a change write request for a target document sent by a business service, the processor is configured to implement:
[0114] When the proxy service receives the change write request, generating a transaction ID corresponding to the change write request for the target document;
[0115] The document change message is generated based on the change write request and the transaction ID.
[0116] In one embodiment, after the processor implements asynchronously writing the document change write request to at least two ES clusters to implement the change to the target document when the consumer executes the document change message stored in the message queue, the processor is further configured to implement:
[0117] Obtaining the storage address of the target document in the storage partition;
[0118] Based on the database, the storage address and the transaction ID are stored, and a change log corresponding to the change write request of the target document is generated.
[0119] A computer-readable storage medium is also provided in an embodiment of the present application. The computer-readable storage medium stores a computer program. The computer program includes program instructions. The processor executes the program instructions to implement any document data processing method for a multi-ES cluster provided in an embodiment of the present application.
[0120] The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc., equipped on the computer device.
[0121] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A document data processing method for multiple ES clusters, characterized in that: For a proxy service system, the proxy service system includes a proxy service, a message queue and a consumer, wherein the proxy service is used to receive a service request, the message queue is used to cache the request message, and the consumer is used to perform a document update of a multi-ES cluster, and the method includes: When the proxy service receives a change write request for a target document sent by a business service, a document change message is generated, wherein the change write request includes a document ID of the target document; Based on the document ID, determine the storage partition corresponding to the target document in the message queue, and based on the storage partition, store the document change message; When the consumer executes the document change message stored in the message queue, the document change write request is asynchronously written to at least two of the ES clusters to implement the change to the target document.
2. The document data processing method of multiple ES clusters according to claim 1, characterized in that: The proxy service system also includes a database, which is used to store update data; Before asynchronously writing the document change write request to at least two ES clusters to implement the change to the target document, the method further includes: Based on the document ID of the target document, query the target document from the ES cluster and read the current document snapshot of the target document; Based on the database, the current document snapshot and the document change message are stored.
3. The document data processing method of multiple ES clusters according to claim 2, characterized in that: When the consumer executes the document change message stored in the message queue, after asynchronously writing the document change write request to at least two ES clusters to implement the change to the target document, the method further includes: When an abnormality occurs in a document change in the ES cluster, based on the document ID, a current document snapshot of the target document stored in the database is read, and a document recovery write request for the current document snapshot is generated; The document recovery write request is executed to write the current document snapshot of the target document into each of the ES clusters to complete data recovery of the target document.
4. The document data processing method of multiple ES clusters according to claim 2 is characterized in that: When the consumer executes the document change message stored in the message queue, after asynchronously writing the document change write request to at least two ES clusters to implement the change to the target document, the method further includes: When the target document of the ES cluster fails to be changed, based on a retry mechanism, the document change message stored in the database is re-read and executed to update the target document; If the ES cluster document is not changed successfully after the retry mechanism has retried a preset number of times, the abnormal factors of the abnormal change of the ES cluster document are recorded, and change failure information is sent to the business service.
5. The document data processing method of multiple ES clusters according to claim 4 is characterized in that: The change failure information includes the document ID and abnormal factors, and the abnormal factors include network, timeout and node.
6. The document data processing method of multiple ES clusters according to claim 1, characterized in that: When the proxy service receives a change write request for a target document sent by the business service, generating a document change message includes: When the proxy service receives the change write request, generating a transaction ID corresponding to the change write request for the target document; The document change message is generated based on the change write request and the transaction ID.
7. The document data processing method of multiple ES clusters according to claim 6, characterized in that: When the consumer executes the document change message stored in the message queue, after asynchronously writing the document change write request to at least two ES clusters to implement the change to the target document, the method further includes: Obtaining the storage address of the target document in the storage partition; Based on the database, the storage address and the transaction ID are stored, and a change log corresponding to the change write request of the target document is generated.
8. A document data processing device for multiple ES clusters, characterized in that: The document data processing device of the multi-ES cluster includes: A document change message generation module, configured to generate a document change message when the proxy service receives a change write request for a target document sent by a business service, wherein the change write request includes a document ID of the target document; A message queue module, used to determine the storage partition corresponding to the target document in the message queue based on the document ID, and store the document change message based on the storage partition; The document change module is used to asynchronously write the document change write request to at least two of the ES clusters when the consumer executes the document change message stored in the message queue, so as to realize the change of the target document.
9. A computer device, characterized in that: The computer device includes a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, the steps of the document data processing method of a multi-ES cluster as described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the document data processing method for a multi-ES cluster according to any one of claims 1 to 7 are implemented.
