Transaction processing method and device for graph database, storage medium and program product

By creating new versions in the graph database and regularly persisting and migrating old versions, the problem of too many historical versions in the graph database is solved, system performance and stability are improved, and version chain management is optimized.

CN120541269APending Publication Date: 2025-08-26BEIJING ZITIAO NETWORK TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510627255.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-15
Publication Date
2025-08-26

AI Technical Summary

Technical Problem

The excessive historical versions in the graph database due to the mixture of OLAP transactions and OLTP transactions, occupying a large amount of resources, affecting system performance, especially in high concurrency scenarios, frequent historical version read and write operations seriously affect performance.

Method used

Create a new version of the target graph data in the first memory space of the graph database and add a pointer to the previous version. Persist the latest version to disk at each first preset time, and migrate the old version to the second memory space, reducing the number of disk persistence and memory usage, and reducing the number of versions through regular garbage collection.

Benefits of technology

Reduces the number of persistence to disk, reduces resource consumption, improves system performance and stability, optimizes the management of the version chain, reduces the number of versions, and improves the overall performance of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120541269A_ABST
    Figure CN120541269A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a graph database transaction processing method and device, a storage medium and a program product, and the method comprises the steps: creating a new version of target graph data in a first memory space used by a graph database in response to an updating instruction for the target graph data in the graph database; adding a pointer of a previous version of the target graph data in the new version of the target graph data, wherein the pointer is used for associating the new version of the target graph data with the previous version; the latest version of the target graph data in the first memory space is persisted to a disk of the graph database every first preset time; and migrating the old version of the target graph data in the first memory space to a second memory space used by the graph database. According to the embodiment of the invention, the number of times of persisting the version to the disk can be reduced, the old version in the first memory space is migrated to the second memory space for subsequent use or version chain reconstruction, unified garbage collection of the old version is facilitated, resource consumption is reduced, and system performance is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present disclosure relate to the field of computer technology, and in particular to a transaction processing method, device, storage medium, and program product for a graph database. Background Art

[0002] A graph database is a database specifically designed for efficiently storing, querying, and processing relational data. It uses a graph structure (nodes, edges, attributes) to directly represent data and its relationships.

[0003] In graph databases, transactions such as OLAP (Online Analytical Processing) and OLTP (Online Transaction Processing) require snapshot isolation (SI), which is usually implemented through multi-version concurrency control (MVCC).

[0004] However, due to the characteristics of graph database workloads, implementing snapshot isolation will lead to too many historical versions of graph data, occupying a large amount of resources and affecting system performance. Summary of the Invention

[0005] The embodiments of the present disclosure provide a transaction processing method, device, storage medium, and program product for a graph database, so as to effectively reduce the number of graph data versions, reduce resource consumption, and improve system performance.

[0006] In a first aspect, an embodiment of the present disclosure provides a transaction processing method for a graph database, including:

[0007] In response to an update instruction for target graph data in a graph database, creating a new version of the target graph data in a first memory space used by the graph database, and adding a pointer to a previous version of the target graph data to the new version of the target graph data, wherein the pointer is used to associate the new version of the target graph data with the previous version;

[0008] Persisting the latest version of the target graph data in the first memory space to the disk of the graph database at intervals of a first preset time;

[0009] Migrate the old version of the target graph data in the first memory space to the second memory space used by the graph database.

[0010] In a second aspect, an embodiment of the present disclosure provides a transaction processing device for a graph database, including:

[0011] an updating unit, configured to, in response to an update instruction for target graph data in a graph database, create a new version of the target graph data in a first memory space used by the graph database, and add a pointer to a previous version of the target graph data in the new version of the target graph data, wherein the pointer is used to associate the new version of the target graph data with the previous version;

[0012] A graph data management unit is configured to persist the latest version of the target graph data in the first memory space to the disk of the graph database at intervals of a first preset time, and to migrate the old version of the target graph data in the first memory space to the second memory space used by the graph database.

[0013] In a third aspect, an embodiment of the present disclosure provides an electronic device, including: a processor and a memory;

[0014] The memory stores computer-executable instructions;

[0015] The processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the transaction processing method of the graph database as described in the first aspect and various possible designs of the first aspect.

[0016] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the transaction processing method of the graph database as described in the first aspect and various possible designs of the first aspect is implemented.

[0017] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements the transaction processing method of the graph database as described in the first aspect and various possible designs of the first aspect.

[0018] The transaction processing method, device, storage medium and program product of the graph database provided by the embodiments of the present disclosure, in response to an update instruction for the target graph data in the graph database, creates a new version of the target graph data in the first memory space used by the graph database, and adds a pointer to the previous version of the target graph data in the new version of the target graph data, the pointer being used to associate the new version of the target graph data with the previous version; persists the latest version of the target graph data in the first memory space to the disk of the graph database at intervals of a first preset time; and migrates the old version of the target graph data in the first memory space to the second memory space used by the graph database. In the embodiments of the present disclosure, by periodically persisting the latest version of the target graph data in the first memory space to the disk of the graph database, the number of persistence times to the disk can be reduced, and by migrating the old version of the target graph data in the first memory space to the second memory space used by the graph database for subsequent use or reconstruction of the version chain, the occupancy of the first memory space can be reduced to ensure the stability of the service, and it is convenient to uniformly garbage collect the old versions, reduce the number of versions, reduce resource consumption, and improve system performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0020] Figure 1 This is an example diagram of transaction processing of a graph database in the prior art;

[0021] Figure 2 A flowchart of a transaction processing method for a graph database provided in one embodiment of the present disclosure;

[0022] Figure 3 A flowchart of a transaction processing method for a graph database provided in another embodiment of the present disclosure;

[0023] Figure 4 A structural block diagram of a transaction processing device for a graph database provided in one embodiment of the present disclosure;

[0024] Figure 5 A schematic diagram of the hardware structure of an electronic device provided in one embodiment of the present disclosure. DETAILED DESCRIPTION

[0025] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure more clear, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present disclosure without making any creative efforts shall fall within the scope of protection of the present disclosure.

