Visibility determination method, apparatus, device, and storage medium

By utilizing the global commit sequence number snapshot in the transaction public cache of the distributed database for initial visibility determination, the inefficiency caused by frequent communication in distributed transactions is solved, achieving more efficient visibility determination and transaction execution.

CN116719825BActive Publication Date: 2026-06-26SHANGHAI DAMENG DATABASE

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHANGHAI DAMENG DATABASE
Filing Date
2023-06-09
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

In a distributed data environment, the frequent communication between nodes and the metadata node to obtain snapshots leads to low efficiency in distributed transaction execution.

Method used

By obtaining a snapshot of the global commit sequence number from the transaction public cache of the compute node or data node, an initial visibility determination is made. If it is visible, the result is determined directly, reducing communication with the metadata node.

Benefits of technology

It improves the efficiency of visibility determination and transaction execution, and reduces the communication cost with metadata nodes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116719825B_ABST
    Figure CN116719825B_ABST
Patent Text Reader

Abstract

The application discloses a visibility determination method and device, equipment and a storage medium, and relates to the technical field of databases. The method comprises the following steps: in response to a first visibility judgment event of a target transaction being triggered, obtaining a current cache value from transaction public cache data of a node, and obtaining a first cache commit sequence number snapshot, wherein the transaction public cache data comprises a global commit sequence number in a cached metadata node; determining a first target commit sequence number snapshot of the target transaction according to the first cache commit sequence number snapshot; performing initial judgment on the visibility according to the first target commit sequence number snapshot; and in the case that the initial judgment result is visible, determining that the visibility judgment result of the first visibility judgment event is visible. Through the above technical solution, the communication cost with the metadata node can be reduced, and the efficiency of the visibility determination and the transaction execution efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of database technology, and in particular to a method, apparatus, device, and storage medium for determining visibility. Background Technology

[0002] In a distributed data environment, to ensure data consistency, a metadata node (MD) is needed to provide each compute node and data node with a globally unique global commit sequence number (g_cmtseg). When a node starts a new transaction or a transaction needs to update visibility information, it generally needs to send a request to the MD to obtain a snapshot. Since transactions obtain snapshots of snapshots relatively frequently, the communication cost between each node and the MD is high, which affects the execution efficiency of distributed transactions. Summary of the Invention

[0003] This invention provides a visibility determination method, apparatus, device, and storage medium, which can improve transaction execution efficiency.

[0004] According to one aspect of the present invention, a visibility determination method is provided, applied to a computing node or data node in a distributed database, the method comprising:

[0005] In response to the first visibility determination event of the target transaction being triggered, the current cached value is obtained from the transaction public cache data of this node to obtain the first cached commit sequence number snapshot, wherein the transaction public cache data includes the global commit sequence number in the metadata node of the distributed database.

[0006] The first target commit sequence number snapshot of the target transaction is determined based on the first cached commit sequence number snapshot.

[0007] Initial visibility determination is performed based on the first target submission sequence number snapshot;

[0008] If the initial judgment result is visible, the visibility judgment result of the first visibility judgment event is determined to be visible.

[0009] According to another aspect of the present invention, a visibility determination apparatus is provided, configured in a computing node or data node of a distributed database, the apparatus comprising:

[0010] The cache snapshot acquisition module is used to obtain the current cache value from the transaction public cache data of this node in response to the first visibility judgment event of the target transaction being triggered, and to obtain the first cache commit sequence number snapshot, wherein the transaction public cache data includes the global commit sequence number in the metadata node of the distributed database.

[0011] The target snapshot determination module is used to determine the first target commit sequence number snapshot of the target transaction based on the first cached commit sequence number snapshot.

[0012] The initial judgment module is used to make an initial judgment on visibility based on the first target submission sequence number snapshot;

[0013] The visibility determination module is used to determine that the visibility determination result of the first visibility determination event is visible if the initial determination result is visible.

[0014] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0015] At least one processor; and

[0016] A memory communicatively connected to the at least one processor; wherein,

[0017] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the visibility determination method according to any embodiment of the present invention.

[0018] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the visibility determination method according to any embodiment of the present invention.

