Timestamp assignment method, device, storage medium and system

By employing a timestamp service cluster in a distributed storage system, where multiple servers jointly provide logical timestamp allocation services, the availability problem of centralized services in the event of master node failure is solved, achieving high availability and linear consistency in logical timestamp allocation.

CN116388916BActive Publication Date: 2026-01-02ALIBABA (CHINA) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310378615.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-31
Publication Date
2026-01-02
Estimated Expiration
2043-03-31

AI Technical Summary

Technical Problem

In distributed storage systems, due to inconsistencies in data modification results caused by different network speeds, existing centralized timestamp allocation services have poor availability when the master node fails.

Method used

A timestamp service cluster uses multiple servers to provide logical timestamp allocation services, ensuring that the logical timestamps monotonically increase and maintaining service availability through other servers in the cluster in the event of a failure.

Benefits of technology

It improves the availability and linear consistency of the timestamp allocation service, ensuring that the logical timestamps obtained by the client are consistent with the request order, and avoiding service interruptions caused by master node failure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116388916B_ABST
    Figure CN116388916B_ABST
Patent Text Reader

Abstract

The application provides a timestamp allocation method, device, storage medium and system, the method comprises: in response to the timestamp acquisition request of the client, determining the first logical timestamp to be fed back from the monotonically increasing logical timestamp generated in turn according to the set timestamp generation strategy, sending the first logical timestamp to the client, so that the client determines the target logical timestamp from a group of received logical timestamps. Wherein, a group of logical timestamps includes the first logical timestamp fed back by different servers in response to the timestamp acquisition request, and the target logical timestamp is the first logical timestamp arranged in the first number position after a group of logical timestamps are sorted from small to large. In the above scheme, a plurality of servers in the timestamp service cluster can simultaneously respond to the timestamp acquisition request of the client, when a certain server is down, the timestamp service cluster can always provide services, and the availability of the timestamp allocation service is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of Internet, and in particular to a timestamp allocation method, device, storage medium and system. BACKGROUND

[0002] In many scenarios, the problem of distinguishing the occurrence order of events is encountered. For example, in a distributed storage system including a plurality of storage nodes, the same data is stored in different storage nodes in the form of multiple copies (such as three copies), and it is assumed that two clients simultaneously modify the same data. Due to the different network speeds of the clients, a certain storage node storing the data may first receive the request of client A and then receive the request of client B, while another storage node storing the data first receives the request of client B and then receives the request of client A, thereby causing two different data modification results in the two storage nodes, resulting in data inconsistency. In order to ensure the consistency of the modification results of the same data in the different storage nodes, each client can obtain a timestamp before requesting to modify the data, and the storage node determines the execution order according to the timestamp corresponding to the data modification request of each client, so as to ensure the consistency of the data modification results.

[0003] Logical clocks can be used to distinguish the occurrence order of different events, such as Lamport clock, and each event is associated with a logical timestamp (an integer starting from 0 and increasing). There are two ways to obtain a logical timestamp, centralized and non-centralized. When using a centralized way to obtain a logical timestamp, a request can be sent to a master node providing a centralized timestamp allocation service to obtain a logical timestamp, and the node assigns an increasing logical timestamp according to the order of different requests. However, if the master node fails, a new master node needs to be selected, and the switching from the original master node to the new master node needs to be completed. During the switching process, there is a period of time when the timestamp service is unavailable. SUMMARY

[0004] Embodiments of the present application provide a timestamp allocation method, device, storage medium and system to improve the availability of timestamp allocation service.

[0005] In a first aspect, embodiments of the present application provide a timestamp allocation method applied to a target server in a timestamp service cluster, the target server being any one of a plurality of servers in the timestamp service cluster, and the method comprising:

[0006] In response to a timestamp acquisition request of a client, determining a first logical timestamp to be fed back from monotonically increasing logical timestamps generated in sequence according to a set timestamp generation strategy;

[0007] send the first logical timestamp to the client, so that the client determines a target logical timestamp from a set of logical timestamps received;

[0008] The set of logical timestamps includes the first logical timestamp fed back by different servers in response to the timestamp acquisition request; and the target logical timestamp is the first logical timestamp in a first number position after the set of logical timestamps is sorted in ascending order.

[0009] The logical timestamp in the first number position presents a monotonic increasing trend in different sets of logical timestamps fed back by the timestamp service cluster for different timestamp acquisition requests received in sequence.

[0010] In a second aspect, an embodiment of the present application provides a timestamp allocation apparatus applied to a target server in a timestamp service cluster, the target server being any one of a plurality of servers in the timestamp service cluster, and the apparatus comprising:

[0011] A determination module configured to determine, in response to a timestamp acquisition request from a client, a first logical timestamp to be fed back currently from logical timestamps sequentially generated according to a set timestamp generation strategy and presenting a monotonic increasing trend;

[0012] A sending module configured to send the first logical timestamp to the client, so that the client determines a target logical timestamp from a set of logical timestamps received;

[0013] The set of logical timestamps includes the first logical timestamp fed back by different servers in response to the timestamp acquisition request; and the target logical timestamp is the first logical timestamp in a first number position after the set of logical timestamps is sorted in ascending order.

[0014] The logical timestamp in the first number position presents a monotonic increasing trend in different sets of logical timestamps fed back by the timestamp service cluster for different timestamp acquisition requests received in sequence.

[0015] In a third aspect, an embodiment of the present application provides an electronic device comprising a memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the timestamp allocation method according to the first aspect.

[0016] In a fourth aspect, an embodiment of the present application provides a non-transitory machine readable storage medium, and the non-transitory machine readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor can at least implement the timestamp allocation method according to the first aspect.

[0017] In a fifth aspect, an embodiment of the present application provides a timestamp allocation method applied to a client, the method comprising:

[0018] obtaining identification information of a plurality of servers in a timestamp service cluster;

[0019] sending, according to the identification information of the plurality of servers, a timestamp obtaining request to the plurality of servers;

[0020] receiving a set of logical timestamps fed back by the plurality of servers, the set of logical timestamps comprising first logical timestamps fed back by different servers in response to the timestamp obtaining request, wherein each server determines the first logical timestamp to be fed back from monotonically increasing logical timestamps sequentially generated according to a set timestamp generation strategy;

[0021] if a quantity of the set of logical timestamps meets a set condition, determining a target logical timestamp from the set of logical timestamps, wherein the target logical timestamp is a first logical timestamp arranged at a target number taking position after the set of logical timestamps is sorted in ascending order; and wherein logical timestamps at the target number taking position present a monotonically increasing trend in different sets of logical timestamps fed back by the timestamp service cluster in response to sequentially received different timestamp obtaining requests.

[0022] In a sixth aspect, an embodiment of the present application provides a timestamp allocation device applied to a client, the device comprising:

[0023] an obtaining module configured to obtain identification information of a plurality of servers in a timestamp service cluster;

[0024] a sending module configured to send, according to the identification information of the plurality of servers, a timestamp obtaining request to the plurality of servers;

[0025] a receiving module configured to receive a set of logical timestamps fed back by the plurality of servers, the set of logical timestamps comprising first logical timestamps fed back by different servers in response to the timestamp obtaining request, wherein each server determines the first logical timestamp to be fed back from monotonically increasing logical timestamps sequentially generated according to a set timestamp generation strategy;

[0026] a determining module configured to, if a quantity of the set of logical timestamps meets a set condition, determine a target logical timestamp from the set of logical timestamps, wherein the target logical timestamp is a first logical timestamp arranged at a target number taking position after the set of logical timestamps is sorted in ascending order; and wherein logical timestamps at the target number taking position present a monotonically increasing trend in different sets of logical timestamps fed back by the timestamp service cluster in response to sequentially received different timestamp obtaining requests.

[0027] In a seventh aspect, an electronic device is provided, and includes a memory, a processor, and a communication interface. The memory has stored executable code that, when executed by the processor, causes the processor to perform the timestamp allocation method of the fifth aspect.

[0028] In an eighth aspect, a non-transitory machine-readable storage medium is provided, and has stored executable code that, when executed by a processor of an electronic device, causes the processor to implement at least the timestamp allocation method of the fifth aspect.

[0029] In a ninth aspect, a timestamp allocation system is provided, and includes a client and a timestamp service cluster.

[0030] The client is configured to obtain identification information of a plurality of servers in the timestamp service cluster, send a timestamp acquisition request to the plurality of servers according to the identification information of the plurality of servers, and determine a target logical timestamp from a group of logical timestamps when a quantity of the group of logical timestamps received satisfies a set condition, wherein the target logical timestamp is a logical timestamp at a target number taking position after the group of logical timestamps are sorted in ascending order.

[0031] Each server in the timestamp service cluster is configured to determine a logical timestamp to be fed back from a group of monotonically increasing logical timestamps generated in sequence according to a set timestamp generation strategy, and send the logical timestamp to the client. The group of logical timestamps includes logical timestamps fed back by different servers in response to the timestamp acquisition request. The logical timestamp at the target number taking position in different groups of logical timestamps fed back by the timestamp service cluster in response to different timestamp acquisition requests received in sequence presents a monotonically increasing trend.

[0032] In the timestamp allocation scheme provided by the embodiments of the present application, a timestamp service cluster comprising a plurality of servers provides logical timestamp allocation services for clients. Specifically, when a certain client needs to obtain a logical timestamp, the client sends a timestamp acquisition request to each server in the cluster. For any target server in the cluster, in the process of allocating a timestamp, the target server first determines a first logical timestamp to be fed back from the monotonically increasing logical timestamps generated in sequence according to a set timestamp generation strategy, and sends the first logical timestamp to the client. The client can receive the first logical timestamps fed back by all or part of the servers, and determine a target logical timestamp from the received set of logical timestamps, wherein the target logical timestamp is the first logical timestamp arranged at a set first number-taking position after the set of logical timestamps is sorted in ascending order. In addition, the logical timestamps arranged at the first number-taking position in different sets of logical timestamps fed back by the timestamp service cluster in response to different timestamp acquisition requests received in sequence exhibit a monotonically increasing trend.

[0033] In the above scheme, the logical timestamps generated by each server in the timestamp service cluster are monotonically increasing, and the logical timestamps arranged at the first number-taking position in different sets of logical timestamps fed back by the timestamp service cluster in response to different timestamp acquisition requests received in sequence exhibit a monotonically increasing trend, which ensures the linear consistency of the target logical timestamps obtained by the client, i.e., the sizes of the target logical timestamps finally obtained by different clients are adapted to the orders in which the clients send timestamp acquisition requests, and the situation that a client obtains a larger logical timestamp than another client does not occur. Moreover, the plurality of servers in the timestamp service cluster simultaneously provide timestamp allocation services for the client, so that when a certain server in the timestamp service cluster is down, the other servers in the timestamp service cluster can still provide timestamp allocation services for the client, thereby improving the availability of the timestamp allocation services. BRIEF DESCRIPTION OF DRAWINGS