[0026] OLAP transactions, OLTP transactions and other transactions in graph databases all require snapshot isolation (SI), which is usually implemented through multi-version concurrency control (MVCC).

[0027] The multi-version concurrency control mechanism is that when multiple transactions execute concurrently, the system provides each transaction with a specific version snapshot of the data. This ensures isolation between transactions, ensuring that each transaction sees a consistent view of the data at its start, and preventing mutual interference. Multi-version concurrency control relies on version chains, which organize different versions, typically linked by pointers to form a linked list structure. This allows read operations to not block write operations, and vice versa. Different transactions can access different versions of the same data, reducing lock contention.

[0028] OLAP transactions generally involve complex data analysis based on target graph data and usually take a long time to execute, while OLTP transactions generally involve daily high-frequency operations based on target graph data, such as adding, deleting, modifying, and querying, and usually take a shorter time to execute.

[0029] However, due to the characteristics of graph database workloads, implementing snapshot isolation can lead to excessive historical versions of graph data, occupying a large amount of resources and affecting system performance. This is manifested in the following ways:

[0030] OLTP transaction data is written concurrently with OLAP transactions, making the cleanup of historical versions complicated. Figure 1 As shown, Graph Data 1 has multiple versions, Version 1 through Version 4. Furthermore, T(A), T(C), and T(E) are all OLAP transactions that depend on different historical versions of Graph Data 1. The traditional MVCC recycling mechanism can only recycle dependent historical versions after the oldest transaction completes, so Versions 1 through 4 cannot be recycled.

[0031] Most OLTP transactions execute very quickly, so the number of historical versions required is far less than that of OLAP transactions. For example, transactions T(B), T(D), and T(F) are all OLTP transactions. Since they complete quickly, they no longer rely on the corresponding versions (i.e., Version 1, Version 2, and Version 4).

[0032] There are two main reasons for the problem of system performance degradation caused by the mixing of OLTP transactions and OLAP transactions: First, disk I / O amplification. Due to the long execution of OLAP transactions, many historical data versions are accumulated, which makes it impossible to store them completely in memory. As a result, a large number of snapshots of data versions need to be written to disk, especially in high-concurrency scenarios. A large number of transactions are carried out at the same time, and frequent historical version read and write operations seriously affect the read and write performance; second, historical version retrieval consumes CPU resources. Since a large number of historical versions are at the end of the version chain, a large number of unnecessary versions need to be traversed when retrieving a specific version. Each retrieval consumes a lot of additional CPU resources. At the same time, since some OLAP transactions run for a long time, these historical versions may take tens of minutes to be completely cleaned up, and because long transactions will continue to be generated, it is impossible to directly recycle intermediate versions in advance, such as Figure 1 As shown in the figure, most versions are dependent on different long transactions (T(A), T(C), and T(E)). Even if we attempt to recycle intermediate short transaction versions, a large number of historical versions will still remain unrecovered. Furthermore, when analyzing workloads in depth, OLTP throughput is typically very high, and most operations do not require snapshot isolation. Therefore, the main challenge currently lies in optimizing the implementation of snapshot isolation to minimize the impact on system performance, given the different latency requirements of OLAP and OLTP transactions shown in the figure.

[0033] In summary, existing technologies suffer from disk I / O amplification. OLAP transactions accumulate a large number of historical versions over long periods of time. When memory cannot fully store them, they need to be written to disk. Frequent reading and writing in high-concurrency scenarios seriously impacts performance. Version retrieval during transaction execution consumes CPU resources. A large number of historical versions are located at the end of the version chain. Retrieving a specific version requires traversing a large number of unnecessary versions, consuming a large amount of CPU resources.

[0034] In order to solve the above technical problems, the embodiment of the present disclosure provides a transaction processing method for a graph database, which creates a new version of the target graph data in a first memory space used by the graph database in response to an update instruction for target graph data in the graph database, and adds a pointer to the previous version of the target graph data in the new version of the target graph data, wherein the pointer is used to associate the new version of the target graph data with the previous version; persists the latest version of the target graph data in the first memory space to the disk of the graph database at intervals of a first preset time; and migrates the old version of the target graph data in the first memory space to the second memory space used by the graph database. In this embodiment, by periodically persisting the latest version of the target graph data in the first memory space to the disk of the graph database, the number of persistence times to the disk can be reduced, and by migrating the old version of the target graph data in the first memory space to the second memory space used by the graph database for subsequent use or reconstruction of the version chain, the occupation of the first memory space can be reduced to ensure the stability of the service, and it is convenient to uniformly garbage collect the old versions, reduce the number of versions, reduce resource consumption, and improve system performance.

[0035] The activation of relevant functions of the embodiments of the present disclosure, the data obtained, the processing and storage methods of the data, etc., shall all be authorized in advance by the user and other rights holders associated with the user, and shall comply with the provisions of relevant laws and regulations and the rules of agreement between rights holders.

[0036] The transaction processing method of the graph database disclosed in the present invention will be introduced in detail below with reference to specific embodiments.

[0037] refer to Figure 2 , Figure 2 This is a flow chart of a graph database transaction processing method provided by one embodiment of the present disclosure. The method of this embodiment can be applied to electronic devices such as terminal devices or servers. The graph database transaction processing method includes:

[0038] S201. In response to an update instruction for target graph data in a graph database, a new version of the target graph data is created in a first memory space used by the graph database, and a pointer to a previous version of the target graph data is added to the new version of the target graph data, wherein the pointer is used to associate the new version of the target graph data with the previous version.

[0039] In this embodiment, the graph database may include multiple graph data, wherein the graph data is composed of nodes and edges connecting the nodes. Nodes may represent entities, such as people, places, commodities, events, etc., and edges may represent connections between nodes. When a user needs to update the target graph data, including but not limited to adding, deleting, or modifying at least one node and / or at least one edge of the target graph data, an update instruction for the target graph data may be triggered, thereby creating a new version of the target graph data in the first memory space used by the graph database. The new version of the target graph data is the updated version of the target graph data.

