Version number determination

By determining the target node pointed to by the frozen pointer in the database and obtaining its minimum version number and continuous playback site, the problem of system resource consumption in the prior art when determining the weakly consistent version number is solved, and fast and efficient version number determination is achieved.

WO2025103121A1PCT designated stage expired Publication Date: 2025-05-22BEIJING OCEANBASE TECHNOLOGY CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/127877
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-11-15
Filing Date
2024-10-28
Publication Date
2025-05-22

AI Technical Summary

Technical Problem

When determining the weakly consistent version number, the prior art needs to traverse the hash table, resulting in a large system resource consumption.

Method used

By determining the target node to which the freeze pointer points, obtain the minimum version number and continuous playback site contained in the target node, and determine the weakly consistent read version number based on this information.

Benefits of technology

Reduces system overhead, improves system performance, and can quickly determine weak consistent version numbers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024127877_22052025_PF_FP_ABST
    Figure CN2024127877_22052025_PF_FP_ABST
Patent Text Reader

Abstract

Provided is a version number determination method. The method comprises: determining a target node to which a frozen pointer points, wherein the target node is a node in an array, the frozen pointer moves on the basis of the number of transactions in the node in the array, and the number of transactions is the number of transactions in the node; acquiring a minimum version number and a continuous replay position that are included in the target node, wherein the minimum version number is the minimum value of a first-stage replay version number corresponding to at least one transaction in the node, and the first-stage replay version number is a version number of a first-stage log corresponding to the transaction; and determining a weak-consistency read version number on the basis of the minimum version number and the continuous replay position that are included in the target node. In this way, determining a weak-consistency read version number on the basis of a minimum version number and a continuous replay position that are included in a target node reduces system overheads. Further provided are a version number determination apparatus, and an electronic device and a storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

Version number determination Technical Field

[0001] The present application relates to the field of database technology, and in particular to a method, device, electronic device, and storage medium for determining a version number. Background Art

[0002] Databases typically offer two levels of querying: strongly consistent reads and weakly consistent reads. Strongly consistent reads typically route requests to the primary replica to read the latest data. Weakly consistent reads typically prioritize reads to the backup replica, without requiring the latest data.

[0003] When performing weak consistency reads, it is necessary to ensure that the data read is successfully committed. This requires generating a safe and readable version number, namely the weak consistency read version number.

[0004] In existing technology, a hash table is typically used to store the log replay version numbers (prepare versions) of all active transactions during the prepare phase. The weakly consistent read version number is determined based on the prepare versions of each active transaction by traversing the hash table. However, traversing the hash table consumes a large amount of system resources.

[0005] Summary of the Invention

[0006] The purpose of the embodiments of the present application is to provide a method, device, electronic device and storage medium for determining a version number, so as to reduce the system resources consumed when determining a weakly consistent read version number.

[0007] On the one hand, an embodiment of the present application provides a method for determining a version number, including: determining a target node pointed to by a frozen pointer; the target node is a node in an array; the frozen pointer is moved according to the number of transactions in the node of the array; the number of transactions is the number of transactions in the node; obtaining the minimum version number and continuous playback position contained in the target node; the minimum version number is the minimum value of the first-stage playback version number corresponding to at least one transaction in the node; the first-stage playback version number is the version number of the first-stage log corresponding to the transaction; the continuous playback position is determined based on the maximum value of the version number of at least one log continuously played back in the log stream when the node is frozen; and determining a weak consistency read version number based on the minimum version number and the continuous playback position contained in the target node.

[0008] In one embodiment, the method further includes: replaying the logs in the log stream; the log stream contains at least one log; if there is a first-stage log being replayed in the log stream, then according to the first transaction corresponding to the first-stage log, the node information of the active node pointed to by the active pointer in the array is updated, and a correspondence between the first transaction and the active node time is established; the active pointer is moved according to the number of transactions in the node of the array; if there is a second-stage log being replayed in the log stream, then the second transaction corresponding to the second-stage log is determined, and based on the correspondence, the node information of the node corresponding to the second transaction in the array is updated.

[0009] In one embodiment, based on the first transaction corresponding to the first-stage log, the node information of the active node pointed to by the active pointer in the array is updated, including: determining the active node pointed to by the active pointer in the array; increasing the number of transactions in the active node by one; obtaining the first-stage replay version number of the first transaction; if the first-stage replay version number is lower than the minimum version number contained in the active node, updating the minimum version number to the first-stage replay version number.

[0010] In one embodiment, after establishing the correspondence between the first transaction and the active node time, the method further includes: if the number of transactions of the active node reaches the set number corresponding to the active node, then the maximum value of the version number of at least one log continuously replayed in the log stream is determined as the continuous replay location of the active node; the node state in the active node is set to frozen; and the active pointer is increased by one.