[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments description. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without any creative effort on the basis of these drawings.

[0035] Figure 1 A composition schematic diagram of a timestamp allocation system provided by the embodiments of the present application;

[0036] Figure 2 A flowchart of a timestamp allocation method provided by the embodiments of the present application;

[0037] Figure 3 A flow chart of a timestamp allocation method provided by an embodiment of the present application;

[0038] Figure 4 A schematic diagram of a timestamp acquisition principle provided by an embodiment of the present application;

[0039] Figure 5 A flow chart of a timestamp allocation method provided by an embodiment of the present application;

[0040] Figure 6 A flow chart of a timestamp allocation method provided by an embodiment of the present application;

[0041] Figure 7 A schematic diagram of a server update event processing process provided by an embodiment of the present application;

[0042] Figure 8 A flow chart of a timestamp allocation method provided by an embodiment of the present application;

[0043] Figure 9 A flow chart of a client determining a target logical timestamp provided by an embodiment of the present application;

[0044] Figure 10 A structural schematic diagram of a timestamp allocation apparatus provided by an embodiment of the present application;

[0045] Figure 11 A structural schematic diagram of an electronic device provided by an embodiment of the present application;

[0046] Figure 12 A structural schematic diagram of a timestamp allocation apparatus provided by an embodiment of the present application;

[0047] Figure 13 A structural schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0048] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of the present application.

[0049] In addition, the step sequence in each of the following method embodiments is only an example, not a strict limitation.

[0050] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the embodiments of the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation portal for user to choose authorization or rejection.

[0051] Some concepts involved in the embodiments of the present application will be introduced briefly.

[0052] Logical clock: a time mechanism used to distinguish the occurrence order of events. In a sense, the physical time in the real world is actually a special case of logical clock. In a distributed system, logical clock is mainly used to guarantee the relative consistency (synchronization) between system node progress. The purpose of synchronization is to maintain the sequence of events. There is no general explicit relationship between logical clock and physical clock.

[0053] Lamport clock is an implementation of logical clock. Each event can be associated with a Lamport logical timestamp (an integer starting from 0 and increasing).

[0054] TSO: Timestamp Oracle, a centralized logical timestamp service, also known as a global sequencer. Clients can request a logical timestamp from the TSO server. The assigned logical timestamp meets the actual causal order of the request, that is, if a request is physically completed after a request, the a request is before the b request, and the logical timestamp of the a request is less than the logical timestamp of the b request. As described above, in the traditional timestamp allocation service based on TSO, a master node is set to provide TSO service. When the master node is down and cannot provide timestamp allocation service, a new master node is selected from other nodes to complete the switching of the master node, and the new master node continues to provide timestamp allocation service. However, selecting a new master node and switching the master node consumes a certain amount of time, which will cause the timestamp allocation service to be unavailable to the outside during this period, resulting in poor availability.

[0055] However, in the above timestamp allocation service with master node, since only one master node provides timestamp service to the outside at the same time, the logical timestamps obtained by each client requesting the master node will have good linear consistency. Linear consistency can be simply understood as follows: according to the order of each client requesting the master node, the master node will eventually assign a monotonically increasing logical timestamp to each client, and the logical timestamp obtained by the client requesting first will not be greater than the logical timestamp obtained by the client requesting later.

[0056] In order to overcome the unavailability problem of the timestamp allocation service with the master node and guarantee the linear consistency index, the embodiment of the present application provides a new timestamp allocation scheme. In the timestamp allocation scheme, a timestamp service cluster containing multiple servers provides the allocation service of the logical timestamp for the client, that is, the timestamp acquisition request of a certain client is responded by multiple servers in the cluster, so that even if part of the servers in the cluster fail, the client can still obtain the logical timestamp, and the availability is guaranteed. In addition, in order to guarantee the linear consistency, on the one hand, the logical timestamps generated by the servers in the timestamp service cluster are monotonically increasing, and on the other hand, among the different groups of logical timestamps fed back by the timestamp service cluster for different timestamp acquisition requests received in turn, the logical timestamp at the set first number position presents a monotonically increasing trend, so that the linear consistency of the logical timestamp finally obtained by the client is guaranteed, that is, the size of the target logical timestamp finally obtained by different clients is adapted to the order in which the clients send the timestamp acquisition request.

[0057] Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The following embodiments and features in the embodiments can be combined with each other without conflict.

[0058] The timestamp allocation method provided by the embodiment of the present application can be applied to Figure 1 The timestamp allocation system shown in the figure can include a client and a timestamp service cluster.

[0059] The client can be various terminal devices or application programs with timestamp acquisition requirements.

[0060] The timestamp service cluster includes multiple servers, such as the server 1, the server 2, …, and the server N shown in the figure, and the multiple servers can simultaneously provide the timestamp allocation service for the client. Figure 1

[0061] In actual application, in order to better distinguish and manage each server in the timestamp service cluster, each server in the timestamp service cluster can be numbered, so that each server has its own identification information. For example, the server 1 corresponds to the number 1, the server 2 corresponds to the number 2, and the server N corresponds to the number N. Figure 1 In addition, the identification information of the server can also include the communication address of each server, such as the IP address.

[0062] ​The servers in the timestamp service cluster mainly assign logical timestamps to clients. Each server has a logical clock, and the logical clock generates a plurality of monotonically increasing logical timestamps in sequence according to a set timestamp generation strategy. That is, the logical timestamps generated by each server are monotonically increasing. The timestamp generation strategy can be set according to actual needs, and the specific form of the timestamp generation strategy is not limited as long as the logical timestamps generated according to the timestamp generation strategy are monotonically increasing.

[0063] In order to use the plurality of servers in the above-mentioned timestamp service cluster to obtain logical timestamps, the client needs to know the identification information of each server included in the cluster.

[0064] Optionally, the above-mentioned timestamp assignment system can further include a storage system, and the storage system stores timestamp configuration information, such as a current version number of the timestamp service cluster, identification information of each server in the timestamp service cluster corresponding to the version number, and a set number taking parameter and the like.

[0065] The version number is actually used to represent the number of servers currently included in the timestamp service cluster. When the number of servers increases or decreases (that is, when the capacity is expanded or reduced), the version number will be updated, and the above-mentioned timestamp configuration information corresponding to the version number will also be updated, which will be described in detail below.

[0066] In actual application, the client can query the storage system to obtain the identification information of the plurality of servers in the current timestamp service cluster, and send a timestamp obtaining request to the plurality of servers according to the identification information of the plurality of servers.

[0067] The plurality of normally working servers in the timestamp service cluster can respond to the timestamp obtaining request of the client, and determine the current logical timestamp to be fed back from the monotonically increasing logical timestamps generated in sequence according to the set timestamp generation strategy, and send the logical timestamp to the client. Each server will generate a plurality of monotonically increasing logical timestamps in sequence according to the set timestamp generation strategy. When completing a timestamp assignment, each server will update the to-be-fed-back timestamp used when receiving a timestamp obtaining request next time, that is, determine the next to-be-fed-back logical timestamp. The next to-be-fed-back logical timestamp is not necessarily the next one adjacent to the last assigned logical timestamp, but can be a certain logical timestamp after a plurality of intervals.

[0068] Since the client sends the timestamp obtaining request to multiple servers in the timestamp service cluster at the same time when requesting the timestamp, if multiple servers in the timestamp service cluster can normally provide the timestamp allocation service for the client, the multiple servers can all respond to the timestamp obtaining request of the client and send the respective current logical timestamp to be fed back to the client, so that the client receives a set of logical timestamps in one process of requesting the timestamp allocation. The set of logical timestamps includes the logical timestamps fed back by different servers in response to the timestamp obtaining request.

[0069] After receiving the set of logical timestamps, the client determines the number of the received set of logical timestamps. Since in actual application, a server in the timestamp service cluster may suddenly appear to be down during operation, so that the server cannot respond to the timestamp obtaining request of the client and cannot allocate the current logical timestamp to be fed back to the client when the server appears to be down. Therefore, after the client sends the timestamp obtaining request to multiple servers in the timestamp service cluster, the client may not receive the logical timestamp fed back by some servers, so that the client can determine whether the number of the received set of logical timestamps meets the set condition after determining the number of the received set of logical timestamps. The set condition can be set according to actual needs, which is not limited herein.

[0070] Then, the client determines the target logical timestamp from the set of logical timestamps when determining that the number of the received set of logical timestamps meets the set condition. The target logical timestamp is the logical timestamp arranged at the target number taking position in the set of logical timestamps sorted in ascending order, and the target number taking position (i.e., the number taking parameter in the above) can be set in advance. Moreover, the logical timestamp at the target number taking position in different sets of logical timestamps fed back by the timestamp service cluster in response to different timestamp obtaining requests received in sequence presents a monotonically increasing trend, so that the target timestamp obtained by the client is monotonically increasing, thereby effectively preventing the phenomenon that the logical timestamp obtained by the client is retrogressed (the logical timestamp obtained by the previous request is greater than the logical timestamp obtained by the subsequent request).

[0071] In summary, in the above embodiment, by simultaneously sending the timestamp obtaining request to multiple servers in the timestamp service cluster, the multiple servers can simultaneously respond to the timestamp obtaining request of the client and send the respective current logical timestamp to be fed back to the client, so that when a small number of servers in the timestamp service cluster appear to be down, other servers in the timestamp service cluster can still provide the timestamp allocation service for the client, that is, the timestamp service cluster in the timestamp allocation system has fault tolerance, thereby improving the availability of the timestamp allocation service.

[0072] The main functions of different component units in the timestamp allocation system are introduced above, and the process of timestamp allocation is described in detail in combination with the following embodiments.

[0073] Figure 2 A flowchart of a timestamp allocation method provided by the embodiment of the present application is shown in FIG. 2, and the method can be executed by Figure 2 Figure 2 The target server is any one of the plurality of servers in the timestamp service cluster, as shown in FIG. 1.

[0074] 201. In response to the timestamp acquisition request of the client, a first logical timestamp to be fed back is determined from the monotonically increasing logical timestamps generated in sequence according to the preset timestamp generation strategy.