[0019] In the technical solution of this invention, a computing node or data node in a distributed database, in response to a visibility determination event of a target transaction being triggered, obtains the current cached value from the transaction public cache data of its own node to obtain a cached commit sequence number snapshot. Based on the cached commit sequence number snapshot, it determines the target commit sequence number snapshot of the target transaction. An initial visibility determination is then performed based on the target commit sequence number snapshot. If the initial determination result is visible, the visibility determination result of the visibility determination event is determined to be visible. By adopting the above technical solution, when visibility determination is required, the current cached value can be directly obtained from the transaction public cache data for initial determination. If the initial determination is visible, the visibility determination result can be directly obtained without waiting to obtain the latest global commit sequence number from the metadata node as the target commit sequence number snapshot. This reduces the communication cost with the metadata node and improves the efficiency of visibility determination and transaction execution.

[0020] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0021] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0022] Figure 1 This is a flowchart of a visibility determination method provided according to an embodiment of the present invention;

[0023] Figure 2 This is a flowchart of yet another visibility determination method provided according to an embodiment of the present invention;

[0024] Figure 3 This is a flowchart of yet another visibility determination method provided according to an embodiment of the present invention;

[0025] Figure 4 This is a schematic diagram of a visibility determination device according to an embodiment of the present invention;

[0026] Figure 5 This is a schematic diagram of the structure of an electronic device that implements the visibility determination method of the present invention. Detailed Implementation

[0027] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0028] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0029] To better understand the embodiments of the present invention, related technologies are described below. Typical distributed databases generally involve the following concepts:

[0030] Compute Node (CN): Receives and processes various requests from clients, and generally does not store any data itself.

[0031] Data Node (DN): The data storage module that provides data to the compute nodes and handles data modification and access requests from the compute nodes.

[0032] Metadata Node (MD): A metadata storage module that provides metadata support for the entire distributed environment.

[0033] Transactions: Record a sequence of operations in an application to ensure overall operational consistency.

[0034] Distributed transaction: A transaction on a computing node corresponds to a branch transaction on multiple data nodes, which together constitute a distributed transaction.

[0035] Distributed transaction consistency: When a transaction on a compute node is committed or rolled back, the branch transactions on each data node must also be committed or rolled back synchronously, thereby ensuring transaction consistency between different nodes.

[0036] In MD, a global commit sequence number (g_cmtseq) is used to sequentially count transaction commits in the system. When a transaction commits, the current value of g_cmtseq is obtained as the commit sequence number (cmtseq) of this transaction, and the system's g_cmtseq is incremented by 1. Transaction registration information (such as using a long array g_cmt_arr) is used to store the commit sequence numbers of each transaction in the system. When a transaction commits, the obtained cmtseq is written to the information corresponding to that transaction in g_cmt_arr. When a transaction starts or needs to perform visibility determination, it may also need to obtain the global commit sequence number as its own commit sequence number snapshot, denoted as snap_seq, in order to determine whether another transaction is visible to the current transaction.

[0037] Figure 1 This is a flowchart of a visibility determination method according to an embodiment of the present invention. This embodiment is applicable to situations where computing nodes or data nodes in a distributed database perform visibility determination during transaction execution. The method can be executed by a visibility determination device, which can be implemented in hardware and / or software. The visibility determination device can be configured in an electronic device, which can be configured as a computing node or data node. Figure 1 As shown, the method includes:

[0038] Step 101: In response to the first visibility determination event of the target transaction being triggered, obtain the current cache value from the transaction public cache data of this node to obtain the first cache commit sequence number snapshot, wherein the transaction public cache data includes the global commit sequence number in the metadata node of the distributed database.

[0039] For example, the target transaction can be any currently executing transaction (i.e., the currently active transaction) on the current node (compute node or data node, hereinafter referred to as this node). When the target transaction needs to determine the visibility of another transaction (such as determining whether a record modified by another transaction is visible to the target transaction), the first visibility determination event of the target transaction can be considered to be triggered. The first visibility determination event can be any visibility determination event triggered during the execution of the target transaction.

[0040] Optionally, the isolation level corresponding to the target transaction includes read committed. For the read committed isolation level, the commit sequence snapshot used when making different visibility determinations can be different.