[0011] In one embodiment, updating the node information of the node corresponding to the second transaction in the array based on the corresponding relationship includes: obtaining the node corresponding to the second transaction based on the corresponding relationship; and reducing the number of transactions in the node corresponding to the second transaction by one.

[0012] In one embodiment, the method further includes: if it is determined that the number of transactions in the node currently pointed to by the frozen pointer is zero, then incrementing the frozen pointer by one; if it is determined that the pointer value of the frozen pointer is the same as the pointer value of the active pointer, then incrementing the active pointer by one.

[0013] In one embodiment, a weak consistency read version number is determined based on the minimum version number and continuous playback location contained in the target node, including: subtracting one from the continuous playback location contained in the target node to obtain a new continuous playback location; and determining the minimum value of the minimum version number contained in the target node and the new continuous playback location as the weak consistency read version number.

[0014] On the one hand, an embodiment of the present application provides a device for determining a version number, including: a first determination unit, used to determine the target node pointed to by the frozen pointer; the target node is a node in an array; the frozen pointer is moved according to the number of transactions in the node of the array; the number of transactions is the number of transactions in the node; an acquisition unit, used to obtain the minimum version number and continuous playback position contained in the target node; the minimum version number is the minimum value of the first-stage playback version number corresponding to at least one transaction in the node; the first-stage playback version number is the version number of the first-stage log corresponding to the transaction; the continuous playback position is determined based on the maximum value of the version number of at least one log continuously played back in the log stream when the node is frozen; a second determination unit, used to determine the weak consistency read version number based on the minimum version number and continuous playback position contained in the target node.

[0015] In one embodiment, the first determination unit is further used to: replay the logs in the log stream; the log stream contains at least one log; if there is a first-stage log being replayed in the log stream, then according to the first transaction corresponding to the first-stage log, the node information of the active node pointed to by the active pointer in the array is updated, and a correspondence between the first transaction and the active node time is established; the active pointer is moved according to the number of transactions in the node of the array; if there is a second-stage log being replayed in the log stream, then the second transaction corresponding to the second-stage log is determined, and based on the correspondence, the node information of the node corresponding to the second transaction in the array is updated.

[0016] In one embodiment, the first determination unit is further used to: determine the active node pointed to by the active pointer in the array; increase the number of transactions in the active node by one; obtain the first-stage replay version number of the first transaction; if the first-stage replay version number is lower than the minimum version number contained in the active node, then update the minimum version number to the first-stage replay version number.

[0017] In one embodiment, the first determination unit is also used to: if the number of transactions of the active node reaches the set number corresponding to the active node, then the maximum value of the version number of at least one log continuously replayed in the log stream is determined as the continuous replay location of the active node; the node state in the active node is set to frozen; and the active pointer is increased by one.

[0018] In one embodiment, the first determining unit is further configured to: obtain a node corresponding to the second transaction based on the corresponding relationship; and reduce the number of transactions in the node corresponding to the second transaction by one.

[0019] In one embodiment, the first determining unit is further configured to: if it is determined that the number of transactions in the node currently pointed to by the frozen pointer is zero, increment the frozen pointer by one; if it is determined that the pointer value of the frozen pointer is the same as the pointer value of the active pointer, increment the active pointer by one.

[0020] In one embodiment, the second determination unit is used to: subtract one from the continuous playback location contained in the target node to obtain a new continuous playback location; and determine the minimum version number contained in the target node and the minimum value in the new continuous playback location as the weak consistency read version number.

[0021] On the one hand, an embodiment of the present application provides an electronic device, comprising: a processor; and a memory storing computer instructions, the computer instructions being used to enable the processor to execute the steps of the method provided in various optional implementations as determined by any of the above version numbers.

[0022] On the one hand, an embodiment of the present application provides a storage medium storing computer instructions, which are used to enable a computer to execute the steps of the method provided in various optional implementations determined by any of the above version numbers.

[0023] In the method, device, electronic device and storage medium for determining the version number provided by the embodiment of the present application, the target node pointed to by the frozen pointer is determined; the target node is a node in the array; the frozen pointer is moved according to the number of transactions in the node of the array; the number of transactions is the number of transactions in the node; the minimum version number and the continuous playback site contained in the target node are obtained; the minimum version number is the minimum value of the first-stage playback version number corresponding to at least one transaction in the node; the first-stage playback version number is the version number of the first-stage log corresponding to the transaction; the continuous playback site is determined based on the maximum value of the version number of at least one log continuously played back in the log stream when the node is frozen; the weak consistency read version number is determined based on the minimum version number and the continuous playback site contained in the target node. In this way, the weak consistency read version number is determined based on the minimum version number and the continuous playback site contained in the target node of the target node, which reduces system overhead, improves system performance, and can quickly determine the weak consistency read version number. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the following is a brief introduction to the drawings required for use in the specific implementation methods or the description of the prior art. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0025] FIG1 is a flow chart of a log playback method in an embodiment of the present application.