[0075] 202. The first logical timestamp is sent to the client, so that the target logical timestamp is determined from a group of logical timestamps received by the client, wherein the group of logical timestamps comprises the first logical timestamps fed back by different servers in response to the timestamp acquisition request of the client, and the target logical timestamp is the first logical timestamp arranged at the first number position after the group of logical timestamps is sorted in ascending order.

[0076] The timestamp allocation method provided by the embodiment of the present application can be applied to any server in the timestamp service cluster, and the operations performed by each server in the timestamp service cluster are basically consistent, so the target server is taken as an example in the embodiment of the present application.

[0077] As described above, when the client has a timestamp acquisition demand, the timestamp acquisition request is sent to the plurality of servers in the timestamp service cluster, and the target server determines the first logical timestamp to be fed back from the monotonically increasing logical timestamps generated in sequence according to the preset timestamp generation strategy after receiving the timestamp acquisition request sent by the client. The timestamp generation strategy can be set according to actual needs, as long as the logical timestamps generated according to the timestamp generation strategy are monotonically increasing.

[0078] ​In one optional embodiment, the specific implementation of the timestamp generation strategy may include: generating a monotonically increasing logical timestamp corresponding to each server based on the server's number, a set modulo parameter, and a multiplier that increments the modulo parameter sequentially. Specifically, the servers in the timestamp service cluster can be pre-numbered so that each server has a unique number. Furthermore, the servers share the modulo parameter and its multipliers, where the value of the modulo parameter is greater than or equal to the total number of servers in the timestamp service cluster. For example, the timestamp service cluster may include three servers, numbered Server 1, Server 2, and Server 3. If the modulus parameter is set to be greater than or equal to 3, for example, a value of 3, and the multiple of the modulus parameter is represented by t, where t≥0, then server 1 can generate multiple logical timestamps such as 1, 4, 7, 10... sequentially according to the set timestamp strategy of 3t+1; server 2 can generate multiple logical timestamps such as 2, 5, 8, 11... sequentially according to the set timestamp strategy of 3t+2; and server 3 can generate multiple logical timestamps such as 3, 6, 9, 12... sequentially according to the set timestamp strategy of 3t+3. This set timestamp generation strategy can ensure that the logical timestamps generated by each server are monotonically increasing.

[0079] Alternatively, in an optional embodiment, the modulus parameter and its multiples can be stored in... Figure 1 In the storage system shown, each server can obtain the modulus parameter and its multiples from the storage system, and based on the obtained modulus parameter, its multiples, and their respective server IDs, generate multiple monotonically increasing logical timestamps. Each server will generate multiple logical timestamps according to a predetermined timestamp generation strategy. Therefore, during timestamp allocation, to ensure the linear consistency of the logical timestamps obtained by the client, it is necessary to ensure that the logical timestamp currently allocated by each server is less than the logical timestamp allocated at the next moment. Thus, when the target server responds to the client's timestamp retrieval request, it can determine the first logical timestamp to be fed back from the generated monotonically increasing logical timestamps.

[0080] In fact, each time the target server feeds back a logical timestamp to a client in response to a timestamp acquisition request from the client, the current logical timestamp to be fed back is updated to the next logical timestamp. Therefore, the "first logical timestamp to be fed back" is actually the next logical timestamp to be assigned among the monotonically increasing logical timestamps generated by the target server. For example, the target server generates logical timestamps 1, 3, 5, 7, 9, and so on, where 1 and 3 have been assigned to clients, and the current logical timestamp to be fed back by the target server is 5. When the target server receives a timestamp acquisition request from a client, the first logical timestamp 5 to be fed back is sent to the client, and then the current logical timestamp to be fed back by the target server is updated to the next logical timestamp 7.

[0081] Each server in the timestamp service cluster that receives the timestamp acquisition request from the client feeds back a first logical timestamp to the client according to the above process, so that the client can determine the target logical timestamp from a set of logical timestamps received, where the set of logical timestamps includes the first logical timestamps fed back by different servers in response to the timestamp acquisition request, and the target logical timestamp is the first logical timestamp in the first number position after the set of logical timestamps is sorted in ascending order.

[0082] Since the target logical timestamp is the first logical timestamp in the first number position after the set of logical timestamps sent by the timestamp service cluster is sorted in ascending order, in order to ensure that the target logical timestamp obtained by the client or other clients in the future does not retrogress (i.e., the logical timestamp of a subsequent request is smaller than that of a previous request), the logical timestamp in the first number position in different sets of logical timestamps fed back by the timestamp service cluster in response to different timestamp acquisition requests received in sequence presents a monotonically increasing trend.

[0083] The first number position is actually a number parameter, denoted as M. In actual applications, the value of M can be set according to the number N of servers included in the current timestamp service cluster, and M is less than N. In fact, M can be considered as the fault tolerance of the timestamp service cluster, that is, the timestamp service cluster can still provide reliable logical timestamp assignment services to clients when M servers in the timestamp service cluster fail. Alternatively, the value of M can be determined as the integer part of the median of the total number N of servers, but this is not limited thereto.

[0084] Suppose M = 2. As described above, after the client receives a set of logical timestamps and sorts them in ascending order, the Mth smallest first logical timestamp is taken out as the target logical timestamp requested by the client this time, and the other first logical timestamps can be discarded.

[0085] Based on this, it can be understood that after receiving the above set of logical timestamps, the client needs to determine whether the total number of the first logical timestamp contained in the set of logical timestamps meets the set condition, such as whether it is greater than or equal to the value M corresponding to the first number position. Alternatively, if the number of the set of logical timestamps is greater than or equal to the value M corresponding to the first number position, the client can obtain the target logical timestamp; if the number of the set of logical timestamps is less than the value M corresponding to the first number position, the client cannot obtain the target logical timestamp, the request fails, at this time the client can re-initiate the timestamp acquisition request after a period of time.

[0086] In the embodiment of the application, the logical timestamps generated by each server in the timestamp service cluster are monotonically increasing, and the logical timestamps at the set first number position in different sets of logical timestamps fed back by the timestamp service cluster for different timestamp acquisition requests received in turn show a monotonically increasing trend, which ensures the linear consistency of the target logical timestamp finally obtained by the client, that is, the size of the target logical timestamp finally obtained by different clients is adapted to the order in which these clients send timestamp acquisition requests, and the situation that the logical timestamp obtained by a client sending a request first is greater than the logical timestamp obtained by a client sending a request later does not occur. Moreover, the multiple servers in the timestamp service cluster simultaneously provide timestamp allocation services for the client, so that when a server in the timestamp service cluster is down, other servers in the timestamp service cluster can still provide timestamp allocation services for the client at all times, improving the availability of the timestamp allocation service.

[0087] As described above, assuming that the current timestamp service cluster contains N servers, in response to a timestamp acquisition request of a client, all or part of the N servers may have fed back respective first logical timestamps to the client, and after receiving a set of logical timestamps composed of these first logical timestamps, the client determines the first logical timestamp at the first number position in the set of logical timestamps as the target logical timestamp when determining that the number of the set of logical timestamps meets the set condition.

[0088] In an optional embodiment, if the number of the set of logical timestamps is N, that is, equal to the total number of servers, after determining the first logical timestamp at the first number position in the set of logical timestamps as the target logical timestamp, it is directly determined that the target logical timestamp is valid, the local request ends, and the target logical timestamp can be directly used for subsequent processes, such as a modification operation on data stored in a database.

[0089] In another optional embodiment, if the number of the set of logical timestamps is greater than or equal to M and less than N, where M is the value corresponding to the first drawing position, then after determining the first logical timestamp in the first drawing position as the target logical timestamp from the set of logical timestamps, a timestamp synchronization process needs to be performed, and after successfully completing the process, the target logical timestamp is determined to be valid, and the target logical timestamp can be used for subsequent processes. Reference Figure 3 is described.

[0090] Figure 3 A flowchart of a timestamp allocation method provided by an embodiment of the present application is shown in the figure. The method can be performed by a target server in a timestamp service cluster, where the target server is any server in the timestamp cluster, as shown in the figure. Figure 1 The method further includes the following steps: Figure 3

[0091] 301. Receive a timestamp synchronization request sent by a client, where the timestamp synchronization request includes a target logical timestamp.

[0092] The timestamp synchronization request is sent by the client to the server that has not fed back the first logical timestamp (assuming that the target server is included) when it is determined that the number of a set of logical timestamps is greater than or equal to the value corresponding to the first drawing position and less than the total number of servers in the timestamp service cluster, the first logical timestamp fed back is less than the target logical timestamp, and the first logical timestamp is not fed back.

[0093] 302. Send the second logical timestamp currently to be fed back and the logical timestamp with the larger value in the target logical timestamp to the client, so that the client determines that the target logical timestamp is valid when it is determined that the sum of the number of logical timestamps corresponding to the timestamp synchronization request received by the client and the number of first logical timestamps in the set of logical timestamps received by the client is greater than or equal to the target number.

[0094] The target number is determined according to the difference between the total number of servers N in the current timestamp service cluster and the value M corresponding to the first drawing position, for example, N-M+1.

[0095] 303. Update the third logical timestamp to be fed back next to be greater than the target logical timestamp according to the target logical timestamp.

[0096] In this embodiment, if the number of the set of logical timestamps received by the client is greater than or equal to M and less than N, it indicates that part of the servers in the current timestamp service cluster have not received the timestamp acquisition request sent by the client, or have not successfully fed back the corresponding first logical timestamp after receiving the request.

[0097] ​At this time, in order to ensure that any client subsequently obtains a target logical timestamp greater than the target logical timestamp obtained by the above client this time, that is, to ensure the linear consistency of the logical timestamp allocation result, the above client sends a timestamp synchronization request to the server that has not fed back the first logical timestamp and whose fed back first logical timestamp is less than the target logical timestamp determined this time after obtaining the target logical timestamp corresponding to this time, so that the server updates the next third logical timestamp to be fed back based on the timestamp synchronization request to be greater than the target logical timestamp.

[0098] Assuming that the target server is one of the "servers that have not fed back the first logical timestamp and whose fed back first logical timestamp is less than the target logical timestamp determined this time", and assuming that the target server can receive the above timestamp synchronization request, the target server compares the target logical timestamp included in the timestamp synchronization request with the second logical timestamp currently to be fed back by the target server, and sends the logical timestamp with the greater value of the second logical timestamp and the target logical timestamp to the client. Moreover, the target server updates the next third logical timestamp to be fed back based on the target logical timestamp in the timestamp synchronization request to be greater than the target logical timestamp. In fact, if the target server successfully feeds back a first logical timestamp in response to the timestamp acquisition request of the client, the second logical timestamp currently to be fed back by the target server when it receives the above timestamp synchronization request is the next logical timestamp of the first logical timestamp previously fed back by the target server.