[0041] For example, the transaction common cache data can be understood as the cache data shared by all transactions on each computing node. The transaction common cache data includes the global commit sequence number in the metadata node of the distributed database. That is, it is the global commit sequence number obtained and cached from the metadata node. Generally, it is not guaranteed that the latest global commit sequence number is cached in real time, that is, there may be a certain lag. For example, the latest global commit sequence number in the metadata node has been updated to S3, while the current cached value in the transaction common cache data may be S2 (S3 is greater than S2).

[0042] For example, after the first visibility judgment event of the target transaction is triggered, the current cache value is obtained from the transaction public cache data of this node, and the obtained current cache value is used as the current cache commit sequence number snapshot of the target transaction, which is recorded as the first cache commit sequence number snapshot.

[0043] Step 102: Determine the first target commit sequence number snapshot of the target transaction based on the first cached commit sequence number snapshot.

[0044] For example, the first cached commit sequence number snapshot can be used as the current commit sequence number snapshot of the target transaction, and denoted as the first target commit sequence number snapshot.

[0045] Step 103: Perform an initial visibility assessment based on the first target submission sequence number snapshot.

[0046] In this embodiment of the invention, the specific method for determining visibility based on the submitted sequence number snapshot is not limited.

[0047] For example, let's take the current active transaction T1 determining whether transaction T0 is visible:

[0048] Search for the cmtseq corresponding to T0 in g_cmt_arr. If it is not found, it means that T0 has not been committed, and therefore it is definitely not visible to T1.

[0049] If the cmtseq of T0 is found, and the cmtseq of T0 is greater than or equal to the snap_seq of T1, it means that T0 was committed after T1 started and is not visible to T1.

[0050] If the cmtseq of T0 is found, and the cmtseq of T0 is less than the snap_seq of T1, it means that T0 was committed before T1 started, and it is visible to T1.

[0051] For example, assuming the target transaction is T1, the snapshot of the first target commit sequence number is used as the snapshot_seq of T1, and the above judgment is performed to obtain the initial judgment result, without needing to obtain the latest global commit sequence number from MD for visibility judgment.

[0052] Step 104: If the initial judgment result is visible, determine that the visibility judgment result of the first visibility judgment event is visible.

[0053] For example, if the cmtseq of T0 is found, and the cmtseq of T0 is less than the first target submission sequence number snapshot of T1, the initial judgment result is visible. At this time, the visibility judgment result of the first visibility judgment event can be determined to be visible.

[0054] For example, since the first target commit sequence number snapshot is determined based on the cached value, it can be understood as an expired snap_seq. If the initial judgment result is visible, even if the latest commit sequence number snapshot is obtained, the record previously judged as visible will not become invisible, because the visible record has been committed and its cmtseq is less than the expired snap_seq. The newly retrieved valid cached snap_seq must be greater than or equal to the expired snap_seq. Therefore, the visibility of the transaction to this record will not change with the update of snap_seq. Thus, the visibility judgment result of the visibility judgment event is directly concluded to be visible.

[0055] The visibility determination method of this invention involves a computing node or data node in a distributed database. In response to a visibility determination event for a target transaction being triggered, the node retrieves the current cached value from its transaction public cache data to obtain a cached commit sequence number snapshot. Based on this snapshot, the node determines the target commit sequence number snapshot for the target transaction. An initial visibility determination is then performed based on this snapshot. If the initial determination indicates visibility, the visibility determination result of the visibility determination event is confirmed as visible. By employing this technical solution, when visibility determination is required, the current cached value can be directly retrieved from the transaction public cache data for initial determination. If the initial determination indicates visibility, the visibility determination result can be directly obtained without waiting for the latest global commit sequence number from the metadata node as the target commit sequence number snapshot. This reduces communication costs with the metadata node and improves the efficiency of visibility determination and transaction execution.

[0056] Figure 2 This is a flowchart of another visibility determination method provided by an embodiment of the present invention, which is optimized based on the above optional embodiments, such as... Figure 2 As shown, the method includes:

[0057] Step 201: In response to the first visibility judgment event of the target transaction being triggered, obtain the current cache value from the transaction public cache data of this node and obtain the first cache commit sequence number snapshot.

[0058] Step 202: Determine the first target commit sequence number snapshot of the target transaction based on the first cached commit sequence number snapshot.

[0059] Step 203: Perform an initial visibility assessment based on the first target's submitted sequence number snapshot.