[0026] FIG2 is an example diagram of an array in an embodiment of the present application.

[0027] FIG3 is an example diagram of log playback in an embodiment of the present application.

[0028] FIG4 is a flowchart of a method for determining a version number in an embodiment of the present application.

[0029] FIG5 is a structural block diagram of a device for determining a version number in an embodiment of the present application.

[0030] FIG6 is a schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION

[0031] The technical solutions of the present application will be described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application. In addition, the technical features involved in the different embodiments of the present application described below can be combined with each other as long as they do not conflict with each other.

[0032] First, some of the terms involved in the embodiments of the present application are explained to facilitate understanding by those skilled in the art.

[0033] Terminal device: can be a mobile terminal, fixed terminal, or portable terminal, such as a mobile phone, station, unit, device, multimedia computer, multimedia tablet, Internet node, communicator, desktop computer, laptop computer, notebook computer, netbook computer, tablet computer, personal communication system device, personal navigation device, personal digital assistant, audio / video player, digital camera / camcorder, positioning device, television receiver, radio broadcast receiver, e-book device, gaming device, or any combination thereof, including accessories and peripherals of these devices, or any combination thereof. It is also foreseeable that the terminal device can support any type of user interface (such as wearable devices), etc.

[0034] Server: It can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, and big data and artificial intelligence platforms.

[0035] ACID properties: These are the four properties that a database management system must possess to ensure that transactions are correct and reliable when writing or updating data. These properties are atomicity, consistency, isolation, and durability.

[0036] The two-phase replay protocol is a protocol that ensures the ACID properties of transactions. It typically consists of a prepare phase and a commit phase. The prepare phase generates a prepare log and a prepare version, while the commit phase generates a commit log and a commit version. A transaction is considered successfully committed only after completing both the prepare and commit phases. Transactions can be distributed.

[0037] Distributed transactions are transactions that require operations on multiple participants in a distributed system. These participants can be different processes, different computers, different databases, and so on. Distributed transactions must possess ACID properties to ensure their correct execution.

[0038] A log stream is a dynamic data stream containing at least one log. Each data point in a log stream is a log. Each log in a log stream has its own timestamp, and the timestamps of each log in the log stream are incremental. Logs in a log stream can be divided into transaction prepare logs and commit logs based on log type. That is, each transaction typically corresponds to one prepare log and one commit log.

[0039] Log replay: Synchronize the data in the log stream of the leader replica to the follower replicas and re-execute the operations in the log on the followers to ensure that the follower data is consistent with the leader. A piece of data in a database (such as a distributed database) typically has multiple replicas, which can be divided into leader replicas and follower replicas. Each replica has its own log stream. For example, during the restart process after a system crash, data modifications made by uncommitted transactions need to be rolled back. The process of implementing this reorganization is called log replay.

[0040] Continuous playback point: This is the highest version number of logs continuously played back in the log stream. It should be noted that there are typically multiple playback threads consuming data from the log stream. Each playback thread selects a log to play back, and each log is played back only once. These playback threads execute concurrently. Logs for a transaction are played back sequentially, while logs for different transactions are typically played back out of order. Therefore, the highest version number of logs continuously played back in the log stream is determined as the continuous playback point.

[0041] Based on the defects of the above-mentioned related technologies, the embodiments of the present application provide a method, device, electronic device and storage medium for determining a version number, aiming to reduce the system resources consumed when determining a weakly consistent read version number.

[0042] The present application provides a method for determining a version number. This method can be applied to electronic devices. The present application does not limit the type of electronic device. The method can be any device type suitable for implementation, such as a smartphone, tablet computer, and database. This application will not elaborate on this. In one application scenario, the method is applied to a distributed database, which can be OceanBase.

[0043] It should be noted that the weakly consistent read version number determined must meet two conditions: 1. The data read by the weakly consistent read version number is all committed data; 2. The weakly consistent read version number cannot be rolled back. To this end, in the embodiment of the present application, an array containing at least one node is first generated based on log playback, and then the weakly consistent read version number is determined based on the node information in the nodes in the array.

[0044] Refer to FIG1 , which is a flow chart of a log playback method in an embodiment of the present application. The method is described below in conjunction with FIG1 . The specific implementation process of the method is as follows.

[0045] Step 100: Play back the logs in the log stream.

[0046] In one implementation, logs in a log stream are replayed through one or more log replay processes.

[0047] Each log playback process plays back a log. Different log playback processes play back different logs. The logs played back in the log stream are out of order.