[0099] In a timestamp updating process, if the client determines that the number of logical timestamps corresponding to the timestamp synchronization request received by the client and the sum of the number of first logical timestamps not less than the target logical timestamp in the set of logical timestamps is greater than or equal to the target number (such as N-M+1), the timestamp synchronization updating is determined to be successful, and the target logical timestamp is valid. Moreover, through the synchronization process, the next logical timestamp to be fed back by at least N-M+1 servers is greater than the target logical timestamp determined this time, so that the logical timestamp at the first numbering position in the set of logical timestamps fed back by the timestamp service cluster for the subsequent received timestamp acquisition request presents a monotonically increasing trend, thereby ensuring that the target logical timestamp obtained by the client next time is greater than the target logical timestamp obtained this time.

[0100] In fact, the number of logical timestamps corresponding to the timestamp synchronization request received by the client and the sum of the number of first logical timestamps not less than the target logical timestamp in the set of logical timestamps being greater than or equal to the target number means that the number of servers in the timestamp service cluster whose next logical timestamp to be fed back is not less than the target logical timestamp needs to be greater than or equal to the target number.

[0101] In an optional embodiment, the specific implementation of updating the next third logical timestamp to be fed back according to the target logical timestamp greater than the target logical timestamp can include: determining the next third logical timestamp to be fed back of the target server according to the logical timestamp with the greater value between the target logical timestamp and the second logical timestamp currently to be fed back of the target server, and the number of the target server and the set modulo parameter.

[0102] Specifically, the updating process can be represented as:

[0103] Response max(S,X),

[0104] Write n×(max(S,X) / n+1)+id

[0105] wherein X represents the target logical timestamp, S represents the second logical timestamp currently to be fed back of the target server (in fact, it is the next logical timestamp of the first logical timestamp in the above), n represents the modulo parameter, / represents the integer operator, and id represents the number of the target server. Wherein, response represents feeding back the logical timestamp with the greater value between the second logical timestamp S currently to be fed back of the target server and the target logical timestamp X to the client; write represents updating the next third logical timestamp to be fed back after the second logical timestamp to n×(max(S,X) / n+1)+id.

[0106] In order to more intuitively understand the timestamp allocation scheme introduced in the above embodiments, the following Figure 4 is taken as an example for illustrative purposes.

[0107] In Figure 4 , it is assumed that the current timestamp service cluster includes N (N=3) servers, namely server 1, server 2 and server 3, the first number position corresponds to the value M=2, and the modulo parameter n=3. According to the set timestamp generation strategy (id, n+id, 2n+id, 3n+id…), wherein id represents the number of the server, server 1 generates 1, 4, 7, 10... and other logical timestamps in turn; server 2 generates 2, 5, 8, 11... and other logical timestamps in turn; and server 3 generates 3, 6, 9, 12... and other logical timestamps in turn.

[0108] In Figure 4In the figure, it is assumed that the logical time stamps currently to be fed back by the three servers at T1 are 1, 2 and 3 respectively. At T1, the client A sends a time stamp acquisition request to the three servers, which is shown as request 1 in the figure. After receiving the request of the client, the server 1 sends the current logical time stamp 1 to be fed back to the client A, which is shown as response 1(1) in the figure, and then determines the next logical time stamp to be fed back as 4. After receiving the request of the client A, the server 2 sends the current logical time stamp 2 to be fed back to the client A, which is shown as response 1(2) in the figure, and then determines the next logical time stamp to be fed back as 5. After receiving the request of the client A, the server 3 sends the current logical time stamp 3 to be fed back to the client A, which is shown as response 1(3) in the figure, and then determines the next logical time stamp to be fed back as 6. The client A receives the logical time stamps sent by the three servers, and these logical time stamps constitute a group of logical time stamps, i.e. (1, 2, 3). It is determined that the number of the group of logical time stamps is equal to the total number of servers, and then the first logical time stamp 2 of the Mth (M = 2) smallest logical time stamp after being sorted in ascending order is determined as the target logical time stamp, and the current request ends.

[0109] Assume that the client B also sends a timestamp acquisition request to the three servers at T2 after the client A requests, which is shown as request 1 in the figure, and at this moment, server 3 is down, and server 2 has sent a logical timestamp 5 to another client before this moment, so that the next logical timestamp to be fed back is determined to be 8. After server 1 receives the request of the client B, the current logical timestamp to be fed back 4 is sent to the client B, which is shown as response 2(4) in the figure, and then the next logical timestamp to be fed back is determined to be 7. After server 2 receives the request of the client B, the current logical timestamp to be fed back 8 is sent to the client B, which is shown as response 2(8) in the figure, and then the next logical timestamp to be fed back is determined to be 11. Server 3 is down at this moment and does not receive the request of the client B, so it does not feed back to the client B. Since the client B only receives the logical timestamps sent by two servers, the logical timestamp fed back by server 3 is not obtained, so a set of logical timestamps is formed according to the received results, that is, (4, 8,?), wherein? represents the logical timestamp not received by server 3. The client B determines that the number of received logical timestamps is equal to the value M corresponding to the first number position, that is, M = 2, and is less than the total number of servers in the timestamp service cluster, that is, 3. After the logical timestamps in the set are sorted in ascending order, the second smallest second logical timestamp 8 is determined as the target logical timestamp, wherein the second smallest should be understood as the second smallest in the received logical timestamps. In order to further determine whether the target logical timestamp is valid, the client B sends a timestamp synchronization request to server 1 which feeds back a logical timestamp less than 8 and server 3 which does not feed back a logical timestamp, which is shown as request 3 in the figure. The timestamp synchronization request includes the target logical timestamp 8. After server 1 receives the timestamp synchronization request, the current logical timestamp to be fed back 7 and the target timestamp 8 are compared, and the logical timestamp 8 with a larger value is sent to the client B, which is shown as response 3(8) in the figure, and the next logical timestamp to be fed back is updated to the logical timestamp 10 which is greater than the target timestamp 8, and the updating method is the above-mentioned “Write n×(max(S,X) / n+1)+id”. Server 3 is still down and has not recovered, so server 3 does not receive the timestamp synchronization request and does not feed back to the client B. After the client B receives the logical timestamp 8 sent by server 1 corresponding to the timestamp synchronization request, it is determined that the number of received logical timestamps corresponding to the timestamp synchronization request is not less than the sum of the number of first logical timestamps not less than the target logical timestamp 8 in the set of logical timestamps (4, 8,?), that is, (N-M+1 = 2), so it is determined that the target logical timestamp is valid, and the request of the client B ends this time.Among them, the logical timestamp corresponding to the timestamp synchronization request received is 1, which is the logical timestamp 8 fed back by server 1; the first logical timestamp in the set of logical timestamps (4, 8,?) that is not less than the target logical timestamp 8 is 1, which corresponds to the first logical timestamp 8 fed back by server 2. Assuming that server 1 does not successfully respond to the above timestamp synchronization request 3, and assuming that server 3 is still in a down state, it can be understood that the sum of the above quantities will be less than the target quantity, at which time it will be determined that the target logical timestamp 8 is invalid, and client B can only reinitiate the timestamp acquisition request subsequently.

[0110] In the embodiment of the application, the logical timestamps generated by each server in the timestamp service cluster are monotonically increasing, and the logical timestamp at the first taking position in different sets of logical timestamps fed back by the timestamp service cluster for different timestamp acquisition requests received in turn presents a monotonically increasing trend, which ensures the linear consistency of the logical timestamps obtained by the client. Moreover, multiple servers in the timestamp service cluster can jointly respond to the timestamp acquisition request of the client, so that when a small number of servers in the timestamp service cluster are down, other servers in the timestamp service cluster can still provide timestamp allocation services to the client at all times, improving the availability of the timestamp allocation service. Furthermore, when a small number of servers (not more than M) cannot normally provide timestamp allocation services, through the above timestamp synchronization process, the servers in the cluster that can normally work update their next to-be-fed-back logical timestamps to a state greater than the target logical timestamp this time, which can ensure that the target logical timestamps obtained by the subsequent clients are in an increasing trend.

[0111] As described above, a storage system accessed by the client and each server in the timestamp service cluster can be included in the timestamp allocation system, and based on the timestamp configuration information stored in the storage system, various management and control events related to the timestamp service cluster can be processed. For example: timestamp water level update, server startup and reentry after server downtime, server expansion and contraction.

[0112] Optionally, the storage system stores a version number corresponding to the timestamp service cluster, and the following parameters corresponding to the version number: server identifier information, the value M corresponding to the first taking position, the current to-be-fed-back logical timestamp of each server, the upper limit of the logical timestamp, and the logical timestamp upper limit lock. The logical timestamp upper limit lock is a distributed lock. The logical timestamp upper limit is shared by multiple servers in the timestamp service cluster.

[0113] In actual application, the above version number and the above parameters corresponding to the version number, such as the value of M, can be updated each time there is an expansion or contraction situation in the timestamp service cluster.

[0114] The following will be exemplarily described for the above-mentioned various events.

[0115] Figure 5 A flowchart of a timestamp allocation method provided by the embodiment of the present application is shown in FIG. 5, which can be executed by any target server in the timestamp service cluster, such as the target server shown in FIG. 1. Figure 1 Figure 5 On the basis of the above-mentioned embodiment, the method further includes the following steps:

[0116] 501. Obtain a first logical timestamp upper limit in the first timestamp configuration information from the storage system.

[0117] 502. If it is determined that a difference between the first logical timestamp to be fed back currently and the first logical timestamp upper limit is less than a set threshold, update the first logical timestamp upper limit as a second logical timestamp upper limit, the second logical timestamp upper limit being a sum of the first logical timestamp and a set step, or the second logical timestamp upper limit being a sum of the first logical timestamp upper limit and the set step.

[0118] 503. Inform servers included in a first server identification list in the first timestamp configuration information to obtain the second logical timestamp upper limit, the first server identification list including identification information of each server included in the timestamp service cluster.

[0119] The embodiment introduces a case of updating the logical timestamp upper limit.

[0120] The setting of the logical timestamp upper limit is equivalent to limiting the number of logical timestamps generated by each server according to the timestamp generation strategy each time, so as to save storage space, and the setting of the logical timestamp upper limit is also conducive to ensuring the monotonicity of the logical timestamps of each server, so as to avoid the problem of not meeting the linear consistency due to the abnormality of part of the servers.