[0040] After each update, a pointer to the previous version can be added to each version of the target graph data. This pointer links the new version of the target graph data to the previous version. This pointer allows you to build a version chain for the target graph data, allowing you to quickly locate the required version when you need to search for or use any version of the target data. When a new version of the target graph data is created, a pointer to the previous version can also be added to the new version, allowing you to add the new version to the target graph data's version chain through the pointer.

[0041] S202: Persist the latest version of the target graph data in the first memory space to the disk of the graph database at intervals of a first preset time.

[0042] In this embodiment, the latest version of the target graph data in the first memory space is persisted to the disk of the graph database at intervals of a first preset time, without the need to persist every version of the target graph data to the disk of the graph database. This can reduce the number of persistence times to the disk, avoid frequent writing of various versions of the target graph data to the disk in high concurrency scenarios, and avoid occupying too many resources and affecting performance. It also reduces the number of versions of the target graph data on the disk.

[0043] S203: Migrate the old version of the target graph data in the first memory space to the second memory space used by the graph database.

[0044] In this embodiment, the old version of the target graph data in the first memory space is migrated to the second memory space used by the graph database for subsequent use or reconstruction of the version chain. This can also prevent the old version from occupying too much space in the first memory space, ensuring that there is enough remaining space in the first memory space to continue creating new versions of the target graph data or new versions of other graph data. In addition, the second memory space stores old versions of various graph data, which facilitates unified garbage collection and reduces the number of versions. In specific implementation, during migration, the old version of the target graph data in the first memory space can be found based on the pointer; and after migration to the second memory space, the pointers of the various versions of the target graph data in the first memory space and the second memory space can be updated.

[0045] Optionally, when the remaining space in the first memory space is less than a preset threshold (or the usage of the first memory space exceeds a preset usage), or at a first preset time interval, the old version of the target graph data in the first memory space can be migrated to the second memory space used by the graph database. This can implement batch version migration, avoid frequent version migration, and avoid occupying too many resources. Alternatively, when the first memory space is full (equivalent to the remaining space in the first memory space being 0), the old version of the target graph data in the first memory space can be migrated to the second memory space.

[0046] The transaction processing method for a graph database provided in this embodiment creates a new version of the target graph data in the first memory space used by the graph database in response to an update instruction for the target graph data in the graph database, and adds a pointer to the previous version of the target graph data in the new version of the target graph data, wherein the pointer is used to associate the new version of the target graph data with the previous version; persists the latest version of the target graph data in the first memory space to the disk of the graph database at intervals of a first preset time; and migrates the old version of the target graph data in the first memory space to the second memory space used by the graph database. In this embodiment, by periodically persisting the latest version of the target graph data in the first memory space to the disk of the graph database, the number of persistence times to the disk can be reduced, and by migrating the old version of the target graph data in the first memory space to the second memory space used by the graph database for subsequent use or reconstruction of the version chain, the occupation of the first memory space can be reduced to ensure the stability of the service, and it is convenient to uniformly garbage collect old versions, reduce the number of versions, reduce resource consumption, and improve system performance.

[0047] Based on any of the above embodiments, the method further includes:

[0048] Filter the old versions to be recycled from the old versions of the target graph data in the second memory space, and perform garbage collection on the old versions to be recycled, wherein the old versions to be recycled are old versions whose creation time is more than a second preset time from the current time, and the second preset time is greater than or equal to the first preset time.

[0049] In this embodiment, one or more old versions of the target graph data are cached in the second memory space. However, since the storage space of the second memory space is limited, and in order to avoid an excessive number of versions of the target graph data, the old versions of the target graph data in the second memory space can be garbage collected. Specifically, the retention time of the old versions is controlled, for example, a second preset time is retained, that is, if the creation time of an old version exceeds the second preset time from the current time, it needs to be garbage collected. Therefore, the old versions to be recycled can be screened from the old versions of the target graph data in the second memory space based on the second preset time. The old versions to be recycled are the old versions whose creation time exceeds the second preset time from the current time, and then the old versions to be recycled can be garbage collected. Among them, the second preset time can be greater than or equal to the first time interval in the above embodiment, so that the availability of the old versions before the latest version is persisted can be guaranteed, and the old versions before the latest version is persisted can be avoided from being cleared. It can be ensured that the old version can be rolled back to when the persistence process of the latest version fails or the latest version is lost. In addition, the old versions in the second memory space can also be used by subsequent transactions and can also be used to build a version chain of the target graph data.

[0050] It should be noted that when garbage collection is performed on the old version to be recycled, the pointer in the version after the old version to be recycled can be updated, and the pointer in the version after the old version to be recycled can be pointed to the version before the old version to be recycled, so as to ensure that the version chain of the target graph data can be reconstructed according to the pointer and the connection of the version chain can be guaranteed.

[0051] Based on any of the above embodiments, Figure 3 As shown, the method further includes:

[0052] S301. In response to a processing request for a target transaction for the target graph data, obtain a target version of the target graph data; wherein, if the target transaction is a first-type transaction, the target version of the target graph data is any version of the target graph data on the disk; if the target transaction is a second-type transaction, the target version of the target graph data is any version of the target graph data in the first memory space or the second memory space; wherein the execution period of the first-type transaction is greater than the execution period of the second-type transaction;

[0053] S302: Execute the target transaction according to the target version of the target graph data.