[0048] It's important to note that a log stream can be viewed as a dynamic data stream, with each piece of data in the log stream being a log. Before a device applies (i.e., consumes) the log stream, the logs in the log stream are sequential. However, during the log stream application process, the logs in the log stream become out of order.

[0049] It should be noted that the logs replayed in the log stream may be first-stage logs or second-stage logs. First-stage logs are transaction prepare logs. Second-stage logs are transaction commit logs. Each transaction corresponds to one prepare log and one commit log. If a first-stage log is replayed in the log stream, step 101 is executed. If a second-stage log is replayed in the log stream, step 103 is executed.

[0050] Step 101: If a first-stage log is played back in the log stream, the node information of the active node pointed to by the active pointer in the array is updated according to the first transaction corresponding to the first-stage log.

[0051] Among them, the active pointer moves according to the number of transactions in the node of the array.

[0052] In one implementation, before executing step 101 , the following steps may be performed.

[0053] S1011: If there is a first-stage log to be played back in the log stream, determine the active node pointed to by the active pointer in the array.

[0054] The array contains at least one node. Optionally, the array can be a circular array, and the length of the array can be fixed or variable. A node can be a Node structure. Node information can include the number of transactions (cnt), the minimum version number (min_version), the continuous playback point (checkpoint), and the node state (state).

[0055] The minimum version number is the minimum of the first-phase replay version numbers corresponding to all transactions in the node. Node states include frozen and active. The node state of an active node is active. The continuous replay point is determined by the maximum version number of all continuously replayed logs in the log stream when the node was frozen. In one embodiment, checkpoint = the above maximum value + 1.

[0056] See Figure 2 for an example of an array. The array contains multiple nodes. Each node's node information includes min_version, cnt, state, and checkpoint.

[0057] S1012: Increase the number of transactions in the active node by one.

[0058] In this way, if the first-stage log corresponding to a transaction is replayed, the transaction is loaded into the active node, and the number in the active node increases by one.

[0059] S1013: Obtain the first-stage playback version number of the first transaction.

[0060] It should be noted that each log has a corresponding version number, and the first-stage playback version number is the version number of the first-stage log.

[0061] S1014: If the first-stage playback version number is lower than the minimum version number included in the active node, the minimum version number is updated to the first-stage playback version number.

[0062] The following example illustrates the update of active nodes.

[0063] When a transaction's prepare log is replayed, the following steps are performed.

[0064] Find the node pointed to by the active pointer active_index and represent it as node_A. Increment the cnt field of node_A by 1 and compare the min_version of node_A with the prepare version of the first stage of the prepare log. If the prepare version is less than the min_version, update the min_version of node_A to the prepare version.

[0065] In this way, when the prepare log of the transaction is replayed, the number of transactions and the minimum version number in the active node pointed to by active_index can be updated.

[0066] Step 102: Establish a correspondence between the first transaction and the active node time.

[0067] In one implementation, the correspondence between the first transaction and the active node time may be established in an indexing manner.

[0068] Specifically, the first transaction and the current pointer value of the active pointer can be stored in the index table, and the pointer value can be used as the index of the first transaction. Each pointer value corresponds to a node. In this way, in subsequent steps, the node of each transaction in the array can be determined based on the transaction index.

[0069] Furthermore, when the number of transactions in a node reaches a set number m corresponding to the active node, the current active node may be frozen and the active pointer may point to the next node.

[0070] In actual applications, the set number can be set according to the actual application scenario. The set numbers corresponding to different nodes can be the same or different. For example, the set number can be 1000, which is not limited here.

[0071] In one implementation, when executing step 102, the following steps may be used.

[0072] S1021: If the number of transactions of the active node reaches a set number corresponding to the active node, the maximum value of the version number of at least one log continuously replayed in the log stream is determined as the continuous replay position of the active node.

[0073] Figure 3 shows an example of log playback. It shows the log stream of a follower replica for a partition. The log stream contains six logs: three prepare logs and three commit logs. Log playback is performed by replay thread 1 and replay thread 2, respectively.

[0074] After logs with log_id 1 and 3 are replayed, logs with log_id 2 have not yet been replayed. Therefore, logs with log_id 1 and 3 are not replayed continuously. Therefore, the version number of the log with log_id 1 is determined as the continuous replay point. After log_id 2 is replayed, logs with log_id 1, 2, and 3 have all been replayed, indicating continuous replay. Therefore, the maximum value of the version numbers (300) corresponding to logs with log_id 1, 2, and 3 is determined as the current continuous replay point.

[0075] S1022: Setting the node status of the active node to frozen.

[0076] It should be noted that each node has a node status field to record the node's status. Node status includes frozen and active. When the node status is frozen, it means that the node is frozen. The node status of the node pointed to by the active pointer is active, while the node status of the remaining nodes is frozen. When a node is frozen, the current continuous playback point of the log stream is filled in the node's checkpoint field.