[0060] Step 204: Determine whether the initial judgment result is visible. If yes, proceed to step 205; otherwise, proceed to step 206.

[0061] Step 205: Determine the visibility judgment result of the first visibility judgment event as visible.

[0062] Step 206: Retrieve the current cache value from the transaction public cache data to obtain the second cache commit sequence number snapshot, until the obtained second cache commit sequence number snapshot meets the preset effective conditions.

[0063] The current cached value in the transaction public cache data is updated after the snapshot refresh event is triggered.

[0064] For example, the specific triggering method for the snapshot refresh event is not limited and there may be multiple situations. For instance, when any transaction starts on this node, it can request the latest global commit sequence number from MD and update the current cached value in the transaction public cache data to the latest global commit sequence number, which is to refresh the current cached value in the transaction public cache data.

[0065] Optionally, in response to a transaction commit event, the global commit sequence number in the metadata node is incremented by one, and the current cached value in the transaction common cache data is refreshed. A transaction commit event can be understood as a transaction commit operation occurring in this node. Refreshing the current cached value in the transaction common cache data can be understood as obtaining the incremented global commit sequence number from the metadata node and using this obtained global commit sequence number as the new current cached value in the transaction common cache data. The advantage of this setting is that when a transaction commits, the system's g_cmtseq is incremented by 1, meaning the current cached value is at least 1 less than the latest global commit sequence number. Therefore, timely refreshing of the current cached value in the transaction common cache data improves the accuracy of visibility determination results.

[0066] Step 207: Determine the second target commit sequence number snapshot of the target transaction based on the second cache commit sequence number snapshot that meets the preset effective conditions.

[0067] Optionally, the preset effective conditions include: the update timestamp corresponding to the second cache submission sequence number snapshot is greater than or equal to the request timestamp corresponding to the target transaction.

[0068] For example, the target transaction starts when it first receives a request. After starting, it can continue to receive requests. The request timestamp corresponding to the target transaction can be the time when the request was first received and registered, or it can be the time when the request was most recently received and registered. The transaction public cache data can also include the update timestamp corresponding to the current cached value, that is, the time when the current cached value last changed. If the update timestamp is less than the request timestamp, it means that the current cached value was updated before the request was received, and it is likely to be inaccurate. However, if the update timestamp is greater than or equal to the request timestamp, it means that the current cached value was updated when the request was received, and it can be considered accurate and can be used for visibility determination.

[0069] Optionally, the preset effective conditions may also include: such as the difference between the update timestamp corresponding to the second cache submission sequence number snapshot and the request timestamp corresponding to the target transaction being greater than a first preset value, or the difference between the update timestamp corresponding to the second cache submission sequence number snapshot and the request timestamp corresponding to the target transaction being greater than a second preset value, etc.

[0070] Optionally, one or more of the above conditions can be set as preset effective conditions according to actual needs.

[0071] Step 208: Determine the visibility of the snapshot submitted by the second target to obtain the visibility determination result of the first visibility determination event.

[0072] For example, since the determined second target commit number is determined based on a valid cached commit number, it can be considered an accurate snapshot of the commit number, thus enabling an accurate visibility judgment result.

[0073] The visibility determination method provided in this embodiment of the invention, when visibility judgment is required, first obtains the current cached value from the transaction public cache data for initial judgment. If the initial judgment is visible, the visibility judgment result can be obtained directly without waiting to obtain the latest global commit sequence number from the metadata node as the target commit sequence number snapshot, reducing the communication cost with the metadata node and improving the efficiency of visibility judgment and transaction execution. If the initial judgment result is not visible, a valid cached commit sequence number snapshot is obtained again to determine a new target commit sequence number snapshot, and then the new target commit sequence number snapshot is used to judge visibility, ensuring the accuracy of the visibility judgment result.

[0074] In some embodiments, before obtaining the first cached sequence number snapshot from the transaction public cache data of the local node in response to the first visibility determination event of the target transaction being triggered, the method further includes: in response to the snapshot refresh event of the target transaction being triggered, performing an update operation on the transaction public cache data, pausing the retrieval of the current cached value from the transaction public cache data, and setting the snapshot validity flag corresponding to the target transaction to invalid. The update operation on the transaction public cache data includes retrieving the latest global commit sequence number from the metadata node and updating the current cached value in the transaction public cache data to the latest global commit sequence number. The advantage of this setting is that the cached snapshot_seq is not retrieved temporarily because the cached snapshot_seq refresh action may not have finished executing, and the value retrieved at this time may not be the latest. By not waiting for the refresh result of the update operation and executing the subsequent operations of the transaction first, the transaction execution efficiency can be improved. When visibility determination is required, the current cached value is then retrieved from the transaction public cache data of the local node.