[0054] In this embodiment, the target transaction for the target graph data is also the transaction that needs to access or use the target graph data, which may specifically include but is not limited to OLAP transactions, OLTP transactions, etc., among which OLAP transactions are generally based on the target graph data for complex data analysis, and usually have a longer execution time, while OLTP transactions are generally based on the target graph data for daily high-frequency operations, such as adding, deleting, modifying, and checking, etc., and usually have a shorter execution time. Therefore, based on the execution cycle, the target transactions can be divided into first-class transactions and second-class transactions, among which the execution cycle of the first-class transactions is greater than the execution cycle of the second-class transactions. OLAP transactions can belong to the first-class transactions, and OLTP transactions can belong to the second-class transactions. More specifically, the execution cycle of the first type of transaction is greater than or equal to the preset time cycle threshold, while the execution cycle of the second type of transaction is less than the preset time cycle threshold. Therefore, the execution cycle of the target transaction can be predicted and compared with the preset time cycle threshold to determine the type of the target transaction; optionally, considering that the execution cycle of the target transaction is related to the degree (number of edges) that needs to be traversed, for example, if the target transaction a needs to query the child nodes of the node, it needs to traverse two degrees, and if the target transaction b needs to query the grandchild nodes of the node, it needs to traverse three degrees. Therefore, the execution cycle of the target transaction b is longer. Therefore, in this embodiment, the degree threshold when the preset time cycle threshold is reached can be determined, and then the degree of the nodes involved in the target transaction can be compared with the degree threshold. If the degree threshold is exceeded, it is determined to be a first type of transaction. If the degree threshold is not exceeded, it is determined to be a second type of transaction.

[0055] Considering that the versions in the first memory space and the second memory space may be cleaned up in the garbage collection stage, and the first type of transaction is a transaction with a long execution cycle, its execution cycle may be longer than the time cycle of garbage collection in memory. In order to avoid the operation of the first type of transaction affecting the garbage collection of the in-memory version, and also to avoid the target version required by the first type of transaction being cleaned up in memory, the first type of transaction can be limited to only use the version of the target graph data on the disk, and not use the version of the target graph data in the first memory space or the second memory space. In this way, the execution of the first type of transaction is guaranteed without affecting the cleaning of the old version in the second memory space, which can effectively reduce the number of versions; and the second type of transaction is a transaction with a short execution cycle, and its execution cycle is generally shorter than the time cycle of garbage collection in memory. Therefore, the second type of transaction can use the version of the target graph data in the first memory space or the second memory space, and of course, the version of the target graph data on the disk can also be used.

[0056] On this basis, in response to the processing request for the target transaction for the target graph data, the target version of the target graph data required by the target transaction can be obtained. Specifically, if the target transaction is a first-type transaction, the target version of the target graph data is obtained from the disk. If the target transaction is a second-type transaction, the target version of the target graph data can be obtained from the first memory space or the second memory space. The target transaction can then be executed according to the target version of the target graph data, which can better ensure the processing of transactions in different execution cycles.

[0057] Optionally, when obtaining the target version of the target graph data, the following steps may be specifically included:

[0058] Determining a creation time of the target transaction;

[0059] If the target transaction is a first-category transaction, obtaining the latest version of the target graph data before the creation time from the disk as the target version of the target graph data; or

[0060] If the target transaction is a second-category transaction, the latest version of the target graph data before the creation time is obtained from the first memory space or the second memory space as the target version of the target graph data.

[0061] In this embodiment, when a target transaction is created, it is necessary to use the latest version of the target graph data at the creation time. However, since the target transaction may not be processed immediately after creation, a version update may occur in the time interval between the creation time and the current time. Therefore, when processing the target transaction, the creation time of the target transaction can be determined first, and then the latest version of the target graph data at the creation time can be found. Specifically, if the target transaction is a first-class transaction, the latest version of the target graph data before the creation time of the target transaction is obtained from the disk, that is, the version with a creation time before the creation time of the target transaction and the closest to the creation time of the target transaction is found on the disk. If the target transaction is a second-class transaction, the latest version of the target graph data before the creation time of the target transaction is obtained from the first memory space or the second memory space, that is, the version with a creation time before the creation time of the target transaction and the closest to the creation time of the target transaction is found in the first memory space and the second memory space. In this way, the target transaction can use the latest version of the target graph data at the creation time.

[0062] Based on any of the above embodiments, if there are multiple target transactions that are first-category transactions, the multiple first-category transactions may be divided into batches according to their creation time and the first preset time, wherein the creation time of the first-category transactions in the same batch falls within the same time window of the first preset time;

[0063] For any batch of first-type transactions, the latest version of the target graph data on the disk within the time window corresponding to the first-type transactions of the batch is obtained, and the target transactions of the batch are executed according to the latest version.

[0064] In this embodiment, if there are multiple first-class transactions, the multiple first-class transactions can be divided into batches. The target version of the target graph data used by the transactions in the same batch is the same. In this way, the target version of the target graph data only needs to be obtained once, which reduces the disk I / O pressure. Among them, multiple first-class transactions can be divided into batches according to the creation time of the first-class transactions and the first preset time, and the first-class transactions whose creation time is within the same first preset time window are divided into the same batch. That is, assuming that the first preset time is t, the latest version of the target graph data in the first memory space is persisted to the disk every first preset time t. Assuming that the latest version of the target graph data in the first memory space is persisted to the disk at time t0, and the next persistence is performed at time t0+t, the first-class transactions created in the time window of t0~t0+t can be divided into the same batch. The first-class transactions in this batch can use the latest version of the target graph data on the disk, that is, the latest version persisted to the disk at time t0. In this way, it can be ensured that the first-class data in this batch only needs to load one data version when it is executed, reducing the disk I / O pressure, and the first-class data in this batch will not be affected by the updated version of the target graph data, nor will it affect the version update of the target graph data.

[0065] On the basis of the above embodiment, in order to avoid the execution of a large number of first-class transactions in a short period of time and affecting the service stability, the first-class transactions can be current-limited. Specifically, for multiple first-class transactions, threads in a preset thread pool can be used for execution, especially for the first-class transactions of the same batch, threads in a preset thread pool are used for execution, where a preset number of threads are in the preset thread pool; and for any first-class transaction, if there is no idle thread in the preset thread pool, the first-class transaction is executed only after an idle thread exists in the preset thread pool, thereby constraining the resources for the execution of the first-class transactions, thereby avoiding the impact of excessive concurrency of first-class transactions on service stability.

[0066] Based on any of the above embodiments, if the target transaction is a second-type transaction, the execution time of the second-type transaction is detected; if the execution time of the second-type transaction exceeds the first preset time, the second-type transaction is changed to a first-type transaction, the target version of the target graph data is obtained from the disk, and the changed first-type transaction is re-executed according to the target version of the target graph data obtained from the disk.