[0077] S1023: Increment the active pointer by one.

[0078] Specifically, after a node is fully loaded with transactions, active_index is incremented by one, and active_index points to the next node, so that the next node can be used as an active node to continue loading transactions.

[0079] Step 103: If there is a second-stage log to be played back in the log stream, determine the second transaction corresponding to the second-stage log.

[0080] Step 104: Based on the corresponding relationship, update the node information of the node corresponding to the second transaction in the array.

[0081] In one implementation, when executing step 104, the following steps may be used.

[0082] S1041: Based on the corresponding relationship, obtain the node corresponding to the second transaction.

[0083] In one implementation, a pointer value corresponding to the second transaction is obtained from the index table, and a node corresponding to the second transaction is found based on the pointer value.

[0084] S1042: Subtract one from the number of transactions in the node corresponding to the second transaction.

[0085] In one implementation, the cnt of the node is reduced by one.

[0086] Thus, when the second phase log is replayed, the second transaction is taken out of the node, and therefore the number of transactions in the node is reduced by one.

[0087] In this embodiment of the present application, when a transaction's prepare log is replayed, the active node pointed to by active_index is found to "load" the transaction into the active node. Simultaneously, the min_version and cnt of the active node are updated to record the minimum prepare version of all transactions in the active node through min_version. Furthermore, if cnt reaches a set number m, the current continuous replay location in the log stream is stored in the active node, the active node is frozen, and active_index is set to point to the next node, making the next node the new active node.

[0088] When a transaction's commit log is replayed, the transaction is "pulled out" of the node where it resides, and the CNT count of the node where the transaction resides is decremented by one. Furthermore, if the frozen pointer currently points to the node and the number of transactions in the node has decreased to zero, indicating that all transactions on the node have been committed, the frozen pointer is incremented by one to determine the weakly consistent read version number based on the transaction of the next node. If the pointer value of the frozen pointer is the same as the pointer value of the active pointer, the active pointer is incremented by one. The frozen pointer and the active pointer each point to a different node.

[0089] Refer to Figure 4, which is a flowchart of a method for determining a version number in an embodiment of the present application. The method is described below in conjunction with Figure 4. The specific implementation process of the method is as follows.

[0090] Step 401: Determine the target node pointed to by the freeze pointer.

[0091] The target node is a node in the array; the frozen pointer is moved according to the number of transactions in the node of the array; and the number of transactions is the number of transactions in the node.

[0092] Step 402: Obtain the minimum version number and continuous playback position contained in the target node.

[0093] Among them, the minimum version number is the minimum value of the first-stage playback version number corresponding to at least one transaction in the node; the first-stage playback version number is the version number of the first-stage log corresponding to the transaction; the continuous playback position is determined based on the maximum value of the version number of at least one log continuously played back in the log stream when the node is frozen.

[0094] Step 403: Determine the weak consistency read version number based on the minimum version number and the continuous playback location contained in the target node.

[0095] In one implementation, when executing step 403, the following steps may be used.

[0096] S4031: Subtract one from the continuous playback location contained in the target node to obtain a new continuous playback location.

[0097] It should be noted that each frozen node contains a continuous playback point, but only the continuous playback point in the target node pointed to by the frozen pointer is valid.

[0098] S4032: Determine the minimum version number contained in the target node and the minimum value in the new continuous playback location as the weak consistency read version number.

[0099] Furthermore, the freeze pointer can be moved according to the number of transactions of the node.

[0100] In one implementation, if it is determined that the number of transactions in the node currently pointed to by the freeze pointer is zero, the freeze pointer is incremented by one.

[0101] Furthermore, the active pointer may be moved according to the frozen pointer.

[0102] In one embodiment, if the pointer value of the frozen pointer is determined to be the same as the pointer value of the active pointer, the active pointer is incremented by 1. In Figure 2, the active pointer and the frozen pointer point to different nodes. The active pointer and the frozen pointer maintain a sliding window on the array.

[0103] The following demonstrates the correctness of the weak consistency reading version number.

[0104] Assume that Node1 is frozen earlier than Node2, and the frozen pointer frozen_index points to Node1. At the current moment, all prepare logs in the log stream have been replayed, and the minimum value of the version of the transactions for which the commit logs have not been replayed is actual_min_version. If the generated weak consistency read version number satisfies the following two conditions simultaneously, it means that the weak consistency read version number is correct: 1. The conditional weak consistency read version number should be less than or equal to actual_min_version and less than the continuous replay position; 2. The weak consistency read version number does not roll back.

[0105] If the min_version in Node1 is equal to actual_min_version, then the continuous replay position when Node1 is frozen must be greater than or equal to min_version. Therefore, simply return min_version as the weak consistency read version number, which satisfies the first condition above.

