One-time semantic method, device, equipment and readable storage medium
By recording the client ID and request ID in the distributed system, and processing non-idempotent requests in case of timeout or failure, the one-time semantic problem caused by repeated sending of non-idempotent requests is solved, and the processing efficiency and performance of the system are improved. .
Patent Information
- Application Number
- CN202311625217.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-30
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2043-11-30
AI Technical Summary
In the existing technology, repeated sending of non-idempotent requests in distributed systems makes it difficult to guarantee one-time semantics, and existing solutions are not efficient enough, affecting system performance.
By recording the client ID and request ID on the server, it distinguishes non-idempotent requests from their query requests. The client sends a query request after timeout to obtain the processing status, and forwards the request to other servers in case of failure to ensure that the request is only Process once.
Efficient one-time semantic processing is achieved to ensure the improvement of distributed system performance and avoid repeated processing and performance loss.
Smart Images

Figure CN117454905B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of distributed system message processing, and in particular to a one-time semantic method, apparatus, device and readable storage medium. Background Art
[0002] In a distributed system, repeated sending of non-idempotent requests will make it difficult to ensure one-time semantics. "Idempotence" is originally a concept in the field of mathematics, which means that certain operations or functions can be executed multiple times, but the results obtained each time are unchanged. In a distributed system, no matter how many times an idempotent operation is repeated, the state of the distributed system will not change. On the contrary, repeated non-idempotent operations will change the state of the distributed system.
[0003] For example, in a distributed file system, the client sends a request to create file A to the server. After that, the server successfully creates file A, but does not return the result to the client due to failures or other reasons. At this time, if the client sends another request to create file A to the server, the server will return that the file already exists, which will obviously cause confusion to the client.
[0004] Therefore, once-only semantics is very important for distributed systems. However, the current once-only semantics solutions are not efficient enough, which affects the performance of distributed systems. Summary of the invention
[0005] The present application provides a one-time semantic method, apparatus, device and readable storage medium, aiming to solve the technical problem that the efficiency of current one-time semantic solutions is not high enough, which affects the performance of distributed systems.
[0006] In a first aspect, an embodiment of the present application provides a one-time semantic method, the one-time semantic method comprising:
[0007] The server receives a request sent by the client, wherein the request sent by the client includes a client identifier, a request identifier, and a resend identifier;
[0008] When the request sent by the client is a non-idempotent request, if the resend flag is yes and the server does not have the client ID and request ID record, or the resend flag is no, the server records the client ID and request ID and processes the non-idempotent request;
[0009] When the request sent by the client is a non-idempotent query request, if the server does not have the client identifier and request identifier records, a message to resend the non-idempotent request is returned to the client.
[0010] Optionally, before the server receives the request sent by the client, the following steps are included:
[0011] The client sends a non-idempotent request to the server. If the client does not receive the processing result of the non-idempotent request returned by the server within a preset time, it sends a query request of the non-idempotent request to the server.
[0012] Optionally, when the request sent by the client is a query request of a non-idempotent request, if the server does not have a client identifier and a request identifier record, after returning a message of resending the non-idempotent request to the client, the method further includes:
[0013] When the request sent by the client is a query request of a non-idempotent request, if the server has the client ID and request ID records, it determines whether the non-idempotent request has been processed through query;
[0014] If the non-idempotent request is not processed, a message for resending the query request for the non-idempotent request is returned to the client;
[0015] If the non-idempotent request has been processed, the processing result is returned to the client.
[0016] Optionally, the one-time semantic method further includes:
[0017] When the distributed system detects that a server fails after receiving a non-idempotent request from a client, it forwards the non-idempotent request sent by the client to another server that has not failed;
[0018] After receiving the query request of the non-idempotent request sent by the client, the server that has not failed will return a message of resending the non-idempotent request to the client if the non-idempotent request has not been processed by the server that has failed. If the non-idempotent request has been processed by the server that has failed, it will return the processing result to the client.
[0019] Optionally, the request identifier is incremented when the client sends a new non-idempotent request to the server, and the request sent by the client also includes a minimum request identifier, where the minimum request identifier is the minimum value of the request identifiers of the non-idempotent requests that have not been processed by the client. After the server receives the request sent by the client, the following steps are included:
[0020] The server deletes the records whose request IDs are smaller than the minimum request ID.
[0021] In a second aspect, an embodiment of the present application provides a one-time semantic device, the one-time semantic device comprising:
[0022] A receiving module, configured to receive a request sent by a client at a server end, wherein the request sent by the client includes a client identifier, a request identifier, and a resend identifier;
[0023] A processing module, used for, when the request sent by the client is a non-idempotent request, if the resend flag is yes and the server does not have the client flag and the request flag record, or the resend flag is no, the server records the client flag and the request flag, and processes the non-idempotent request;
[0024] The resending module is used to return a message of resending the non-idempotent request to the client when the request sent by the client is a query request of a non-idempotent request and if the server does not have the client identifier and request identifier records.
[0025] Optionally, the one-time semantic device further includes a sending module, which is used to:
[0026] The client sends a non-idempotent request to the server. If the client does not receive the processing result of the non-idempotent request returned by the server within a preset time, it sends a query request of the non-idempotent request to the server.
[0027] Optionally, the one-time semantic device further includes a return module, which is used to:
[0028] When the request sent by the client is a query request of a non-idempotent request, if the server has the client ID and request ID records, it determines whether the non-idempotent request has been processed through query;
[0029] If the non-idempotent request is not processed, a message for resending the query request for the non-idempotent request is returned to the client;
[0030] If the non-idempotent request has been processed, the processing result is returned to the client.
[0031] In a third aspect, an embodiment of the present application provides a one-time semantic device, which includes a processor, a memory, and a one-time semantic program stored in the memory and executable by the processor, wherein when the one-time semantic program is executed by the processor, the steps of the one-time semantic method described above are implemented.
[0032] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a one-time semantic program is stored, wherein when the one-time semantic program is executed by a processor, the steps of the one-time semantic method described above are implemented.
[0033] The beneficial effects brought by the technical solution provided in the embodiments of the present application include:
[0034] In an embodiment of the present application, a server receives a request sent by a client, wherein the request sent by the client includes a client identifier, a request identifier and a retransmission identifier; when the request sent by the client is a non-idempotent request, if the retransmission identifier is yes and the server does not have a record of the client identifier and the request identifier, or the retransmission identifier is no, the server records the client identifier and the request identifier and processes the non-idempotent request; when the request sent by the client is a query request of a non-idempotent request, if the server does not have a record of the client identifier and the request identifier, a message of retransmitting the non-idempotent request is returned to the client. The embodiments of the present application focus on the processing of non-idempotent requests. The requests sent by the client and received by the server are divided into two categories, namely non-idempotent requests and query requests for non-idempotent requests. The client first sends a non-idempotent request to the server. If no return result is received after timeout, the client sends a query request for the non-idempotent request to the server to obtain the server's processing of the non-idempotent request. For non-idempotent requests, the retransmission mark is no, which means that it is a non-idempotent request sent for the first time, or the retransmission mark is yes, but the server does not have a client mark and request mark record, indicating that although it is a repeated non-idempotent request, the server may not have received it due to a failure or other reasons. The non-idempotent request sent before is also regarded as the first non-idempotent request sent. The client ID and request ID are recorded, and the non-idempotent request is processed, thereby ensuring that the server can process the non-idempotent request in a timely and effective manner and only processes the repeatedly sent non-idempotent request once. For the query request of the non-idempotent request, if the server does not have the client ID and request ID record, it means that the server has not received the non-idempotent request sent by the client. It returns to let the client resend the non-idempotent request, so that the server can receive the non-idempotent request that it has not received before, thereby ensuring one-time semantics, simple and efficient implementation, and very little impact on the performance of the distributed system. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 This is a first flow chart of an embodiment of the one-time semantic method of the present application;
[0036] Figure 2 This is a second flow chart of an embodiment of the one-time semantic method of the present application;
[0037] Figure 3 This is a third flow chart of an embodiment of the one-time semantic method of the present application;
[0038] Figure 4 This is a functional module diagram of an embodiment of a one-time semantic device of the present application;
[0039] Figure 5 This is a schematic diagram of the hardware structure of the disposable semantic device involved in the embodiment of the present application. DETAILED DESCRIPTION
[0040] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only 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.
[0041] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0042] In a first aspect, an embodiment of the present application provides a one-time semantic method.
[0043] In one embodiment, referring to Figure 1 , Figure 1 This is a first flow chart of an embodiment of the one-time semantic method of the present application, as shown in FIG. Figure 1 As shown, the one-shot semantics approach includes:
[0044] Step S10: The server receives a request sent by the client, wherein the request sent by the client includes a client identifier, a request identifier, and a resend identifier.
[0045] In this embodiment, taking the distributed file system as an example, non-idempotent requests include create, remove, rename, mkdir (create directory) and rmdir (delete directory), etc., and idempotent requests include lookup and open, etc. Since repeated operations of idempotent requests will not change the state of the distributed system, while repeated operations of non-idempotent requests will change the state of the distributed system, this application focuses on the processing of non-idempotent requests. The requests sent by the client received by the server can be divided into two categories, namely non-idempotent requests and query requests for non-idempotent requests. The client first sends a non-idempotent request to the server. If no return result is received after timeout, it sends a query request for non-idempotent requests to the server to obtain the server's processing of the non-idempotent request. It should be noted that the query request for non-idempotent requests is an idempotent request, and repeatedly sending the query request for non-idempotent requests will not change the state of the distributed system. No matter it is a non-idempotent request or a query request of a non-idempotent request, the request message sent carries the client identifier, request identifier and retransmission identifier information. The client identifier, request identifier and retransmission identifier information can be implemented by using separate fields or fused character strings, etc., wherein different requests from different clients are identified by the client identifier and request identifier. The retransmission identifier includes two states, "yes" or "no". The retransmission identifier is "no", which means that the request sent by the client is a non-idempotent request sent for the first time. The retransmission identifier is "yes", which means that it is a request sent repeatedly by the client. The repeatedly sent request may be a non-idempotent request or a query request of a non-idempotent request.
[0046] Step S20, when the request sent by the client is a non-idempotent request, if the resend flag is yes and the server does not have a client flag and a request flag record, or the resend flag is no, the server records the client flag and the request flag and processes the non-idempotent request.
[0047] In this embodiment, there are two cases for the non-idempotent request sent by the client. The retransmission flag is no, which means that the request sent by the client is the first non-idempotent request sent. Another case is that the client has sent a non-idempotent request before, but due to network failure or other reasons, the server did not receive the non-idempotent request sent by the client before, and the client repeatedly sent the non-idempotent request. By querying if the server does not have the client identification and request identification records, it can be determined that the server has not received the non-idempotent request sent by the client before. For this case, it is also regarded as the first non-idempotent request sent, and the same processing is performed as the first non-idempotent request sent. The server records the client identification and request identification, and processes the non-idempotent request, thereby ensuring that the server can process the non-idempotent request in a timely and effective manner and only processes the repeatedly sent non-idempotent request once.
[0048] Step S30: When the request sent by the client is a non-idempotent query request, if the server does not have the client identifier and request identifier records, a message for resending the non-idempotent request is returned to the client.
[0049] In this embodiment, the client identifier and request identifier of the query request of the non-idempotent request are the same as the client identifier and request identifier of the non-idempotent request. When the request sent by the client is a query request of the non-idempotent request, if there is no client identifier and request identifier record on the server through query, it means that the client has sent a non-idempotent request before, but the server may not receive the non-idempotent request sent by the client due to network failure and other reasons. At this time, the message of resending the non-idempotent request is returned to the client, so that the server can receive the non-idempotent request that was not received before.
[0050] In this embodiment, the focus is on the processing of non-idempotent requests. The requests sent by the client and received by the server can be divided into two categories, namely non-idempotent requests and query requests for non-idempotent requests. The client first sends a non-idempotent request to the server. If no return result is received after the timeout, the query request for the non-idempotent request is sent to the server to obtain the server's processing of the non-idempotent request. For non-idempotent requests, the retransmission flag is "no", which means that it is the first non-idempotent request sent, or the retransmission flag is "yes", but the server does not have the client flag and request flag records, indicating that although it is a repeated non-idempotent request, the server may not have received the previous request due to a failure or other reasons. The non-idempotent request sent is also regarded as the first non-idempotent request sent. The client ID and request ID are recorded, and the non-idempotent request is processed, thereby ensuring that the server can process the non-idempotent request in a timely and effective manner and only processes the repeatedly sent non-idempotent request once. For the query request of the non-idempotent request, if the server does not have the client ID and request ID record, it means that the server has not received the non-idempotent request sent by the client. It returns to let the client resend the non-idempotent request, so that the server can receive the non-idempotent request that it has not received before, thereby ensuring one-time semantics, simple and efficient implementation, and very little impact on the performance of the distributed system.
[0051] Further, in one embodiment, referring to Figure 2 , Figure 2 This is a second flow chart of an embodiment of the one-time semantic method of the present application, as shown in FIG. Figure 2 As shown, before step S10, the following steps are included:
[0052] Step S00, the client sends a non-idempotent request to the server. If the client does not receive the processing result of the non-idempotent request returned by the server within a preset time, the client sends a query request of the non-idempotent request to the server.
[0053] In this embodiment, the application focuses on the processing of non-idempotent requests. The client first sends a non-idempotent request to the server. If the processing result of the non-idempotent request returned by the server is not received within the preset time, a query request of the non-idempotent request is sent to the server to obtain the processing status of the non-idempotent request by the server, wherein the client identifier and request identifier of the query request of the non-idempotent request are the same as the client identifier and request identifier of the non-idempotent request, and the retransmission identifier can be set to yes. Continuing with the example of a distributed file system, if the client first sends a non-idempotent request such as create to the server, and the processing result of the non-idempotent request create returned by the server is not received within the preset time, a query request lookup of the non-idempotent request is sent to the server.
[0054] Further, in one embodiment, referring to Figure 3 , Figure 3 This is a third flow chart of an embodiment of the one-time semantic method of the present application, as shown in FIG. Figure 3 As shown, after step S30, the following steps are included:
[0055] Step S40, when the request sent by the client is a query request of a non-idempotent request, if the server has a client identifier and a request identifier record, it is determined by query whether the non-idempotent request has been processed;
[0056] Step S50: if the non-idempotent request is not processed, a message of resending the query request of the non-idempotent request is returned to the client;
[0057] Step S60: If the non-idempotent request has been processed, the processing result is returned to the client.
[0058] In this embodiment, when the request sent by the client is a query request of a non-idempotent request, if the server has a client identifier and a request identifier record, it means that the server has received a non-idempotent request before, and then determines whether the non-idempotent request has been processed by querying, which is divided into two situations. For the non-idempotent request, if the server has not yet processed it, the client is notified to resend the query request of the non-idempotent request, that is, the server informs the client that it is processing the non-idempotent request and will query again later. For the non-idempotent request, the server has processed it, and then the server returns the processing result to the client. Continuing to take the distributed file system as an example, the server receives a query request lookup of a non-idempotent request create sent by the client, and queries the processing status of the server through the client identifier and the request identifier. If the information returned by the server does not include inode (index node, containing file meta information) information, it means that the non-idempotent request has not been processed, and the server notifies the client to resend the query request of the non-idempotent request. If the information returned by the server includes inode information, it means that the non-idempotent request has been processed, and the server returns the inode information to the client.
[0059] Furthermore, in one embodiment, the one-time semantic method further includes:
[0060] When the distributed system detects that a server fails after receiving a non-idempotent request from a client, it forwards the non-idempotent request sent by the client to another server that has not failed;
[0061] After receiving the query request of the non-idempotent request sent by the client, the server that has not failed will return a message of resending the non-idempotent request to the client if the non-idempotent request has not been processed by the server that has failed. If the non-idempotent request has been processed by the server that has failed, it will return the processing result to the client.
[0062] In this embodiment, in a distributed system, the server may fail and restart after receiving a non-idempotent request sent by a client. At this time, the distributed system will forward the non-idempotent request sent by the client to another server that has not failed. The distributed system will update the new cluster view to the client and the server through the monitor component. After the client sends a query request for the non-idempotent request to the server that has not failed, the server will process it in two situations. One is that the non-idempotent request has not been processed by the failed server, and the server that has not failed needs to receive and process the non-idempotent request again, so it will return a message of the resent non-idempotent request to the client. The other is that the non-idempotent request has been processed by the failed server, and the processing result will be returned to the client. It can be seen that this application does not need to persist the non-idempotent request to support the server restart failure scenario, so the performance is better.
[0063] Further, in one embodiment, the request identifier is incremented when the client sends a new non-idempotent request to the server, and the request sent by the client also includes a minimum request identifier, and the minimum request identifier is the minimum value of the request identifiers of the non-idempotent requests that have not been processed by the client. After step S10, the following is included:
[0064] The server deletes the records whose request IDs are smaller than the minimum request ID.
[0065] In this embodiment, recording the client identifier and request identifier on the server side will occupy the server side's resources. Therefore, it is necessary to delete and clean up the client identifier and request identifier recorded on the server side, and set the request identifier to increment when the client sends a new non-idempotent request to the server. In addition to the client identifier, request identifier and retransmission identifier, the request sent by the client may also include a minimum request identifier. The minimum request identifier is the minimum value among the request identifiers of the non-idempotent requests that have not been processed by the client. After receiving the minimum request identifier, the server side can determine that the client has processed the non-idempotent requests that are smaller than the minimum request identifier through the minimum request identifier. Therefore, the records with request identifiers smaller than the minimum request identifier in the record can be deleted on the server side.
[0066] In a second aspect, an embodiment of the present application also provides a disposable semantic device.
[0067] In one embodiment, referring to Figure 4 , Figure 4 This is a functional module diagram of an embodiment of a one-time semantic device of the present application, such as Figure 4 As shown, the one-time semantic device includes:
[0068] The receiving module 10 is used for receiving the request sent by the client at the server end, wherein the request sent by the client includes a client identifier, a request identifier and a resend identifier;
[0069] Processing module 20, used for when the request sent by the client is a non-idempotent request, if the resend flag is yes and the server does not have the client flag and request flag record, or the resend flag is no, the server records the client flag and request flag, and processes the non-idempotent request;
[0070] The resending module 30 is used for returning a message of resending the non-idempotent request to the client if the request sent by the client is a query request of a non-idempotent request and if the server does not have the client identifier and the request identifier record.
[0071] Furthermore, in one embodiment, the one-time semantic device further includes a sending module, which is used to:
[0072] The client sends a non-idempotent request to the server. If the client does not receive the processing result of the non-idempotent request returned by the server within a preset time, it sends a query request of the non-idempotent request to the server.
[0073] Furthermore, in one embodiment, the one-time semantic device further includes a return module, which is used to:
[0074] When the request sent by the client is a query request of a non-idempotent request, if the server has the client ID and request ID records, it determines whether the non-idempotent request has been processed through query;
[0075] If the non-idempotent request is not processed, a message for resending the query request for the non-idempotent request is returned to the client;
[0076] If the non-idempotent request has been processed, the processing result is returned to the client.
[0077] Furthermore, in one embodiment, the one-time semantic device further includes a fault handling module, which is used to:
[0078] When the distributed system detects that a server fails after receiving a non-idempotent request from a client, it forwards the non-idempotent request sent by the client to another server that has not failed;
[0079] After receiving the query request of the non-idempotent request sent by the client, the server that has not failed will return a message of resending the non-idempotent request to the client if the non-idempotent request has not been processed by the server that has failed. If the non-idempotent request has been processed by the server that has failed, it will return the processing result to the client.
[0080] Further, in one embodiment, the request identifier is incremented when the client sends a new non-idempotent request to the server, and the request sent by the client also includes a minimum request identifier, and the minimum request identifier is the minimum value of the request identifiers of the non-idempotent requests that have not been processed by the client. The one-time semantic device also includes a deletion module for:
[0081] The server deletes the records whose request IDs are smaller than the minimum request ID.
[0082] Among them, the functional implementation of each module in the above-mentioned one-time semantic device corresponds to the various steps in the above-mentioned one-time semantic method embodiment, and its functions and implementation processes will not be repeated here one by one.
[0083] In a third aspect, an embodiment of the present application provides a disposable semantic device.
[0084] Reference Figure 5 , Figure 5 The hardware structure diagram of the one-time semantic device involved in the embodiment of the present application is shown in FIG. In the embodiment of the present application, the one-time semantic device may include a processor, a memory, a communication interface, and a communication bus.
[0085] The communication bus may be of any type and is used to interconnect the processor, the memory, and the communication interface.
[0086] The communication interface includes input / output (I / O) interface, physical interface and logical interface, etc., which are used to realize the interconnection of devices inside the one-time semantic device, and the interface used to realize the interconnection between the one-time semantic device and other devices (such as other computing devices or user devices). The physical interface can be an Ethernet interface, a fiber optic interface, an ATM interface, etc.; the user device can be a display, a keyboard, etc.
[0087] The memory can be various types of storage media, such as random access memory (RAM), read-only memory (ROM), non-volatile RAM (NVRAM), flash memory, optical storage, hard disk, programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), etc.
[0088] The processor may be a general-purpose processor, and the general-purpose processor may call the one-time semantic program stored in the memory and execute the one-time semantic method provided in the embodiment of the present application. For example, the general-purpose processor may be a central processing unit (CPU). The method executed when the one-time semantic program is called may refer to the various embodiments of the one-time semantic method of the present application, and will not be repeated here.
[0089] Those skilled in the art will understand that Figure 5 The hardware structure shown in the figure does not constitute a limitation on the present application, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0090] In a fourth aspect, an embodiment of the present application also provides a readable storage medium.
[0091] A one-time semantic program is stored on a readable storage medium of the present application, wherein when the one-time semantic program is executed by a processor, the steps of the one-time semantic method described above are implemented.
[0092] Among them, the method implemented when the one-time semantic program is executed can refer to the various embodiments of the one-time semantic method of the present application, and will not be repeated here.
[0093] It should be noted that the serial numbers of the above-mentioned embodiments of the present application are only for description and do not represent the advantages or disadvantages of the embodiments.
[0094] The terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices. The terms "first", "second" and "third" are used to distinguish different objects, etc., and do not represent a sequence, nor do they limit "first", "second" and "third" to different types.
[0095] In the description of the embodiments of the present application, "exemplary", "for example" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary", "for example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary", "for example" or "for example" is intended to present related concepts in a specific way.
[0096] In the description of the embodiments of the present application, unless otherwise specified, “ / ” means or, for example, A / B can mean A or B; the “and / or” in the text is merely a description of the association relationship of associated objects, indicating that three relationships may exist, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, “multiple” refers to two or more than two.
[0097] In some processes described in the embodiments of the present application, multiple operations or steps that appear in a specific order are included, but it should be understood that these operations or steps may not be executed in the order in which they appear in the embodiments of the present application or in parallel, and the sequence number of the operation is only used to distinguish the different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed in sequence or in parallel, and these operations or steps may be combined.
[0098] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD) as described above, and includes a number of instructions for a terminal device to execute the methods described in each embodiment of the present application.
[0099] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A one-shot semantic method, characterized in that Applied to distributed systems, the one-shot semantics method includes: The server receives a request sent by the client, wherein the request sent by the client includes a client identifier, a request identifier, and a resend identifier; When the request sent by the client is a non-idempotent request, if the resend flag is yes and the server does not have the client ID and request ID record, or the resend flag is no, the server records the client ID and request ID and processes the non-idempotent request; When the request sent by the client is a non-idempotent query request, if the server does not have the client ID and request ID records, a message to resend the non-idempotent request is returned to the client; Before the server receives the request sent by the client, it includes: The client sends a non-idempotent request to the server. If the client does not receive the processing result of the non-idempotent request returned by the server within a preset time, it sends a query request of the non-idempotent request to the server.
2. The one-shot semantic method according to claim 1, characterized in that: When the request sent by the client is a query request of a non-idempotent request, if the server does not have a client identifier and a request identifier record, after returning a message of resending the non-idempotent request to the client, the method includes: When the request sent by the client is a query request of a non-idempotent request, if the server has the client ID and request ID records, it determines whether the non-idempotent request has been processed through query; If the non-idempotent request is not processed, a message for resending the query request for the non-idempotent request is returned to the client; If the non-idempotent request has been processed, the processing result is returned to the client.
3. The one-shot semantic method according to claim 1, characterized in that: The one-shot semantic method further comprises: When the distributed system detects that a server fails after receiving a non-idempotent request from a client, it forwards the non-idempotent request sent by the client to another server that has not failed; After receiving the query request of the non-idempotent request sent by the client, the server that has not failed will return a message of resending the non-idempotent request to the client if the non-idempotent request has not been processed by the server that has failed. If the non-idempotent request has been processed by the server that has failed, it will return the processing result to the client.
4. The one-shot semantic method according to claim 1, characterized in that: The request identifier is incremented when the client sends a new non-idempotent request to the server. The request sent by the client also includes a minimum request identifier, which is the minimum value of the request identifiers of the non-idempotent requests that have not been processed by the client. After the server receives the request sent by the client, it includes: The server deletes the records whose request IDs are smaller than the minimum request ID.
5. A one-time semantic device, characterized in that Applied to a distributed system, the one-time semantic device comprises: A receiving module, configured to receive a request sent by a client at a server end, wherein the request sent by the client includes a client identifier, a request identifier, and a resend identifier; A processing module, used for, when the request sent by the client is a non-idempotent request, if the resend flag is yes and the server does not have the client flag and the request flag record, or the resend flag is no, the server records the client flag and the request flag, and processes the non-idempotent request; The resending module is used to return a message of resending the non-idempotent request to the client if the request sent by the client is a query request of a non-idempotent request and if the server does not have the client identifier and the request identifier record; The one-time semantic device also includes a sending module, which is used to: The client sends a non-idempotent request to the server. If the client does not receive the processing result of the non-idempotent request returned by the server within a preset time, it sends a query request of the non-idempotent request to the server.
6. The disposable semantic device according to claim 5, characterized in that: The one-time semantic device also includes a return module, which is used to: When the request sent by the client is a query request of a non-idempotent request, if the server has the client ID and request ID records, it determines whether the non-idempotent request has been processed through query; If the non-idempotent request is not processed, a message for resending the query request for the non-idempotent request is returned to the client; If the non-idempotent request has been processed, the processing result is returned to the client.
7. A disposable semantic device, characterized in that The one-time semantic device includes a processor, a memory, and a one-time semantic program stored in the memory and executable by the processor, wherein the one-time semantic program, when executed by the processor, implements the steps of the one-time semantic method according to any one of claims 1 to 4.
8. A readable storage medium, characterized in that: The readable storage medium stores a one-time semantic program, wherein when the one-time semantic program is executed by a processor, the steps of the one-time semantic method according to any one of claims 1 to 4 are implemented.