[0121] Specifically, it is assumed that the version number stored in the storage system is V1 in the initial state, and the target server can obtain the timestamp configuration information corresponding to the version number from the storage system when starting, which is assumed to be the first timestamp configuration information, and includes the first logical timestamp upper limit Limit0 and the first server identification list and other information, and the first server identification list stores identification information of each server included in the timestamp service cluster.

[0122] ​In the foregoing embodiment, the target server receives the timestamp acquisition request sent by the client. The target server can determine whether the version number in the timestamp acquisition request is consistent with the version number V1 obtained from the storage system. If the version numbers are consistent, the target server determines the first logical timestamp to be fed back and feeds back the first logical timestamp to the client. The client can query the storage system to obtain the version number V1 and the corresponding timestamp configuration information when starting.

[0123] After determining the first logical timestamp to be fed back and feeding back the first logical timestamp to the client, a difference between the first logical timestamp to be fed back and the first logical timestamp upper limit Limit1 is determined. If the difference is less than a threshold value, it is indicated that a plurality of first logical timestamps less than the first logical timestamp upper limit Limit1 will be exhausted. The first logical timestamp upper limit Limit1 is updated. It is assumed that the first logical timestamp upper limit Limit1 is updated to a second logical timestamp upper limit Limit2.

[0124] The threshold value can be set according to actual needs. For example, the threshold value is set to 3. It is assumed that the first logical timestamp to be fed back by the target server is 98, and the first logical timestamp upper limit Limit1 is 100. The difference between the first logical timestamp to be fed back and the first logical timestamp upper limit Limit1 is less than the threshold value. The first logical timestamp upper limit is updated to the second logical timestamp upper limit Limit2.

[0125] Optionally, the second logical timestamp upper limit Limit2 can be determined by the first logical timestamp and a set step. Specifically, the sum of the first logical timestamp and the set step is determined as the second logical timestamp upper limit Limit2. For example, it is assumed that the first logical timestamp is S=98 and the set step is delta=100. The second logical timestamp upper limit Limit2 can be determined as Limit2=S+delta=198. Alternatively, the second logical timestamp upper limit Limit2 can be determined by the first logical timestamp upper limit Limit1 and the set step. It is assumed that Limit1=100 and delta=100. Limit2=Limit1+delta=200.

[0126] After the target server updates the first logical timestamp upper limit Limit1 corresponding to the version number V1 in the storage system to the second logical timestamp upper limit Limit2, the target server can notify the servers included in the first server identifier list in the first timestamp configuration information to obtain the second logical timestamp upper limit Limit2. In this way, each server included in the timestamp service cluster knows the new logical timestamp upper limit.

[0127] The following describes the handling process when a server update event occurs in the timestamp service cluster. Server update events include events where a server leaves the timestamp service cluster and events where a server joins the timestamp service cluster. In other words, server update events will cause changes in the number of servers in the cluster, so they can also be called scaling events.

[0128] Figure 6 This is a flowchart illustrating a timestamp allocation method provided in an embodiment of the present invention. This method can be executed by a target server in a timestamp service cluster, where the target server can be any server in the timestamp cluster, such as... Figure 6 As shown, the method also includes the following steps:

[0129] 601. In response to a server update event in the timestamp service cluster, update the first timestamp configuration information in the storage system to a second timestamp configuration information. The second timestamp configuration information includes a second server identifier list, a second numbering position determined according to the number of servers included in the second server identifier list, and a third logical timestamp upper limit. The third logical timestamp upper limit is determined based on the larger of the logical timestamp upper limit included in the first timestamp configuration information and the sum of the fifth logical timestamp to be fed back by the updating server during the server update event and the set step size. Alternatively, the third logical timestamp upper limit is the sum of the logical timestamp upper limit included in the first timestamp configuration information and the set step size.

[0130] Among them, the update server is the server corresponding to the server update event, such as the server that leaves the cluster or the server that rejoins the cluster.

[0131] 602. Notify the servers included in the second server identifier list to obtain the second timestamp configuration information so as to update their next pending fourth logical timestamp to the sum of the upper limit of the third logical timestamp and their own identifier.

[0132] When a server in a timestamp service cluster goes down, that server is removed from the cluster, which is equivalent to the cluster shrinking. When a new server joins the cluster or a previously removed server rejoins, the cluster expands.

[0133] Assuming that the version number contained in the current timestamp service cluster is V1, each server currently obtains the first timestamp configuration information corresponding to the version number V1. In actual application, optionally, an operation and maintenance process can be run in each server, which detects whether a server update event occurs in the timestamp service cluster in real time. Assuming that multiple servers including the target server detect the server update event, the target server performs the lock acquisition processing of the upper limit of the logical timestamp in the first timestamp configuration information corresponding to the version number V1, and assuming that the target server succeeds in the lock acquisition, the target server performs the subsequent processing of the server update event. Only one server that succeeds in the lock acquisition completes the processing of the server update event.

[0134] Specifically, in response to the server update event in the timestamp service cluster, the target server updates the first timestamp configuration information in the storage system to the second timestamp configuration information. The second timestamp configuration information includes a second server identifier list, a second number taking position determined according to the number of servers contained in the second server identifier list, and a third upper limit of the logical timestamp.

[0135] Compared with the first server identifier list contained in the first timestamp configuration information, the second server identifier list contains the identifier information of each server in the timestamp service cluster at this time. For example, if a server exits the cluster, the identifier information of the server will no longer be contained in the second server identifier list; if a server joins the cluster, the identifier information of the server will be added to the second server identifier list. The identifier information of the server that exits / joins the cluster is contained in the above-mentioned server update event.

[0136] Because the number of servers in the timestamp service cluster changes, and the value of the number taking position M is related to the total number of servers, the value of M can also be updated.

[0137] The determination result of the third upper limit of the logical timestamp Limit3 is different depending on whether the server update event is the event of the server exiting the timestamp service cluster or the event of the server joining the timestamp service cluster.

[0138] If the server update event is a shrink event in which a server exits the timestamp service cluster, the third logical timestamp upper limit Limit3 is equal to the first logical timestamp upper limit Limit1 currently contained in the first timestamp configuration information. It should be noted that in this embodiment, the first logical timestamp upper limit Limit1 refers to the logical timestamp upper limit contained in the first timestamp configuration information at this time, which can be the initial first logical timestamp upper limit in the foregoing embodiment or the updated second logical timestamp upper limit. That is, in the case of shrinkage, the logical timestamp upper limit corresponding to the timestamp service cluster can not be updated, and only the logical timestamp water level of each server is updated: the fourth logical timestamp to be fed back next by each server is updated to the sum of the third logical timestamp upper limit and the server identifier of the server.

[0139] If the server update event is an expansion event in which a server joins the timestamp service cluster, the third logical timestamp upper limit Limit3 can be determined in two ways as follows: the third logical timestamp upper limit Limit3 is determined according to the logical timestamp upper limit contained in the first timestamp configuration information (assuming that it is represented as Limit1) and the greater of the sum of the fifth logical timestamp to be fed back by the updated server at the time of the server update event and the set step size. Alternatively, the sum of the logical timestamp upper limit Limit1 contained in the first timestamp configuration information and the set step size is determined as the third logical timestamp upper limit Limit3. The updated server is the server that newly joins the timestamp service cluster.

[0140] In actual applications, the version number corresponding to the second timestamp configuration information can be set as V2. After the version number V2 and the second timestamp configuration information are updated to the storage system, the target server notifies the servers contained in the second server identifier list to obtain the second timestamp configuration information.

[0141] Any server contained in the second server identifier list except the target server is denoted as server j. After the server j obtains the second timestamp configuration information from the storage system, it is assumed that the expansion event currently occurs. The fifth logical timestamp to be fed back next by the server j is updated to the sum of the third logical timestamp upper limit Limit3 and the server identifier of the server j. In this way, the numbering space of the logical timestamps used by the servers in the timestamp service cluster before and after the shrinkage and expansion events has no intersection, which can better guarantee linear consistency. That is, in the case of expansion, in addition to updating the logical timestamp upper limit, each server also needs to update its own logical timestamp water level.

[0142] For ease of understanding, for example, originally the timestamp service cluster includes three servers: server 1, server 2 and server 3, server 3 exits the cluster when it is assigned a logical timestamp = 6, and it is assumed that the first logical timestamp upper limit Limit1 = 100 at this time, the step size delta = 100 is set, in response to the scaling-out event, the third logical timestamp upper limit Limit3 = Limit1, it is assumed that the next logical timestamp to be fed back by server 1 before the scaling-out event is 80, server 1 updates the next logical timestamp to be fed back to Limit3 + id = 100 + 1 = 101 after obtaining the third logical timestamp upper limit Limit3. Server 2 is the same. At this time, a new version number V2 and corresponding timestamp configuration information are formed, which include a logical timestamp upper limit Limit1.