[0075] For example, the specific way the snapshot refresh event of the target transaction is triggered is not limited, such as triggering the snapshot refresh event of the target transaction when the target transaction starts. Each transaction can correspond to a snapshot validity identifier. The execution of the target transaction and the update operation of the transaction common cache data can be implemented by different threads, and the two threads can be executed in parallel. When the first thread detects that the target transaction has started, it can trigger the snapshot refresh event of the target transaction, notifying the second thread to execute the update operation of the transaction common cache data. However, this update operation may take some time. Therefore, the first thread pauses the acquisition of the current cache value and sets the snapshot validity identifier to invalid. After the second thread completes the update operation, the transaction common cache data is updated, and the first thread does not need to wait for the second thread to complete the update operation and can execute the subsequent operations of the target transaction first.

[0076] In some embodiments, after determining the second target commit sequence number snapshot of the target transaction based on the second cached commit sequence number snapshot that meets the preset effective conditions, the method further includes: setting the snapshot validity identifier corresponding to the target transaction to valid. Wherein, after determining visibility based on the second target commit sequence number snapshot and obtaining the visibility determination result of the visibility determination event, the method further includes: in response to the second visibility determination event of the target transaction being triggered, if the snapshot validity identifier corresponding to the target transaction is valid, determining visibility based on the current target commit sequence number snapshot corresponding to the target transaction, and obtaining the visibility determination result of the second visibility determination event. The advantage of this setting is that after the snapshot validity identifier becomes valid, when the second visibility determination event (if it is different from the transaction requiring visibility determination corresponding to the first visibility determination event) is triggered, the current target commit sequence number snapshot can be used directly for visibility determination, without needing to obtain the current cache value from the transaction public cache data, which can further improve the efficiency of visibility determination.

[0077] Optionally, if the snapshot validity flag corresponding to the target transaction is set to valid and then the snapshot refresh event of the target transaction is triggered, the snapshot validity flag corresponding to the target transaction can be reset to invalid. This ensures the validity of the target commit sequence number snapshot used for visibility determination.

[0078] To better understand the technical solutions of the embodiments of the present invention, the following description uses a specific transaction process as an example:

[0079] (1) Transaction T1 is committed, and its cmtseq = S1;

[0080] (2) Cache snap_seq is moved to S2;

[0081] (3) Transaction T2 starts and obtains the expired cache snap_seq = S2;

[0082] (4) Transaction T3 commits, and its cmtseq = S3 (assuming that there are also transaction commits on other nodes, making cmtseq change from S2 to S3);

[0083] (5) The cache snap_seq is advanced to S4, and at this time it is valid for transaction T2.

[0084] When transaction T2 determines the visibility of the records modified by T1, because S2 > S1, it can directly determine that T1 is visible to itself without waiting for (4) the cache snap_seq to become effective for itself. It doesn't need to wait until it needs to determine the visibility of transaction T3. Because S2 < S3, it initially determines that T3 is not visible to itself. At this time, it needs to wait for the cache snap_seq to be refreshed (5), and then determine the final visibility of T3 after obtaining the effective cache snap_seq. Since the timing of obtaining the effective cache snap_seq is further delayed, in most cases, the cache snap_seq has been refreshed after T2 starts, so the time consumed waiting for the cache to become effective is further compressed.

[0085] Figure 3 It is a flowchart of another visibility determination method provided according to an embodiment of the present invention, which is optimized based on the above optional embodiment. As Figure 3 shown, the method includes:

[0086] Step 301, in response to the triggering of the snapshot refresh event of the target transaction, perform the update operation of the transaction public cache data, pause obtaining the current cache value from the transaction public cache data, and set the snapshot validity flag corresponding to the target transaction to invalid.