[0067] In this embodiment, the second type of transaction is a transaction with a short execution cycle, but in some cases the execution time of the second type of transaction may be too long, exceeding the first preset time. The second type of transaction can be re-executed as the first type of transaction, that is, the target version of the target graph data is obtained from the disk, and then the changed first type of transaction is re-executed to avoid the version originally used by the second type of transaction being cleared by garbage collection and affecting the execution of the second type of transaction.

[0068] Based on any of the above embodiments, obtaining the target version of the target graph data includes:

[0069] Based on the pointers in each version of the target graph data, the versions of the target graph data are searched out from the first memory space, the second memory space and the disk in turn, and a version chain of the target graph data is constructed; the target version of the target graph data is obtained according to the version chain of the target graph data.

[0070] In this embodiment, since the various versions of the target graph data are scattered in the first memory space, the second memory space and the disk, and each version only includes a pointer to the previous version, the various versions of the target graph data can be found from the first memory space, the second memory space and the disk in turn according to the pointer, and a version chain of the target graph data can be constructed in order, wherein the various versions in the version chain of the target graph data can be arranged from new to old, and then the required target version can be obtained through the version chain. Through the periodic persistence and garbage collection process in the above embodiment, the number of versions can be reduced, that is, the number of versions in the version chain of the target graph data is reduced, and then the scanning efficiency can be improved during scanning, the time consumption and resource consumption of the scanning process can be reduced, and the query performance can be improved.

[0071] In practice, when obtaining the target version of the target graph data, if the target version does not exist in the first or second memory spaces, the version on disk can be loaded by building a version chain for the target graph data. Furthermore, when building the version chain, it is not necessary to build the entire chain; only the target version needs to be built.

[0072] It should be noted that when the latest version of the target graph data in the first memory space is persisted to the disk of the graph database at every first preset time interval, it is also necessary to associate the version of the target graph data on the disk through pointers, and to associate the version of the target graph data on the disk with the versions of the target data in the first memory space and the second memory space through pointers, in order to realize the construction of the version chain.

[0073] Through the above embodiments, the number of versions that need to be persisted can be significantly reduced, the disk I / O operations in the persistence process can be reduced, and the system efficiency can be improved. In addition, for the batch execution of the first type of transactions, since the first type of transactions in the same batch only need to obtain the target version of the target graph data once, the number of versions that need to be maintained is significantly reduced, and lightweight transaction processing is also achieved. Quickly recovering unnecessary old versions reduces resource consumption and can effectively improve the overall performance of the system. For the second type of transactions, it can respond immediately, optimize retrieval efficiency, improve system throughput, and effectively alleviate the negative impact of snapshot isolation on system throughput.

[0074] Corresponding to the transaction processing method of the graph database in the above embodiment, Figure 4 A structural block diagram of a transaction processing device for a graph database provided by an embodiment of the present disclosure. For ease of explanation, only the parts related to the embodiment of the present disclosure are shown. Figure 4 The transaction processing device 400 of the graph database includes: an update unit 401 and a graph data management unit 402.

[0075] The updating unit 401 is configured to, in response to an update instruction for target graph data in a graph database, create a new version of the target graph data in a first memory space used by the graph database, and add a pointer to a previous version of the target graph data to the new version of the target graph data, wherein the pointer is used to associate the new version of the target graph data with the previous version.

[0076] The graph data management unit 402 is used to persist the latest version of the target graph data in the first memory space to the disk of the graph database at intervals of a first preset time, and to migrate the old version of the target graph data in the first memory space to the second memory space used by the graph database.

[0077] The transaction processing device of the graph database provided by the embodiment of the present disclosure, in response to an update instruction for the target graph data in the graph database, creates a new version of the target graph data in the first memory space used by the graph database, and adds a pointer to the previous version of the target graph data in the new version of the target graph data, the pointer being used to associate the new version of the target graph data with the previous version; persists the latest version of the target graph data in the first memory space to the disk of the graph database at intervals of a first preset time, and migrates the old version of the target graph data in the first memory space to the second memory space used by the graph database. In this embodiment, by periodically persisting the latest version of the target graph data in the first memory space to the disk of the graph database, the number of persistence times to the disk can be reduced, and by migrating the old version of the target graph data in the first memory space to the second memory space used by the graph database for subsequent use or reconstruction of the version chain, the occupation of the first memory space can be reduced to ensure the stability of the service, and it is convenient to uniformly garbage collect the old versions, reduce the number of versions, reduce resource consumption, and improve system performance.

[0078] In one or more embodiments of the present disclosure, the graph data management unit 402 is further configured to:

[0079] Filter the old versions to be recycled from the old versions of the target graph data in the second memory space, and perform garbage collection on the old versions to be recycled, wherein the old versions to be recycled are old versions whose creation time is more than a second preset time from the current time, and the second preset time is greater than or equal to the first preset time.

[0080] In one or more embodiments of the present disclosure, the graph data management unit 402 is further configured to:

[0081] In response to a processing request for a target transaction directed to the target graph data, obtaining a target version of the target graph data, and executing the target transaction according to the target version of the target graph data;

[0082] Among them, if the target transaction is a first-type transaction, the target version of the target graph data is any version of the target graph data in the disk; if the target transaction is a second-type transaction, the target version of the target graph data is any version of the target graph data in the first memory space or the second memory space; wherein the execution cycle of the first-type transaction is greater than the execution cycle of the second-type transaction.

[0083] In one or more embodiments of the present disclosure, when acquiring the target version of the target graph data, the graph data management unit 402 is configured to:

[0084] Determining a creation time of the target transaction;

[0085] If the target transaction is a first-category transaction, obtaining the latest version of the target graph data before the creation time from the disk as the target version of the target graph data; or

[0086] If the target transaction is a second-category transaction, the latest version of the target graph data before the creation time is obtained from the first memory space or the second memory space as the target version of the target graph data.