[0143] After that, it is assumed that server 3 re-joins the timestamp service cluster, that is, a scaling-in event occurs, at this time, a new version number V3 and corresponding timestamp configuration information are formed, which include a logical timestamp upper limit Limit3'. For example, the third logical timestamp upper limit Limit3' = Limit1 + delta = 200 is set, or Limit3' = 6 + delta = 106 (because Limit1 = 100 is less than 106, so the greater of the two is taken). It is assumed that the next logical timestamp to be fed back by server 1 before the scaling-in event is 90, server 1 updates the next logical timestamp to be fed back to Limit3' + id = 200 + 1 = 201 (assuming Limit3' = 200) after obtaining the third logical timestamp upper limit Limit3'. Server 2 is the same.

[0144] In addition, it should be noted that the synchronization of the new version number by each server in the timestamp service cluster to the corresponding timestamp configuration information is a gradual updating process, that is, not all servers update at the same time. During the updating period, if a server receives a timestamp acquisition request sent by a client, it determines whether to respond to the client by comparing the version number in the timestamp acquisition request with the version number currently used by itself, and if it is found that the version number sent by the client is lower than its own version number, it can send its own version number and the corresponding timestamp configuration information to the client, so that the client re-sends a timestamp acquisition request carrying a new version number.

[0145] For ease of understanding of the above server updating event, the following is combined with the above-mentioned timestamp service cluster Figure 7The event of server exiting / joining the timestamp service cluster is exemplified. Assume that the timestamp service cluster includes 4 servers (N=4), the value of the first number taking position is M=2, the version number of the first timestamp configuration information is set as ver1, and the version number of the second timestamp configuration information is set as ver2. Assume that server 4 exits / joins the timestamp service cluster. Assume that server 1 detects the event of server 4 exiting / joining the timestamp service cluster and succeeds in grabbing the lock. Server 1 first updates the first timestamp configuration information in the storage system to the second timestamp configuration information and updates the version number ver1 to the new version ver2. Then, the timestamp allocation service of server 4 is stopped / stated. Server 2 and server 3 are informed to acquire the new version of the second timestamp configuration information. The timestamp configuration information updating of each server is a step-by-step updating process, which is shown in the updating process of Figure 7 When server 1 has been updated to ver2, the version number of the timestamp configuration information used by the client is ver1, and when the client requests the logical timestamp from servers 1-4, only the feedback from server 2 and server 3 is obtained, i.e., the last obtained set of logical timestamps is (?, x, y,?), wherein x, y represent the logical timestamps fed back by server 2 and server 3. When server 1 and server 2 have both been updated to ver2, the version number of the timestamp configuration information used by the client is promoted to ver2, and then the client requests the logical timestamp from servers 1-4, only the response from server 1 and server 2 is obtained, i.e., the last obtained set of logical timestamps is (p, q,?,?), wherein p, q represent the logical timestamps fed back by server 1 and server 2. When server 1, server 2 and server 3 have all been updated to ver2, the version number of the timestamp configuration information used by the client is promoted to ver2, and then the client requests the timestamp from servers 1-4, the response from server 1, server 2 and server 3 is obtained, i.e., the last obtained set of logical timestamps is (p, q, w,?).

[0146] The process executed by the target server in the timestamp service cluster is introduced in detail in the above embodiment, and the timestamp allocation process executed by the client is described in detail below. Figure 8 The timestamp allocation process executed by the client is described in detail.

[0147] Figure 8 A flowchart of a timestamp allocation method provided by the embodiment of the present application is shown in FIG. 6. The method can be executed by the client in the timestamp allocation system shown in FIG. 1, and the method includes the following steps. Figure 1 The method includes the following steps. Figure 8

[0148] ​801、Obtain identification information of a plurality of servers in a timestamp service cluster.

[0149] 802、According to the identification information of the plurality of servers, send a timestamp obtaining request to the plurality of servers.

[0150] 803、Receive a set of logical timestamps fed back by the plurality of servers, the set of logical timestamps including first logical timestamps fed back by different servers in response to the timestamp obtaining request, wherein each server determines a first logical timestamp to be fed back from monotonically increasing logical timestamps sequentially generated according to a set timestamp generation strategy.

[0151] 804、If the number of the set of logical timestamps meets a set condition, determine a target logical timestamp from the set of logical timestamps. The target logical timestamp is a first logical timestamp in the set of logical timestamps sorted in ascending order and located at a target number taking position; the logical timestamp at the target number taking position presents a monotonically increasing trend in different sets of logical timestamps fed back by the timestamp service cluster in response to different timestamp obtaining requests received sequentially.

[0152] When a client needs to obtain a logical timestamp, first, identification information of a plurality of servers in a timestamp service cluster is obtained. In an optional embodiment, the specific implementation process of obtaining the identification information of the plurality of servers in the timestamp service cluster can include: when the client is started, first timestamp configuration information containing the identification information of the current plurality of servers in the timestamp service cluster is obtained from a storage system, so that when a timestamp obtaining request is sent, the identification information of the plurality of servers is obtained from the locally stored first timestamp configuration information.

[0153] After obtaining the identification information of the plurality of servers, according to the identification information of the plurality of servers, a timestamp obtaining request is sent to the plurality of servers. The timestamp obtaining request contains the identification of the first timestamp configuration information corresponding to the client, such as the version number described above. Therefore, when the server receiving the timestamp obtaining request determines that the version number stored locally is consistent with the version number in the timestamp obtaining request, subsequent logical timestamp allocation processing is performed. Otherwise, if they are inconsistent, the second timestamp configuration information corresponding to the version number stored locally can be fed back to the client. The client then initiates a timestamp obtaining request based on the second timestamp configuration information.

[0154] Based on the timestamp obtaining request sent by the client, each server determines a first logical timestamp to be fed back from monotonically increasing logical timestamps sequentially generated according to a set timestamp generation strategy, and sends the first logical timestamp to the client. The client receives a set of logical timestamps fed back by the plurality of servers, the set of logical timestamps including first logical timestamps fed back by different servers in response to the timestamp obtaining request.

[0155] In practical applications, when some servers in the timestamp service cluster are down, the servers can not receive the timestamp acquisition request sent by the client, and thus can not send the first logical timestamp currently to be fed back to the client. When the client determines that the number of the received set of logical timestamps is less than the total number of servers, it indicates that some servers in the timestamp service cluster can not provide timestamp allocation services for the client, and thus the target logical timestamp can not be obtained in the set of logical timestamps. Therefore, after receiving the set of logical timestamps, the client can determine whether the number of the set of logical timestamps meets a set condition. The set condition is, for example, consistent with the total number of servers included in the timestamp service cluster, or greater than or equal to a value corresponding to the target number position and less than the total number of servers in the timestamp service cluster.

[0156] If the number of the set of logical timestamps meets the set condition, the set of logical timestamps is sorted in ascending order, and the first logical timestamp at the target number position is determined as the target logical timestamp. For example, assuming that the value corresponding to the target number position is M = 2, and the received set of logical timestamps is (1, 2, 3), the sorting result obtained after sorting in ascending order is 1 < 2 < 3, and the logical timestamp at the second position 2 is determined as the target logical timestamp. The logical timestamp at the target number position in different sets of logical timestamps fed back by the timestamp service cluster for different timestamp acquisition requests received in sequence presents a monotonically increasing trend, which can make the target timestamp obtained by the client have linear consistency.

[0157] As described above, assuming that the current timestamp service cluster includes N servers, in response to a timestamp acquisition request of a client, all or part of the N servers can feed back respective first logical timestamps to the client, and the client determines the first logical timestamp at the target number position from the set of logical timestamps composed of the first logical timestamps when the number of the set of logical timestamps meets a set condition. However, it is further necessary to determine whether the target logical timestamp is valid according to the number of the received first logical timestamps, if valid, the target logical timestamp can be used, otherwise, it cannot be used, and the logical timestamp needs to be requested again.

[0158] In practical applications, there can also be a case where the number of the set of logical timestamps does not meet the set condition. If the number of the set of logical timestamps does not meet the set condition, the request fails, and the client can reinitiate the timestamp acquisition request after a period of time.

[0159] In an optional embodiment, if the number of the set of logical timestamps is N, i.e., equal to the total number of servers, after determining the first logical timestamp in the target number position as the target logical timestamp, it is directly determined that the target logical timestamp is valid, the current request is ended, and the target logical timestamp can be directly used for subsequent processes, such as a modification operation on data stored in a database.

[0160] In another optional embodiment, if the number of the set of logical timestamps is greater than or equal to M and less than N, where M is a value corresponding to the target number position, after determining the first logical timestamp in the target number position as the target logical timestamp, a timestamp synchronization process needs to be performed, and after successfully completing the process, it is determined that the target logical timestamp is valid, and the target logical timestamp can be used for subsequent processes.

[0161] Specifically, if it is determined that the number of the set of logical timestamps is greater than or equal to a value corresponding to the target number position and less than the total number of servers in the timestamp service cluster, a timestamp synchronization request is sent to the servers that do not feed back the first logical timestamp and whose first logical timestamp is less than the target logical timestamp, and the target logical timestamp is included in the timestamp synchronization request, so that the servers receiving the timestamp synchronization request determine the logical timestamp with a larger value between the current second logical timestamp to be fed back and the target logical timestamp and send it to the client, and update the next third logical timestamp to be fed back to be greater than the target logical timestamp according to the target logical timestamp; if the client determines that the number of logical timestamps corresponding to the timestamp synchronization request received is greater than or equal to the sum of the number of the first logical timestamp in the set of logical timestamps that is not less than the target logical timestamp and the target number, it is determined that the target logical timestamp is valid.

[0162] In order to facilitate understanding of the process of determining the target logical timestamp by the client in the above scheme, the following is combined with the above scheme. Figure 9Detailed description is made. Assuming that the current timestamp service cluster contains N servers, the client sends a timestamp acquisition request to the N servers, and all or part of the N servers may have fed back respective first logical timestamps to the client. After receiving a set of logical timestamps composed of the first logical timestamps, the client determines the number of the first logical timestamps contained in the set of logical timestamps. First, it is determined whether the number of the first logical timestamps is greater than or equal to the value M corresponding to the target numbering position. If it is determined that the number of the logical timestamps is less than M, the request fails. If it is determined that the number of the first logical timestamps in the set of logical timestamps is equal to the total number N of servers in the timestamp service cluster, the Mth smallest logical timestamp is taken as the valid target logical timestamp after sorting the set of logical timestamps. If it is determined that the number of the set of logical timestamps is greater than or equal to M but less than N, the Mth smallest logical timestamp is taken after sorting the set of logical timestamps. Then, the servers that feed back the first logical timestamp smaller than the Mth smallest logical timestamp and the servers that do not feed back the first logical timestamp are sent a timestamp synchronization request, wherein the timestamp synchronization request includes the Mth smallest logical timestamp. The servers perform the synchronization process described above, which is not repeated here. Then, the client determines whether the number of servers in the cluster whose next logical timestamp to be fed back is greater than the Mth smallest logical timestamp is greater than or equal to N-M+1. If yes, the Mth smallest logical timestamp is determined as the valid target logical timestamp; if no, the current timestamp request fails.

[0163] In this embodiment, the execution process of the client can refer to the related description in the foregoing other embodiments, which is not repeated here.

[0164] The timestamp allocation method provided by the embodiments of the present application can be applied to various application scenarios that require the use of logical timestamps.

[0165] For example, in a distributed storage system composed of multiple storage nodes, the same data D is stored in storage nodes A and B in the form of double copies, and two clients (such as two application servers of the same enterprise user) need to modify the same data D. Before sending the data modification request to the storage node A and the storage node B, the client A sends a timestamp acquisition request to each server in the timestamp service cluster, assuming that the cluster contains 3 servers. The client A acquires a set of logical timestamps (1, 2, 3) from the 3 servers in the timestamp service cluster, and when it is determined that the number of the received set of logical timestamps meets the set condition, the logical timestamp in the second position after sorting the set of logical timestamps in ascending order is determined as the target logical timestamp, that is, the target logical timestamp is 2. Then, the client A sends the data modification request containing the target logical timestamp 2 to the storage node A and the storage node B. Similarly, before sending the data modification request to the storage node A and the storage node B, the client B sends a timestamp acquisition request to the 3 servers in the timestamp service cluster. The client B acquires a set of logical timestamps (4, 8,?) from the 3 servers in the timestamp service cluster, and when it is determined that the number of the received set of logical timestamps meets the set condition, the logical timestamp in the second position after sorting the set of logical timestamps in ascending order is determined as the target logical timestamp, that is, the target logical timestamp is 8. The client B sends the data modification request containing the target logical timestamp 8 to the storage node A and the storage node B. The storage node A determines the execution order according to the target logical timestamp carried in the received data modification request: the data modification request of the client A is executed first and then the data modification request of the client B. Similarly, the storage node B determines the execution order as well, so that the modification results of the data D in the storage node A and the storage node B are consistent.

[0166] For example, before a client (such as a certain database application program) requests to generate a snapshot, it requests a logical timestamp Y from the timestamp service cluster, so that each database access operation (associated with a respective logical timestamp) before the logical timestamp Y will be added to the snapshot. It can be seen that, based on the allocation of the corresponding logical timestamp to each access operation, the access operation before the snapshot generation time can be accurately obtained when the snapshot is generated.

[0167] In addition, the timestamp allocation scheme provided by the embodiments of the present application can also be applied to various application scenarios, which will not be described here.

[0168] The timestamp allocation apparatus of one or more embodiments of the present application will be described in detail below. Those skilled in the art can understand that these apparatuses can be configured by using commercially available hardware components through the steps taught by the present scheme.

[0169] Figure 10 A structural schematic diagram of a timestamp allocation device provided for an embodiment of the present application is shown in Figure 10 The device is applied to a target server in a timestamp service cluster, the target server being any one of a plurality of servers in the timestamp service cluster, and the device comprising a determination module 11 and a sending module 12.

[0170] The determination module 11 is configured to determine, in response to a timestamp acquisition request from a client, a first logical timestamp to be fed back from monotonically increasing logical timestamps generated in sequence according to a set timestamp generation strategy.

[0171] The sending module 12 is configured to send the first logical timestamp to the client, so that the client determines a target logical timestamp from a set of logical timestamps received; wherein the set of logical timestamps comprises first logical timestamps fed back by different servers in response to the timestamp acquisition request; the target logical timestamp is the first logical timestamp in a first numbering position after the set of logical timestamps is sorted in ascending order; wherein the logical timestamp in the first numbering position presents a monotonically increasing trend in different sets of logical timestamps fed back by the timestamp service cluster in response to different timestamp acquisition requests received in sequence.

[0172] Optionally, the determination module 11 can be specifically configured to generate the monotonically increasing logical timestamp corresponding to the target server according to a number of the target server, a set modulo parameter, and a multiple of the modulo parameter that is incremented in sequence; wherein the plurality of servers each correspond to a different number, and the plurality of servers share the modulo parameter and the multiple of the modulo parameter.

[0173] Optionally, the device can further comprise a receiving module and an updating module.

[0174] The receiving module is configured to receive a timestamp synchronization request sent by the client, the timestamp synchronization request including the target logical timestamp, the timestamp synchronization request being sent by the client to a server that has not fed back a first logical timestamp smaller than the target logical timestamp and to which the target logical timestamp is not fed back when it is determined that the number of the set of logical timestamps is greater than or equal to the number corresponding to the first number-taking position and is smaller than the total number of servers in the timestamp service cluster, the server that has not fed back the first logical timestamp smaller than the target logical timestamp and to which the target logical timestamp is not fed back being included in the target server. Based on this, the sending module 12 is further configured to send, to the client, a logical timestamp with a larger value between a second logical timestamp currently to be fed back by the target server and the target logical timestamp, so that the client determines that the target logical timestamp is valid when it is determined that the number of logical timestamps corresponding to the timestamp synchronization request received by the client and the number of first logical timestamps not smaller than the target logical timestamp in the set of logical timestamps are greater than or equal to a target number.

[0175] The updating module is configured to update a third logical timestamp to be fed back next according to the target logical timestamp, the third logical timestamp to be fed back next being greater than the target logical timestamp.

[0176] Optionally, the target number is determined according to a difference between the total number of servers in the timestamp service cluster and the number corresponding to the first number-taking position.

[0177] Optionally, the updating module is specifically configured to determine, according to a logical timestamp with a larger value between the second logical timestamp currently to be fed back by the target server and the target logical timestamp and a number of the target server and a set parameter, a third logical timestamp to be fed back next by the target server.

[0178] Optionally, the updating module is further configured to obtain an upper limit of a first logical timestamp in first timestamp configuration information from a set storage system, update the upper limit of the first logical timestamp to a second upper limit of a logical timestamp if it is determined that a difference between the first logical timestamp currently to be fed back and the upper limit of the first logical timestamp is smaller than a set threshold, the second upper limit of the logical timestamp being a sum of the first logical timestamp and a set step length or the second upper limit of the logical timestamp being a sum of the upper limit of the first logical timestamp and the set step length, and notify servers included in a first server identification list in the first timestamp configuration information to obtain the second upper limit of the logical timestamp, the first server identification list including identification information of each server included in the timestamp service cluster, wherein the first number-taking position is included in the first timestamp configuration information and is determined according to a number of servers included in the first server identification list.

[0179] Optionally, the updating module is further configured to: in response to a server updating event in the timestamp service cluster, update the first timestamp configuration information in the setting storage system to second timestamp configuration information, the second timestamp configuration information including a second server identifier list, a second number position determined according to a number of servers included in the second server identifier list, and a third logical timestamp upper limit; the server updating event includes an event of a server exiting the timestamp service cluster, and an event of a server joining the timestamp service cluster; notify the servers included in the second server identifier list to obtain the second timestamp configuration information, so as to update a fourth logical timestamp to be fed back next by each server as a sum of the third logical timestamp upper limit and a server identifier of the server; wherein, if the server updating event is the event of the server joining the timestamp service cluster, the third logical timestamp upper limit is determined according to a larger one of a first logical timestamp upper limit included in the first timestamp configuration information and a sum of a fifth logical timestamp to be fed back by an updating server at the time of the server updating event and a setting step, or the third logical timestamp upper limit is a sum of the first logical timestamp upper limit included in the first timestamp configuration information and the setting step; the updating server is a server newly joining the timestamp service cluster; if the server updating event is the event of the server exiting the timestamp service cluster, the third logical timestamp upper limit is equal to the first logical timestamp upper limit included in the first timestamp configuration information.

[0180] Figure 11 The apparatus shown can perform the steps performed by the target server in the foregoing embodiments, and the detailed execution process and technical effects can be referred to the related description of the target server in the foregoing embodiments, which will not be described herein again.

[0181] In one possible design, the above Figure 12 The timestamp allocation apparatus shown can be implemented as an electronic device. As shown in the figure, Figure 12 The electronic device can include a processor 21, a memory 22, and a communication interface 23. The memory 22 stores executable code. When the executable code is executed by the processor 21, the processor 21 can at least implement the timestamp allocation method performed by the target server as provided in the foregoing embodiments.

[0182] In addition, the embodiment of the present application provides a non-transitory machine readable storage medium, which stores executable code. When the executable code is executed by a processor of an electronic device, the processor can at least implement the timestamp allocation method performed by the target server as provided in the foregoing embodiments.

[0183] Figure 12A structural schematic diagram of a timestamp allocation device provided by an embodiment of the present application is shown in Figure 12 The device is applied to a client, and the device comprises an acquisition module 31, a sending module 32, a receiving module 33, and a determination module 34.

[0184] The acquisition module 31 is configured to acquire identification information of a plurality of servers in a timestamp service cluster.

[0185] The sending module 32 is configured to send a timestamp acquisition request to the plurality of servers according to the identification information of the plurality of servers.

[0186] The receiving module 33 is configured to receive a set of logical timestamps fed back by the plurality of servers, wherein the set of logical timestamps comprises first logical timestamps fed back by different servers in response to the timestamp acquisition request, and each server determines the first logical timestamp to be fed back from monotonically increasing logical timestamps generated in sequence according to a set timestamp generation strategy.

[0187] The determination module 34 is configured to determine a target logical timestamp from the set of logical timestamps if a quantity of the set of logical timestamps meets a set condition, wherein the target logical timestamp is a first logical timestamp arranged at a target number taking position after the set of logical timestamps is sorted in ascending order, and wherein the logical timestamp at the target number taking position presents a monotonically increasing trend in different sets of logical timestamps fed back by the timestamp service cluster in response to different timestamp acquisition requests received in sequence.

[0188] Optionally, the determination module 34 can be specifically configured to: the quantity of the set of logical timestamps is consistent with a total number of servers included in the timestamp service cluster, or the quantity of the set of logical timestamps is greater than or equal to a value corresponding to the target number taking position and less than the total number of servers in the timestamp service cluster.

[0189] Optionally, the set condition comprises: the quantity of the set of logical timestamps is consistent with a total number of servers included in the timestamp service cluster, or the quantity of the set of logical timestamps is greater than or equal to a value corresponding to the first number taking position and less than the total number of servers in the timestamp service cluster.

[0190] Optionally, the sending module 32 is further configured to: if it is determined that the number of the set of logical timestamps is greater than or equal to the value corresponding to the target number-taking position and less than the total number of servers in the timestamp service cluster, send a timestamp synchronization request to the servers that do not feed back the first logical timestamp and whose first logical timestamp is less than the target logical timestamp, the timestamp synchronization request including the target logical timestamp, so that the servers receiving the timestamp synchronization request determine the logical timestamp with a larger value between the second logical timestamp currently to be fed back and the target logical timestamp and send it to the client, and update the third logical timestamp to be fed back next as greater than the target logical timestamp according to the target logical timestamp.

[0191] The determination module 34 is further configured to: if it is determined that the number of logical timestamps corresponding to the timestamp synchronization request received and the sum of the number of the first logical timestamp in the set of logical timestamps that is not less than the target logical timestamp are greater than or equal to the target number, determine that the target logical timestamp is valid.

[0192] Optionally, the obtaining module 31 is specifically configured to: obtain the identification information of the plurality of servers from the locally stored first timestamp configuration information, the first timestamp configuration information including the target number-taking position.

[0193] Based on this, the timestamp acquisition request includes the identification of the first timestamp configuration information corresponding to the client, and the receiving module 33 is further configured to: receive the second timestamp configuration information fed back by any server of the plurality of servers, the second timestamp configuration information being sent by the any server to the client when it is determined that the identification of the first timestamp configuration information is inconsistent with the identification of the second timestamp configuration information stored locally.

[0194] Figure 13 The apparatus can perform the steps performed by the client in the foregoing embodiments, and the detailed execution process and technical effects are described in the foregoing embodiments, which will not be described here.

[0195] In one possible design, the above ​ The timestamp allocation apparatus can be implemented as an electronic device. As shown in the figure, ​ The electronic device can include a processor 41, a memory 42, and a communication interface 43. The memory 42 stores executable code, and when the executable code is executed by the processor 41, the processor 41 can at least implement the timestamp allocation method performed by the client as provided in the foregoing embodiments.

[0196] In addition, embodiments of the present invention provide a non-transitory machine-readable storage medium storing executable code, which, when executed by a processor of an electronic device, enables the processor to at least implement the timestamp allocation method executed by the client as provided in the foregoing embodiments.

[0197] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separate. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0198] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of a necessary general-purpose hardware platform, or by a combination of hardware and software. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a computer product. The present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0199] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A time stamp allocation method characterized by, A target server applied to a timestamp service cluster, the target server being any one of a plurality of servers in the timestamp service cluster, the method comprising: determining, in response to a timestamp acquisition request of a client, a first logical timestamp to be currently fed back from monotonically increasing logical timestamps generated in turn according to a set timestamp generation strategy; sending the first logical timestamp to the client to enable the client to determine a target logical timestamp from a group of logical timestamps received; wherein the group of logical timestamps comprises first logical timestamps fed back by different servers in response to the timestamp acquisition request; and the target logical timestamp is a first logical timestamp arranged at a first numbering position after the group of logical timestamps is sorted in ascending order; wherein a next logical timestamp to be fed back by at least a target number of servers in the timestamp service cluster is updated to be greater than the target logical timestamp, so that the logical timestamp at the first numbering position in different groups of logical timestamps fed back by the timestamp service cluster for different timestamp acquisition requests received in turn presents a monotonically increasing trend; and wherein the at least target number of servers comprises servers whose first logical timestamps are less than the target logical timestamp in the group of logical timestamps and servers that have not fed back a first logical timestamp.