[0087] Exemplarily, when it is detected that the target transaction starts or a request registration of the target transaction is received, a snapshot refresh event of the target transaction is triggered. For example, taking T2 in the above transaction process as the target transaction, when transaction T2 starts, a cache snap_seq refresh action is triggered, but the cache snap_seq is not obtained first, and only the snapshot validity flag (snap_valid) is set to 0, indicating that the snap_seq of the target transaction is invalid. The advantage of not obtaining the cache snap_seq temporarily is that since the cache snap_seq refresh action may not have been completed, the value obtained at this time is not the latest. Without waiting for the refresh result and performing the subsequent steps first can improve efficiency.

[0088] Step 302, in response to the triggering of the first visibility determination event of the target transaction, obtain the current cache value from the transaction public cache data of this node to obtain the first cache commit sequence number snapshot.

[0089] For example, when transaction T2 first checks visibility, it directly obtains the current cached snap_seq and keeps snap_valid = 0.

[0090] Step 303: Determine the first target commit sequence number snapshot of the target transaction based on the first cached commit sequence number snapshot.

[0091] Step 304: Perform an initial visibility assessment based on the snapshot number submitted by the first target.

[0092] Step 305: Determine whether the initial judgment result is visible. If yes, proceed to step 306; otherwise, proceed to step 307.

[0093] Step 306: Determine the visibility judgment result of the first visibility judgment event as visible.

[0094] For example, transaction T2 first uses the currently registered invalid snap_seq to determine the visibility of the record. If the record is visible, it directly returns the result.

[0095] Step 307: Retrieve the current cache value from the transaction public cache data to obtain the second cache commit sequence number snapshot. Continue until the obtained second cache commit sequence number snapshot meets the preset effective conditions. Based on the second cache commit sequence number snapshot that meets the preset effective conditions, determine the second target commit sequence number snapshot of the target transaction and set the snapshot validity flag corresponding to the target transaction to valid.

[0096] For example, transaction T2 waits for the cached snap_seq to become valid before retrieving the updated snap_seq. Once a valid snap_seq is determined, snap_valid is set to 1. The advantage of retrieving the cached snap_seq at this point is that the cache snap_seq refresh action triggered in step 301 has already been completed or is nearly completed, or other actions triggering the cache snap_seq refresh have already been completed. Therefore, the cached snap_seq is now up-to-date or about to be up-to-date. Retrieving the latest cached snap_seq in this step, compared to retrieving it in step 301, requires no waiting or the waiting time is very short, thus improving efficiency.

[0097] Step 308: In response to the second visibility judgment event of the target transaction being triggered, if the snapshot validity flag corresponding to the target transaction is valid, the visibility is judged according to the current target commit sequence number snapshot corresponding to the target transaction, and the visibility judgment result of the second visibility judgment event is obtained.

[0098] For example, since snap_valid=1 has been marked, the registered snap_seq is used directly to determine visibility regardless of whether the record is visible, which further improves efficiency.

[0099] The visibility determination method provided in this invention involves, after the snapshot refresh event of the target transaction is triggered, performing an update operation on the transaction's common cache data, pausing the retrieval of the current cache value from the transaction's common cache data, and setting the snapshot validity flag to invalid. When visibility determination is required, the current cache value is first retrieved from the transaction's common cache data for initial determination. If the initial determination indicates visibility, the visibility determination result can be obtained directly without waiting to retrieve the latest global commit sequence number from the metadata node as the target commit sequence number snapshot, reducing the communication cost with the metadata node. If the initial determination result indicates invisibility, a valid cached commit sequence number snapshot is retrieved again to determine a new target commit sequence number snapshot, and then the new target commit sequence number snapshot is used for visibility determination, ensuring the accuracy of the visibility determination result. At the same time, the snapshot validity flag is set to valid, and subsequent visibility determination is performed using the valid target commit sequence number snapshot, effectively improving the efficiency of visibility determination and transaction execution efficiency.

[0100] Figure 4 This is a schematic diagram of a visibility determination device according to an embodiment of the present invention. The device is configured on a computing node or data node in a distributed database. Figure 4 As shown, the device includes:

[0101] The cache snapshot acquisition module 401 is used to obtain the current cache value from the transaction public cache data of this node in response to the first visibility judgment event of the target transaction being triggered, and obtain the first cache commit sequence number snapshot, wherein the transaction public cache data includes the global commit sequence number in the metadata node of the distributed database.