[0106] If the min_version in Node1 is greater than actual_min_version, then the transaction corresponding to actual_min_version must have been loaded into Node2. That is, when Node1 is frozen, the prepare log of the transaction corresponding to actual_min_version has not been replayed. Because if both the transaction corresponding to ctual_min_version and the transaction corresponding to min_version are loaded into Node1, and actual_min_version is less than min_version, then min_version will be updated to a smaller actual_min_version, which contradicts the fact that min_version in Node1 is greater than actual_min_version.

[0107] That is to say, when Node1 is frozen, the continuous replay position must be less than actual_min_version, and this continuous replay position smaller than actual_min_version will be written into Node1 when Node1 is frozen. At this time, the weak consistency read version number = min(min_version of Node1, continuous replay position of Node1 - 1) < actual_min_version, satisfying the first condition above.

[0108] Regarding the second condition above, since both the continuous playback point and min_version in Node1 are increasing, the minimum value between the continuous playback point and min_version is used as the weak consistency read version number and will not be rolled back.

[0109] In the traditional method, it is usually necessary to traverse each transaction in the hash table to determine the weak consistency read version number, and the time complexity is O(n), where n is the number of active transactions. Obviously, the more transactions, the higher the complexity, the greater the system overhead, and the lower the efficiency. In the embodiment of the present application, the weak consistency read version number is determined based on the minimum version number and continuous playback site contained in the target node of the target node. The time complexity is O(1), and the complexity does not increase with the increase of transactions, which reduces system overhead, improves system performance, and can quickly determine the weak consistency read version number.

[0110] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0111] Based on the same inventive concept, the embodiments of this application also provide a device for determining a version number. Since the principles of the above-mentioned device and equipment for solving the problem are similar to those of a method for determining a version number, the implementation of the above-mentioned device can refer to the implementation of the method, and the repeated parts will not be repeated. The device can be applied to electronic devices. This application does not limit the type of electronic device. It can be any device type suitable for implementation, such as a smartphone, tablet computer, etc., and this application will not repeat them.

[0112] Refer to Figure 5, which is a structural block diagram of the device for determining the version number in an embodiment of the present application. In some embodiments, the device for determining the version number in the example of the present application includes: a first determining unit 501, used to determine the target node pointed to by the frozen pointer; the target node is a node in the array; the frozen pointer is moved according to the number of transactions in the node of the array; the number of transactions is the number of transactions in the node; an obtaining unit 502, used to obtain the minimum version number and continuous playback position contained in the target node; the minimum version number is the minimum value of the first-stage playback version number corresponding to at least one transaction in the node; the first-stage playback version number is the version number of the first-stage log corresponding to the transaction; the continuous playback position is determined based on the maximum value of the version number of at least one log continuously played back in the log stream when the node is frozen; a second determining unit 503, used to determine the weak consistency read version number based on the minimum version number and the continuous playback position contained in the target node.

[0113] In one embodiment, the first determination unit 501 is also used to: replay the logs in the log stream; the log stream contains at least one log; if there is a first-stage log being replayed in the log stream, then according to the first transaction corresponding to the first-stage log, the node information of the active node pointed to by the active pointer in the array is updated, and a correspondence between the first transaction and the active node time is established; the active pointer is moved according to the number of transactions in the node of the array; if there is a second-stage log being replayed in the log stream, then the second transaction corresponding to the second-stage log is determined, and based on the correspondence, the node information of the node corresponding to the second transaction in the array is updated.

[0114] In one embodiment, the first determination unit 501 is further used to: determine the active node pointed to by the active pointer in the array; increase the number of transactions in the active node by one; obtain the first-stage replay version number of the first transaction; if the first-stage replay version number is lower than the minimum version number contained in the active node, update the minimum version number to the first-stage replay version number.

[0115] In one embodiment, the first determination unit 501 is also used to: if the number of transactions of the active node reaches the set number corresponding to the active node, then the maximum value of the version number of at least one log continuously replayed in the log stream is determined as the continuous replay location of the active node; the node state in the active node is set to frozen; and the active pointer is increased by one.

[0116] In one implementation, the first determining unit 501 is further configured to: obtain a node corresponding to the second transaction based on the corresponding relationship; and reduce the number of transactions in the node corresponding to the second transaction by one.

[0117] In one embodiment, the first determining unit 501 is further configured to: if it is determined that the number of transactions in the node currently pointed to by the frozen pointer is zero, increment the frozen pointer by one; if it is determined that the pointer value of the frozen pointer is the same as the pointer value of the active pointer, increment the active pointer by one.

[0118] In one embodiment, the second determination unit 503 is used to: subtract one from the continuous playback location contained in the target node to obtain a new continuous playback location; and determine the minimum version number contained in the target node and the minimum value in the new continuous playback location as the weak consistency read version number.