2. The method of claim 1, wherein, The set timestamp generation strategy comprises: generating a monotonically increasing logical timestamp corresponding to the target server according to a number of the target server, a set modulus parameter, and a multiple of the modulus parameter that is incremented in turn; wherein the plurality of servers each correspond to a different number, and the plurality of servers share the modulus parameter and the multiple of the modulus parameter.

3. The method according to claim 1 or 2, characterized in that, The method further comprises: receiving a timestamp synchronization request sent by the client, the timestamp synchronization request comprising the target logical timestamp, the timestamp synchronization request being sent by the client to servers that have fed back a first logical timestamp less than the target logical timestamp and have not fed back a first logical timestamp when determining that a number of the group of logical timestamps is greater than or equal to a value corresponding to the first numbering position and less than a total number of servers in the timestamp service cluster, the servers that have fed back a first logical timestamp less than the target logical timestamp and have not fed back a first logical timestamp including the target server; sending, to the client, a second logical timestamp to be currently fed back and a logical timestamp with a larger value between the target logical timestamp, to enable the client to determine that the target logical timestamp is valid when determining that a number of logical timestamps corresponding to the timestamp synchronization request received is greater than or equal to a target number that is a sum of a number of first logical timestamps in the group of logical timestamps that are not less than the target logical timestamp; updating, according to the target logical timestamp, a third logical timestamp to be fed back next to be greater than the target logical timestamp.