[0102] The target snapshot determination module 402 is used to determine the first target commit sequence number snapshot of the target transaction based on the first cached commit sequence number snapshot.

[0103] The initial judgment module 403 is used to perform an initial judgment on visibility based on the first target submission sequence number snapshot;

[0104] The visibility determination module 404 is used to determine that the visibility determination result of the first visibility determination event is visible if the initial determination result is visible.

[0105] The visibility determination device of this invention can directly obtain the current cache value from the transaction public cache data for initial judgment when visibility judgment is required. If the initial judgment is visible, the visibility judgment result can be obtained directly without waiting to obtain the latest global commit sequence number from the metadata node as the target commit sequence number snapshot, thereby reducing the communication cost between the metadata node and improving the efficiency of visibility judgment and transaction execution efficiency.

[0106] Optionally, the device may also include:

[0107] The cache commit sequence number snapshot acquisition module is used to, after the initial visibility judgment based on the first target commit sequence number snapshot, if the initial judgment result is not visible, retrieve the current cache value from the transaction public cache data to obtain a second cache commit sequence number snapshot, until the acquired second cache commit sequence number snapshot meets the preset effective conditions, wherein the current cache value in the transaction public cache data is updated after the snapshot refresh event is triggered;

[0108] The snapshot determination module is used to determine the second target commit sequence number snapshot of the target transaction based on the second cache commit sequence number snapshot that meets the preset effective conditions.

[0109] The visibility determination module is used to determine the visibility based on the second target submission sequence number snapshot, and obtain the visibility determination result of the first visibility determination event.

[0110] Optionally, the preset effective conditions include: the update timestamp corresponding to the second cache submission sequence number snapshot is greater than or equal to the request timestamp corresponding to the target transaction.

[0111] Optionally, the device may also include:

[0112] The first identifier setting module is used to, before the first visibility judgment event of the target transaction is triggered, retrieve the current cache value from the transaction public cache data of this node to obtain the first cache commit sequence number snapshot, and before the snapshot refresh event of the target transaction is triggered, execute the update operation of the transaction public cache data, suspend the retrieval of the current cache value from the transaction public cache data, and set the snapshot validity identifier corresponding to the target transaction to invalid. The update operation of the transaction public cache data includes retrieving the latest global commit sequence number from the metadata node and updating the current cache value in the transaction public cache data to the latest global commit sequence number.

[0113] Optionally, the device may also include:

[0114] The second identifier setting module is used to set the snapshot validity identifier corresponding to the target transaction to valid after determining the second target commit sequence number snapshot of the target transaction based on the second cache commit sequence number snapshot that meets the preset validity conditions.

[0115] The determination module is used to determine visibility based on the second target commit sequence number snapshot and obtain the visibility determination result of the visibility determination event. In response to the second visibility determination event of the target transaction being triggered, if the snapshot validity identifier corresponding to the target transaction is valid, the module determines visibility based on the current target commit sequence number snapshot corresponding to the target transaction and obtains the visibility determination result of the second visibility determination event.

[0116] Optionally, the device may also include:

[0117] The update module is used to increment the global commit sequence number in the metadata node and refresh the cached value in the transaction public cache data in response to the transaction commit event being triggered.

[0118] Optionally, the isolation level corresponding to the target transaction includes read committed.

[0119] The visibility determination device provided in the embodiments of the present invention can execute the visibility determination method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the method execution.

[0120] Figure 5 A schematic diagram of an electronic device 10 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0121] like Figure 5 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0122] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0123] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as the visibility determination method.

[0124] In some embodiments, the visibility determination method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or mounted on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the visibility determination method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the visibility determination method by any other suitable means (e.g., by means of firmware).