[0119] In the method, device, electronic device and storage medium for determining the version number provided by the embodiment of the present application, the target node pointed to by the frozen pointer is determined; the target node is a node in the array; the frozen pointer is moved according to the number of transactions in the node of the array; the number of transactions is the number of transactions in the node; the minimum version number and the continuous playback site contained in the target node are obtained; the minimum version number is the minimum value of the first-stage playback version number corresponding to at least one transaction in the node; the first-stage playback version number is the version number of the first-stage log corresponding to the transaction; the continuous playback site is determined based on the maximum value of the version number of at least one log continuously played back in the log stream when the node is frozen; the weak consistency read version number is determined based on the minimum version number and the continuous playback site contained in the target node. In this way, the weak consistency read version number is determined based on the minimum version number and the continuous playback site contained in the target node of the target node, which reduces system overhead, improves system performance, and can quickly determine the weak consistency read version number.

[0120] An embodiment of the present application provides an electronic device, including: a processor; and a memory storing computer instructions, wherein the computer instructions are used to enable the processor to execute a method in any of the above embodiments.

[0121] An embodiment of the present application provides a storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the method of any of the above embodiments.

[0122] FIG6 shows a schematic structural diagram of an electronic device 6000. Referring to FIG6, the electronic device 6000 includes a processor 6010 and a memory 6020, and optionally, may further include a power supply 6030, a display unit 6040, and an input unit 6050.

[0123] The processor 6010 is the control center of the electronic device 6000. It uses various interfaces and lines to connect various components and performs various functions of the electronic device 6000 by running or executing software programs and / or data stored in the memory 6020.

[0124] In the embodiment of the present application, the processor 6010 executes the various steps in the above embodiment when calling the computer program stored in the memory 6020.

[0125] Optionally, the processor 6010 may include one or more processing units. Preferably, the processor 6010 may integrate an application processor and a modem processor, wherein the application processor primarily processes the operating system, user interface, and applications, and the modem processor primarily processes wireless communications. It is understood that the modem processor may not be integrated into the processor 6010. In some embodiments, the processor and memory may be implemented on a single chip. In some embodiments, they may also be implemented on separate chips.

[0126] The memory 6020 may mainly include a program storage area and a data storage area. The program storage area may store an operating system, various applications, etc., and the data storage area may store data created based on the use of the electronic device 6000. In addition, the memory 6020 may include a high-speed random access memory and a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device.

[0127] The electronic device 6000 also includes a power supply 6030 (such as a battery) for supplying power to various components. The power supply can be logically connected to the processor 6010 through a power management system, thereby managing functions such as charging, discharging, and power consumption through the power management system.

[0128] The display unit 6040 can be used to display information input by the user or information provided to the user, as well as various menus of the electronic device 6000. In the embodiment of the present application, it is mainly used to display the display interface of each application in the electronic device 6000 and objects such as text and pictures displayed on the display interface. The display unit 6040 may include a display panel 6041. The display panel 6041 can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc.

[0129] The input unit 6050 can be used to receive information such as numbers or characters input by the user. The input unit 6050 may include a touch panel 6051 and other input devices 6052. The touch panel 6051, also known as a touch screen, can receive user touch operations on or near it (for example, operations performed by the user using a finger, a stylus, or any other suitable object or accessory on or near the touch panel 6051).

[0130] Specifically, the touch panel 6051 can detect user touch operations and the signals generated by the touch operations, convert these signals into touch point coordinates, send them to the processor 6010, and receive and execute commands sent by the processor 6010. In addition, the touch panel 6051 can be implemented using various types, such as resistive, capacitive, infrared, and surface acoustic wave. Other input devices 6052 can include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control buttons, power buttons, etc.), a trackball, a mouse, a joystick, etc.

[0131] Of course, the touch panel 6051 can cover the display panel 6041. When the touch panel 6051 detects a touch operation on or near it, it transmits the information to the processor 6010 to determine the type of touch event. The processor 6010 then provides a corresponding visual output on the display panel 6041 based on the type of touch event. Although in Figure 6, the touch panel 6051 and the display panel 6041 are used as two independent components to implement the input and output functions of the electronic device 6000, in some embodiments, the touch panel 6051 and the display panel 6041 can be integrated to implement the input and output functions of the electronic device 6000.

[0132] The electronic device 6000 may further include one or more sensors, such as a pressure sensor, a gravity acceleration sensor, a proximity light sensor, etc. Of course, according to the needs of specific applications, the electronic device 6000 may also include other components such as a camera. Since these components are not the key components used in the embodiments of the present application, they are not shown in FIG6 and will not be described in detail.