[0087] In one or more embodiments of the present disclosure, when the graph data management unit 402 obtains the target version of the target graph data and executes the target transaction according to the target version of the target graph data, it is configured to:

[0088] If there are multiple target transactions that are first-category transactions, the multiple first-category transactions are divided into batches according to their creation time and the first preset time, wherein the creation time of the first-category transactions in the same batch falls within the same time window of the first preset time;

[0089] For any batch of first-type transactions, the latest version of the target graph data on the disk within the time window corresponding to the first-type transactions of the batch is obtained, and the target transactions of the batch are executed according to the latest version.

[0090] In one or more embodiments of the present disclosure, the graph data management unit 402 is further configured to:

[0091] For a plurality of first-category transactions, threads in a preset thread pool are used for execution, wherein the preset thread pool has a preset number of threads;

[0092] For any of the first-category transactions, if there is no idle thread in the preset thread pool, the process waits until there is an idle thread in the preset thread pool before executing any of the first-category transactions.

[0093] In one or more embodiments of the present disclosure, when acquiring the target version of the target graph data, the graph data management unit 402 is configured to:

[0094] Based on the pointers in the versions of the target graph data, searching for the versions of the target graph data from the first memory space, the second memory space, and the disk in sequence, and building a version chain of the target graph data;

[0095] A target version of the target graph data is obtained according to a version chain of the target graph data.

[0096] In one or more embodiments of the present disclosure, when executing the target transaction according to the target version of the target graph data, the graph data management unit 402 is further configured to:

[0097] If the target transaction is a second-type transaction, detecting the execution time of the second-type transaction;

[0098] If the execution time of the second type of transaction exceeds the first preset time, the second type of transaction is changed to the first type of transaction, the target version of the target graph data is obtained from the disk, and the changed first type of transaction is re-executed according to the target version of the target graph data.

[0099] In one or more embodiments of the present disclosure, when migrating the old version of the target graph data in the first memory space to the second memory space used by the graph database, the graph data management unit 402 is configured to:

[0100] When the remaining space of the first memory space is less than a preset threshold or at intervals of a first preset time, the old version of the target graph data in the first memory space is migrated to the second memory space.

[0101] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effects are similar and will not be described in detail in this embodiment.

[0102] In order to implement the above embodiment, the embodiment of the present disclosure further provides an electronic device.

[0103] refer to Figure 5 , which shows a schematic structural diagram of an electronic device 500 suitable for implementing the embodiments of the present disclosure. The electronic device 500 may be a terminal device or a server. The terminal device may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers, portable media players (PMPs), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.

[0104] like Figure 5As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. Various programs and data required for the operation of the electronic device 500 are also stored in the RAM 503. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0105] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 5 The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.

[0106] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program includes program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network via the communication device 509, or installed from the storage device 508, or installed from the ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.

[0107] It should be noted that the computer-readable storage medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable storage medium other than a computer-readable storage medium that can transmit, propagate, or convey a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable storage medium may be conveyed using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.

[0108] The computer-readable storage medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0109] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the method shown in the above embodiment.

[0110] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0111] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0112] The units involved in the embodiments described in this disclosure may be implemented in software or hardware. In some cases, the name of a unit does not limit the unit itself. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses."

[0113] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.

[0114] The electronic device, computer-readable storage medium, and computer program product provided by the embodiments of the present disclosure, in response to an update instruction for target graph data in a graph database, create a new version of the target graph data in the first memory space used by the graph database, and add a pointer to the previous version of the target graph data in the new version of the target graph data, the pointer being used to associate the new version of the target graph data with the previous version; persist the latest version of the target graph data in the first memory space to the disk of the graph database at intervals of a first preset time, and migrate the old version of the target graph data in the first memory space to the second memory space used by the graph database. In this embodiment, by periodically persisting the latest version of the target graph data in the first memory space to the disk of the graph database, the number of persistence times to the disk can be reduced, and by migrating the old version of the target graph data in the first memory space to the second memory space used by the graph database for subsequent use or reconstruction of the version chain, the occupancy of the first memory space can be reduced to ensure the stability of the service, and it is convenient to uniformly garbage collect old versions, reduce the number of versions, reduce resource consumption, and improve system performance.

[0115] In a first aspect, according to one or more embodiments of the present disclosure, a transaction processing method for a graph database is provided, comprising:

[0116] In response to an update instruction for target graph data in a graph database, creating a new version of the target graph data in a first memory space used by the graph database, and adding a pointer to a previous version of the target graph data to the new version of the target graph data, wherein the pointer is used to associate the new version of the target graph data with the previous version;

[0117] Persisting the latest version of the target graph data in the first memory space to the disk of the graph database at intervals of a first preset time;

[0118] Migrate the old version of the target graph data in the first memory space to the second memory space used by the graph database.

[0119] According to one or more embodiments of the present disclosure, the method further includes:

[0120] Filter the old versions to be recycled from the old versions of the target graph data in the second memory space, and perform garbage collection on the old versions to be recycled, wherein the old versions to be recycled are old versions whose creation time is more than a second preset time from the current time, and the second preset time is greater than or equal to the first preset time.

[0121] According to one or more embodiments of the present disclosure, the method further includes:

[0122] In response to a processing request for a target transaction directed to the target graph data, obtaining a target version of the target graph data, and executing the target transaction according to the target version of the target graph data;

[0123] Among them, if the target transaction is a first-type transaction, the target version of the target graph data is any version of the target graph data in the disk; if the target transaction is a second-type transaction, the target version of the target graph data is any version of the target graph data in the first memory space or the second memory space; wherein the execution cycle of the first-type transaction is greater than the execution cycle of the second-type transaction.

[0124] According to one or more embodiments of the present disclosure, obtaining the target version of the target graph data includes:

[0125] Determining a creation time of the target transaction;

[0126] If the target transaction is a first-category transaction, obtaining the latest version of the target graph data before the creation time from the disk as the target version of the target graph data; or