[0125] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0126] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0127] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0128] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0129] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0130] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0131] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0132] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A visibility determination method, characterized in that, The method, applied to computing nodes or data nodes in a distributed database, includes: In response to the first visibility determination event of the target transaction being triggered, the current cached value is obtained from the transaction public cache data of this node to obtain the first cached commit sequence number snapshot, wherein the transaction public cache data includes the global commit sequence number in the metadata node of the distributed database. The first target commit sequence number snapshot of the target transaction is determined based on the first cached commit sequence number snapshot. Initial visibility determination is performed based on the first target submission sequence number snapshot; If the initial judgment result is visible, the visibility judgment result of the first visibility judgment event is determined to be visible, and it is allowed to hold only the first target submission sequence number snapshot without waiting for the second cached submission sequence number snapshot to take effect; If the initial judgment result is invisible, the current cache value is retrieved again from the transaction public cache data to obtain the second cache commit sequence number snapshot, until the obtained second cache commit sequence number snapshot meets the preset effective conditions. The current cache value in the transaction public cache data is updated after the snapshot refresh event is triggered. The second target commit sequence number snapshot of the target transaction is determined based on the second cache commit sequence number snapshot that meets the preset effective conditions; Based on the second target submission sequence number snapshot, the visibility is determined, and the visibility determination result of the first visibility determination event is obtained.

2. The method according to claim 1, characterized in that, The preset effective conditions include: the update timestamp corresponding to the second cache submission sequence number snapshot is greater than or equal to the request timestamp corresponding to the target transaction.

3. The method according to claim 1, characterized in that, Before the first visibility determination event in response to the target transaction is triggered, and the current cache value is obtained from the transaction public cache data of this node to obtain the first cache commit sequence number snapshot, the method further includes: In response to the snapshot refresh event of the target transaction being triggered, the update operation of the transaction common cache data is executed, the retrieval of the current cache value from the transaction common cache data is paused, and the snapshot validity flag corresponding to the target transaction is set to invalid. The update operation of the transaction common cache data includes retrieving the latest global commit sequence number from the metadata node and updating the current cache value in the transaction common cache data to the latest global commit sequence number.

4. The method according to claim 3, characterized in that, After determining the second target commit sequence number snapshot of the target transaction based on the second cache commit sequence number snapshot that meets the preset effective conditions, the method further includes: Set the snapshot validity flag corresponding to the target transaction to valid; The process, after determining visibility based on the second target submission sequence number snapshot and obtaining the visibility determination result of the visibility determination event, further includes: In response to the second visibility determination event of the target transaction being triggered, if the snapshot validity identifier corresponding to the target transaction is valid, the visibility is determined based on the current target commit sequence number snapshot corresponding to the target transaction, and the visibility determination result of the second visibility determination event is obtained.

5. The method according to claim 1, characterized in that, Also includes: In response to a transaction commit event being triggered, the global commit sequence number in the metadata node is incremented by one, and the cached value in the transaction public cache data is refreshed.

6. The method according to any one of claims 1-5, characterized in that, The isolation level corresponding to the target transaction includes read committed.

7. A visibility determination device, characterized in that, The device comprises a computing node or data node configured in a distributed database, the node being used for such computing or data operations. The cache snapshot acquisition module is used to obtain the current cache value from the transaction public cache data of this node in response to the first visibility judgment event of the target transaction being triggered, and obtain the first cache commit sequence number snapshot, wherein the transaction public cache data includes the global commit sequence number in the metadata node of the distributed database. The target snapshot determination module is used to determine the first target commit sequence number snapshot of the target transaction based on the first cached commit sequence number snapshot. The initial judgment module is used to make an initial judgment on visibility based on the first target submission sequence number snapshot; The visibility determination module is used to determine that the visibility determination result of the first visibility determination event is visible when the initial determination result is visible, and allows holding only the first target submission sequence number snapshot without waiting for the second cached submission sequence number snapshot to take effect; The device further includes: The cache commit sequence number snapshot acquisition module is used to, after the initial visibility judgment based on the first target commit sequence number snapshot, if the initial judgment result is not visible, retrieve the current cache value from the transaction public cache data to obtain a second cache commit sequence number snapshot, until the acquired second cache commit sequence number snapshot meets the preset effective conditions, wherein the current cache value in the transaction public cache data is updated after the snapshot refresh event is triggered; The snapshot determination module is used to determine the second target commit sequence number snapshot of the target transaction based on the second cache commit sequence number snapshot that meets the preset effective conditions. The visibility determination module is used to determine the visibility based on the second target submission sequence number snapshot, and obtain the visibility determination result of the first visibility determination event.

8. An electronic device, characterized in that, The electronic device is configured as a computing node or data node in a distributed database, and the electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, which enables the at least one processor to perform the visibility determination method according to any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the visibility determination method according to any one of claims 1-6.