[0133] Those skilled in the art will understand that FIG6 is merely an example of an electronic device and does not limit the electronic device. The electronic device may include more or fewer components than shown in the figure, or may combine certain components, or may include different components.

[0134] For the convenience of description, the above parts are divided into modules (or units) according to their functions and described separately. Of course, when implementing this application, the functions of each module (or unit) can be implemented in the same or multiple software or hardware.

[0135] Obviously, the above embodiments are merely examples for clarity of explanation and are not intended to limit the embodiments. Those skilled in the art will appreciate that other variations or modifications can be made based on the above description. It is not necessary and impossible to enumerate all embodiments here. Obvious variations or modifications arising therefrom remain within the scope of protection of this application.

Claims

1. A method for determining a version number, the method comprising: Determine the target node pointed to by the frozen pointer; The target node is a node in the array; The frozen pointer is moved according to the number of transactions in the node of the array; the number of transactions is the number of transactions in the node; Obtaining the minimum version number and continuous playback position contained in the target node; The minimum version number is the minimum value of the first-stage playback version number corresponding to at least one transaction in the node; The first-stage playback version number is the version number of the first-stage log corresponding to the transaction; The continuous playback position is determined according to the maximum value of the version number of at least one log that is continuously played back in the log stream when the node is frozen; The weak consistency read version number is determined according to the minimum version number and the continuous playback position contained in the target node.

2. The method according to claim 1, further comprising: Replay the logs in the log stream; The log stream includes at least one log; If a first-stage log is played back in the log stream, then according to a first transaction corresponding to the first-stage log, the node information of the active node pointed to by the active pointer in the array is updated, and a corresponding relationship between the first transaction and the active node time is established; The active pointer is moved according to the number of transactions in the node of the array; If there is a second-stage log to be played back in the log stream, a second transaction corresponding to the second-stage log is determined, and based on the corresponding relationship, node information of a node corresponding to the second transaction in the array is updated.

3. The method according to claim 2, wherein updating the node information of the active node pointed to by the active pointer in the array according to the first transaction corresponding to the first stage log comprises: determining an active node pointed to by an active pointer in the array; Increment the number of transactions in the active node by one; Obtain the first phase playback version number of the first transaction; If the first-stage playback version number is lower than the minimum version number included in the active node, the minimum version number is updated to the first-stage playback version number.

4. The method according to claim 3, after establishing the correspondence between the first transaction and the active node time, the method further comprises: If the number of transactions of the active node reaches a set number corresponding to the active node, the maximum value of the version number of at least one log continuously played back in the log stream is determined as the continuous playback position of the active node; Setting the node status of the active node to frozen; The active pointer is incremented by one.

5. The method according to claim 2, wherein updating the node information of the node corresponding to the second transaction in the array based on the corresponding relationship comprises: Based on the corresponding relationship, obtaining a node corresponding to the second transaction; The number of transactions in the node corresponding to the second transaction is reduced by one.

6. The method according to claim 5, further comprising: If it is determined that the number of transactions in the node currently pointed to by the frozen pointer is zero, then the frozen pointer is increased by one; If it is determined that the pointer value of the frozen pointer is the same as the pointer value of the active pointer, the active pointer is increased by one.

7. The method according to any one of claims 1 to 6, wherein determining the weakly consistent read version number according to the minimum version number and the continuous playback position contained in the target node comprises: Subtract one from the continuous playback point contained in the target node to obtain a new continuous playback point; The minimum value of the minimum version number contained in the target node and the new continuous playback location is determined as the weak consistency read version number.

8. A device for determining a version number, the device comprising: A first determining unit, used to determine a target node pointed to by the frozen pointer; The target node is a node in the array; The frozen pointer is moved according to the number of transactions in the node of the array; the number of transactions is the number of transactions in the node; An acquisition unit, used to acquire the minimum version number and continuous playback position contained in the target node; The minimum version number is the minimum value of the first-stage playback version number corresponding to at least one transaction in the node; The first-stage playback version number is the version number of the first-stage log corresponding to the transaction; The continuous playback position is determined according to the maximum value of the version number of at least one log that is continuously played back in the log stream when the node is frozen; The second determination unit is used to determine the weak consistency read version number according to the minimum version number and the continuous playback position included in the target node.

9. An electronic device, comprising: processor; as well as A memory storing computer instructions, wherein the computer instructions are used to enable the processor to execute the method according to any one of claims 1-7.

10. A storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Cache operation method, device and system, storage medium and operation equipment

    CN113312385A

  • Transaction execution method and device, computing equipment and storage medium

    CN115113989A

  • Transaction processing method and device, equipment and storage medium

    CN116932150A

  • Version number determination method and device, electronic equipment and storage medium

    CN117573738A

  • Consistent read queries from a secondary compute node

    US20200050692A1