4. The method of claim 3, wherein, The target number is determined according to a difference between the total number of servers in the timestamp service cluster and a value corresponding to the first numbering position.

5. The method of claim 3, wherein, The updating, according to the target logical timestamp, of a next third logical timestamp to be fed back to be greater than the target logical timestamp comprises: According to a larger logical timestamp between the target server's current second logical timestamp to be fed back and the target logical timestamp, and a number of the target server and a set modulo parameter, a third logical timestamp to be fed back next by the target server is determined.

6. The method of claim 1, wherein, The method further comprises: Obtaining an upper limit of a first logical timestamp in first timestamp configuration information from a set storage system; If a difference between the current first logical timestamp to be fed back and the upper limit of the first logical timestamp is less than a set threshold, updating the upper limit of the first logical timestamp to be an upper limit of a second logical timestamp, the upper limit of the second logical timestamp being a sum of the first logical timestamp and a set step, or the upper limit of the second logical timestamp being a sum of the upper limit of the first logical timestamp and the set step; Notifying servers included in a first server identification list in the first timestamp configuration information to obtain the upper limit of the second logical timestamp, the first server identification list including identification information of each server included in the timestamp service cluster. The first number obtaining position is included in the first timestamp configuration information and is determined according to a number of servers included in the first server identification list.

7. The method of claim 1, wherein, The method further comprises: In response to a server update event in the timestamp service cluster, updating the first timestamp configuration information in the set storage system to be second timestamp configuration information, the second timestamp configuration information including a second server identification list, a second number obtaining position determined according to a number of servers included in the second server identification list, and an upper limit of a third logical timestamp; the server update event including an event of a server exiting the timestamp service cluster and an event of a server joining the timestamp service cluster; Notifying servers included in the second server identification list to obtain the second timestamp configuration information to update a fourth logical timestamp to be fed back next by each server to be a sum of the upper limit of the third logical timestamp and a server number of the server; If the server update event is the event of the server joining the timestamp service cluster, the upper limit of the third logical timestamp is determined according to a larger value of the upper limit of the first logical timestamp included in the first timestamp configuration information and a sum of a fifth logical timestamp to be fed back by an update server at the time of the server update event and a set step, or the upper limit of the third logical timestamp is a sum of the upper limit of the first logical timestamp included in the first timestamp configuration information and the set step; the update server is a server newly joining the timestamp service cluster; If the server update event is the event of the server exiting the timestamp service cluster, the upper limit of the third logical timestamp is equal to the upper limit of the first logical timestamp included in the first timestamp configuration information.

8. A time stamp allocation method characterized by comprising: The method applied to a client comprises: Obtaining identification information of a plurality of servers in a timestamp service cluster; According to the identification information of the plurality of servers, a timestamp acquisition request is sent to the plurality of servers; A set of logical timestamps fed back by the plurality of servers is received, the set of logical timestamps including first logical timestamps fed back by different servers in response to the timestamp acquisition request, wherein each server determines the first logical timestamp to be currently fed back from monotonically increasing logical timestamps sequentially generated according to a set timestamp generation strategy; If the number of the set of logical timestamps meets a set condition, a target logical timestamp is determined from the set of logical timestamps, wherein the target logical timestamp is the first logical timestamp in the set of logical timestamps sorted in ascending order and arranged at a target number position; wherein the next logical timestamp to be fed back by at least a target number of servers in the timestamp service cluster is updated to be greater than the target logical timestamp, so that the logical timestamp at the target number position in different sets of logical timestamps fed back by the timestamp service cluster in response to sequentially received different timestamp acquisition requests presents a monotonically increasing trend; wherein the at least target number of servers include servers whose first logical timestamp in the set of logical timestamps is less than the target logical timestamp and servers that have not fed back the first logical timestamp.

9. The method of claim 8, wherein, The set condition includes that the number of the set of logical timestamps is consistent with the total number of servers included in the timestamp service cluster, or the number of the set of logical timestamps is greater than or equal to a value corresponding to the target number position and less than the total number of servers in the timestamp service cluster.

10. The method of claim 9, wherein, The method further includes: If it is determined that the number of the set of logical timestamps is greater than or equal to the value corresponding to the target number position and less than the total number of servers in the timestamp service cluster, a timestamp synchronization request is sent to servers whose first logical timestamp fed back is less than the target logical timestamp and servers that have not fed back the first logical timestamp, the timestamp synchronization request including the target logical timestamp, so that the servers receiving the timestamp synchronization request determine a second logical timestamp to be currently fed back and a logical timestamp with a larger value between the target logical timestamp and send the logical timestamp to the client, and update a third logical timestamp to be next fed back to be greater than the target logical timestamp according to the target logical timestamp; If it is determined that the number of logical timestamps corresponding to the timestamp synchronization request received is greater than or equal to the sum of the number of first logical timestamps in the set of logical timestamps that are not less than the target logical timestamp and a target number, it is determined that the target logical timestamp is valid.

11. The method of claim 8, wherein, The method further includes: The identification information of the plurality of servers in the timestamp service cluster is obtained from first timestamp configuration information stored locally, the first timestamp configuration information including the target number position; The timestamp acquisition request includes an identifier of first timestamp configuration information corresponding to the client, and the method further includes: Receiving second timestamp configuration information fed back by any server of the plurality of servers, the second timestamp configuration information being sent by the any server to the client when the any server determines that the identity of the first timestamp configuration information is inconsistent with the identity of the second timestamp configuration information stored locally.

12. An electronic device, comprising: Comprising: a memory, a processor, a communication interface; wherein the memory has stored executable codes, when the executable codes are executed by the processor, the processor executes the timestamp allocation method according to any one of claims 1 to 7, or executes the timestamp allocation method according to any one of claims 8 to 11.

13. A non-transitory machine-readable storage medium, comprising: The non-transitory machine-readable storage medium has stored executable codes, when the executable codes are executed by the processor of the electronic device, the processor executes the timestamp allocation method according to any one of claims 1 to 7, or executes the timestamp allocation method according to any one of claims 8 to 11.

14. A timestamp allocation system characterized by Comprising: a client and a timestamp service cluster; the client, configured to acquire identity information of a plurality of servers in the timestamp service cluster, and send a timestamp acquisition request to the plurality of servers according to the identity information of the plurality of servers; determining a target logical timestamp from a group of logical timestamps when it is determined that the number of the group of logical timestamps received meets a set condition, wherein the target logical timestamp is a logical timestamp arranged at a target number taking position after the group of logical timestamps is sorted in ascending order; each server in the timestamp service cluster, configured to determine a logical timestamp to be fed back from monotonically increasing logical timestamps generated in sequence according to a set timestamp generation strategy, and send the logical timestamp to the client; wherein the group of logical timestamps comprises logical timestamps fed back by different servers in response to the timestamp acquisition request; wherein the next logical timestamp to be fed back by at least a target number of servers in the timestamp service cluster is updated to be greater than the target logical timestamp, so that the logical timestamp at the target number taking position in different groups of logical timestamps fed back by the timestamp service cluster for different timestamp acquisition requests received in sequence presents a monotonically increasing trend; wherein the at least target number of servers comprises servers whose first logical timestamp in the group of logical timestamps is less than the target logical timestamp and servers that have not fed back the first logical timestamp.

Citation Information

Patent Citations

  • Consistent distributed timestamp counters

    CN101496322A

  • Time stamp server apparatus, time stamp issuing method, and time stamp issuing program

    JP2007181093A