[0127] If the target transaction is a second-category transaction, the latest version of the target graph data before the creation time is obtained from the first memory space or the second memory space as the target version of the target graph data.

[0128] According to one or more embodiments of the present disclosure, obtaining the target version of the target graph data and executing the target transaction according to the target version of the target graph data includes:

[0129] If there are multiple target transactions that are first-category transactions, the multiple first-category transactions are divided into batches according to their creation time and the first preset time, wherein the creation time of the first-category transactions in the same batch falls within the same time window of the first preset time;

[0130] For any batch of first-type transactions, the latest version of the target graph data on the disk within the time window corresponding to the first-type transactions of the batch is obtained, and the target transactions of the batch are executed according to the latest version.

[0131] According to one or more embodiments of the present disclosure, the method further includes:

[0132] For a plurality of first-category transactions, threads in a preset thread pool are used for execution, wherein the preset thread pool has a preset number of threads;

[0133] For any of the first-category transactions, if there is no idle thread in the preset thread pool, the process waits until there is an idle thread in the preset thread pool before executing any of the first-category transactions.

[0134] According to one or more embodiments of the present disclosure, obtaining the latest version of the target graph data on the disk includes:

[0135] Based on the pointers in the versions of the target graph data, searching for the versions of the target graph data from the first memory space, the second memory space, and the disk in sequence, and building a version chain of the target graph data;

[0136] Determine the latest version of the target graph data in the disk from the version chain of the target graph data, and obtain the latest version of the target graph data in the disk.

[0137] According to one or more embodiments of the present disclosure, after executing the target transaction according to the latest version of the target graph data in the memory, the method further includes:

[0138] detecting an execution time of the target transaction;

[0139] If the execution time of the target transaction exceeds the first preset time, the target transaction is changed to the first type of transaction, the latest version of the target graph data on the disk is obtained, and the target transaction is re-executed according to the latest version of the target graph data on the disk.

[0140] According to one or more embodiments of the present disclosure, migrating the old version of the target graph data in the first memory space to the second memory space used by the graph database includes:

[0141] When the remaining space of the first memory space is less than a preset threshold or at intervals of a first preset time, the old version of the target graph data in the first memory space is migrated to the second memory space.

[0142] In a second aspect, according to one or more embodiments of the present disclosure, a transaction processing device for a graph database is provided, comprising:

[0143] an updating unit, configured to, in response to an update instruction for target graph data in a graph database, create a new version of the target graph data in a first memory space used by the graph database, and add a pointer to a previous version of the target graph data in the new version of the target graph data, wherein the pointer is used to associate the new version of the target graph data with the previous version;

[0144] A graph data management unit is configured to persist the latest version of the target graph data in the first memory space to the disk of the graph database at intervals of a first preset time; and to migrate the old version of the target graph data in the first memory space to the second memory space used by the graph database.

[0145] According to one or more embodiments of the present disclosure, the graph data management unit is further configured to:

[0146] Filter the old versions to be recycled from the old versions of the target graph data in the second memory space, and perform garbage collection on the old versions to be recycled, wherein the old versions to be recycled are old versions whose creation time is more than a second preset time from the current time, and the second preset time is greater than or equal to the first preset time.

[0147] According to one or more embodiments of the present disclosure, the graph data management unit is further configured to:

[0148] In response to a processing request for a target transaction directed to the target graph data, obtaining a target version of the target graph data, and executing the target transaction according to the target version of the target graph data;

[0149] Among them, if the target transaction is a first-type transaction, the target version of the target graph data is any version of the target graph data in the disk; if the target transaction is a second-type transaction, the target version of the target graph data is any version of the target graph data in the first memory space or the second memory space; wherein the execution cycle of the first-type transaction is greater than the execution cycle of the second-type transaction.

[0150] According to one or more embodiments of the present disclosure, when acquiring the target version of the target graph data, the graph data management unit is configured to:

[0151] Determining a creation time of the target transaction;

[0152] If the target transaction is a first-category transaction, obtaining the latest version of the target graph data before the creation time from the disk as the target version of the target graph data; or

[0153] If the target transaction is a second-category transaction, the latest version of the target graph data before the creation time is obtained from the first memory space or the second memory space as the target version of the target graph data.

[0154] According to one or more embodiments of the present disclosure, when the graph data management unit obtains the target version of the target graph data and executes the target transaction according to the target version of the target graph data, it is configured to:

[0155] If there are multiple target transactions that are first-category transactions, the multiple first-category transactions are divided into batches according to their creation time and the first preset time, wherein the creation time of the first-category transactions in the same batch falls within the same time window of the first preset time;

[0156] For any batch of first-type transactions, the latest version of the target graph data on the disk within the time window corresponding to the first-type transactions of the batch is obtained, and the target transactions of the batch are executed according to the latest version.

[0157] According to one or more embodiments of the present disclosure, the graph data management unit is further configured to:

[0158] For a plurality of first-category transactions, threads in a preset thread pool are used for execution, wherein the preset thread pool has a preset number of threads;

[0159] For any of the first-category transactions, if there is no idle thread in the preset thread pool, the process waits until there is an idle thread in the preset thread pool before executing any of the first-category transactions.

[0160] According to one or more embodiments of the present disclosure, when acquiring the target version of the target graph data, the graph data management unit is configured to:

[0161] Based on the pointers in the versions of the target graph data, searching for the versions of the target graph data from the first memory space, the second memory space, and the disk in sequence, and building a version chain of the target graph data;

[0162] A target version of the target graph data is obtained according to a version chain of the target graph data.

[0163] According to one or more embodiments of the present disclosure, when executing the target transaction according to the target version of the target graph data, the graph data management unit is further configured to:

[0164] If the target transaction is a second-type transaction, detecting the execution time of the second-type transaction;

[0165] If the execution time of the second type of transaction exceeds the first preset time, the second type of transaction is changed to the first type of transaction, the target version of the target graph data is obtained from the disk, and the changed first type of transaction is re-executed according to the target version of the target graph data.

[0166] According to one or more embodiments of the present disclosure, when migrating the old version of the target graph data in the first memory space to the second memory space used by the graph database, the graph data management unit is configured to:

[0167] When the remaining space of the first memory space is less than a preset threshold or at intervals of a first preset time, the old version of the target graph data in the first memory space is migrated to the second memory space.

[0168] In a third aspect, according to one or more embodiments of the present disclosure, there is provided an electronic device, comprising: at least one processor and a memory;

[0169] The memory stores computer-executable instructions;

[0170] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the transaction processing method of the graph database as described in the first aspect and various possible designs of the first aspect.

[0171] In a fourth aspect, according to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the transaction processing method of the graph database described in the first aspect and various possible designs of the first aspect is implemented.

[0172] In a fifth aspect, according to one or more embodiments of the present disclosure, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the transaction processing method of the graph database as described in the first aspect and various possible designs of the first aspect.

[0173] In summary, in response to an update instruction for the target graph data in the graph database, a new version of the target graph data is created in the first memory space used by the graph database, and a pointer to the previous version of the target graph data is added to the new version of the target graph data, the pointer being used to associate the new version of the target graph data with the previous version; the latest version of the target graph data in the first memory space is persisted to the disk of the graph database at every first preset time interval, and the old version of the target graph data in the first memory space is migrated to the second memory space used by the graph database. In this embodiment, by periodically persisting the latest version of the target graph data in the first memory space to the disk of the graph database, the number of persistence to disk can be reduced, and by migrating the old version of the target graph data in the first memory space to the second memory space used by the graph database for subsequent use or reconstruction of the version chain, the occupancy of the first memory space can be reduced to ensure the stability of the service, and it is convenient to uniformly garbage collect old versions, reduce the number of versions, reduce resource consumption, and improve system performance.

[0174] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also includes other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.

[0175] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details have been included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0176] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.

Claims

1. A transaction processing method for a graph database, characterized in that: include: In response to an update instruction for target graph data in a graph database, creating a new version of the target graph data in a first memory space used by the graph database, and adding a pointer to a previous version of the target graph data to the new version of the target graph data, wherein the pointer is used to associate the new version of the target graph data with the previous version; Persisting the latest version of the target graph data in the first memory space to the disk of the graph database at intervals of a first preset time; Migrate the old version of the target graph data in the first memory space to the second memory space used by the graph database.

2. The method according to claim 1, characterized in that The method further comprises: Filter the old versions to be recycled from the old versions of the target graph data in the second memory space, and perform garbage collection on the old versions to be recycled, wherein the old versions to be recycled are old versions whose creation time is more than a second preset time from the current time, and the second preset time is greater than or equal to the first preset time.

3. The method according to claim 1, characterized in that The method further comprises: In response to a processing request for a target transaction directed to the target graph data, obtaining a target version of the target graph data, and executing the target transaction according to the target version of the target graph data; Among them, if the target transaction is a first-type transaction, the target version of the target graph data is any version of the target graph data in the disk; if the target transaction is a second-type transaction, the target version of the target graph data is any version of the target graph data in the first memory space or the second memory space; wherein the execution cycle of the first-type transaction is greater than the execution cycle of the second-type transaction.

4. The method according to claim 3, characterized in that The obtaining of the target version of the target graph data includes: Determining a creation time of the target transaction; If the target transaction is a first-category transaction, obtaining the latest version of the target graph data before the creation time from the disk as the target version of the target graph data; or If the target transaction is a second-category transaction, the latest version of the target graph data before the creation time is obtained from the first memory space or the second memory space as the target version of the target graph data.

5. The method according to claim 3, characterized in that The acquiring the target version of the target graph data and executing the target transaction according to the target version of the target graph data includes: If there are multiple target transactions that are first-category transactions, the multiple first-category transactions are divided into batches according to their creation time and the first preset time, wherein the creation time of the first-category transactions in the same batch falls within the same time window of the first preset time; For any batch of first-type transactions, the latest version of the target graph data on the disk within the time window corresponding to the first-type transactions of the batch is obtained, and the target transactions of the batch are executed according to the latest version.

6. The method according to claim 3, characterized in that The method further comprises: For a plurality of first-category transactions, threads in a preset thread pool are used for execution, wherein the preset thread pool has a preset number of threads; For any of the first-category transactions, if there is no idle thread in the preset thread pool, the process waits until there is an idle thread in the preset thread pool before executing any of the first-category transactions.

7. The method according to claim 3, characterized in that The obtaining of the target version of the target graph data includes: Based on the pointers in the versions of the target graph data, searching for the versions of the target graph data from the first memory space, the second memory space, and the disk in sequence, and building a version chain of the target graph data; A target version of the target graph data is obtained according to the version chain of the target graph data.

8. The method according to claim 3, characterized in that The executing the target transaction according to the target version of the target graph data further includes: If the target transaction is a second-type transaction, detecting the execution time of the second-type transaction; If the execution time of the second type of transaction exceeds the first preset time, the second type of transaction is changed to the first type of transaction, the target version of the target graph data is obtained from the disk, and the changed first type of transaction is re-executed according to the target version of the target graph data.

9. The method according to claim 1, characterized in that Migrating the old version of the target graph data in the first memory space to the second memory space used by the graph database includes: When the remaining space of the first memory space is less than a preset threshold or at intervals of a first preset time, the old version of the target graph data in the first memory space is migrated to the second memory space.

10. A transaction processing device for a graph database, characterized in that: include: an updating unit, configured to, in response to an update instruction for target graph data in a graph database, create a new version of the target graph data in a first memory space used by the graph database, and add a pointer to a previous version of the target graph data in the new version of the target graph data, wherein the pointer is used to associate the new version of the target graph data with the previous version; A graph data management unit, configured to persist the latest version of the target graph data in the first memory space to the disk of the graph database at intervals of a first preset time; Migrate the old version of the target graph data in the first memory space to the second memory space used by the graph database.

11. An electronic device, characterized in that: include: processor and memory; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, and when a processor executes the computer-executable instructions, the method according to any one of claims 1 to 9 is implemented.

13. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.