CN117390027A - Memory read-write method and device - Google Patents

Memory read-write method and device Download PDF

Info

Publication number
CN117390027A
CN117390027A CN202311459996.8A CN202311459996A CN117390027A CN 117390027 A CN117390027 A CN 117390027A CN 202311459996 A CN202311459996 A CN 202311459996A CN 117390027 A CN117390027 A CN 117390027A
Authority
CN
China
Prior art keywords
root
tree
transaction
read
root metadata
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311459996.8A
Other languages
Chinese (zh)
Inventor
白建民
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202311459996.8A priority Critical patent/CN117390027A/en
Publication of CN117390027A publication Critical patent/CN117390027A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2246Trees, e.g. B+trees
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2474Sequence data queries, e.g. querying versioned data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Abstract

The disclosure provides a memory read-write method and a memory read-write device, relates to the technical field of computers, and particularly relates to the field of data processing. The specific implementation scheme is as follows: acquiring root metadata corresponding to a read transaction/write transaction to be executed, wherein the root metadata comprises a root node pointer, a tree version number and a list to be recovered; determining a corresponding first balance search tree in the memory area according to the root node pointer; in response to the transaction to be executed being a read transaction, copying the root metadata, and reading data of the first balanced search tree based on the first copied root metadata obtained by copying; and in response to the transaction to be executed being a write transaction, copying the root metadata, and performing write operation on the first balanced search tree based on the second copied root metadata obtained by copying. The method and the device can realize read-read concurrency and read-write concurrency, and when a write transaction is executed, the copied root metadata ensures that the read transaction can still perform read operation based on the original root metadata, and improves the isolation and reliability of data.

Description

Memory read-write method and device
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and an apparatus for reading and writing a memory.
Background
With the widespread use of multithreaded and multi-core processors in computer systems, concurrent read and write operations on memory are becoming increasingly important. In the current distributed system, related data is often temporarily stored in a memory, and a plurality of data can be read and written in a task process, however, concurrent read-write operation may cause data competition and consistency problems.
Disclosure of Invention
The disclosure provides a memory read-write method, a memory read-write device, a memory read-write equipment and a memory storage medium.
According to an aspect of the present disclosure, a memory read-write method is provided, by acquiring root metadata corresponding to a read transaction/write transaction to be executed, where the root metadata includes a root node pointer, a tree version number, and a list to be recovered; determining a corresponding first balance search tree in the memory area according to the root node pointer; copying the root metadata in response to the transaction to be executed as a read transaction, and reading data of the first balanced search tree based on the first copied root metadata obtained by copying; and in response to the transaction to be executed being a write transaction, copying the root metadata, and performing write operation on the first balanced search tree based on the second copied root metadata obtained by copying.
According to another aspect of the present disclosure, there is provided a memory read-write device, including an obtaining module, configured to obtain root metadata corresponding to a read transaction/write transaction to be executed, where the root metadata includes a root node pointer, a tree version number, and a list to be reclaimed; the determining module is used for determining a corresponding first balance search tree in the memory area according to the root node pointer; the first execution module is used for responding to the transaction to be executed as a read transaction, copying the root metadata, and reading the data of the first balance search tree based on the first copied root metadata obtained by copying; and the second execution module is used for responding to the transaction to be executed as a write transaction, copying the root metadata, and performing write operation on the first balanced search tree based on the copied second copied root metadata.
According to another aspect of the present disclosure, there is provided an electronic device including: at least one processor; and a memory communicatively coupled to the at least one processor; the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor, so that the at least one processor can execute the memory read-write method.
According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform the memory read-write method described above.
According to another aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the memory read-write method described above.
The application at least realizes the following beneficial effects:
in the method, the read-read concurrency and the read-write concurrency can be realized by copying the root metadata and performing the read-write operation based on copying, a plurality of read transactions can be performed simultaneously, each transaction uses own copy root metadata, the conflict and mutual interference between the read transactions are avoided, the concurrency performance of the system is improved, and the read-write isolation can be realized by copying the root metadata and performing the read-write operation based on copying. When executing the writing transaction, the copied root metadata ensures that the reading transaction can still perform reading operation based on the original root metadata without being influenced by the writing transaction, can ensure that the data read by the reading transaction during execution are consistent all the time, improves the isolation and reliability of the data, and in addition, even if faults or errors occur during executing the transaction, the original root metadata still remains unchanged, can be restored to the state before executing the transaction through rollback or other mechanisms, and can improve the fault tolerance of the system.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The drawings are for a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
fig. 1 is a schematic diagram of an exemplary embodiment of a memory read-write method shown in the present application.
Fig. 2 is a schematic diagram of an exemplary embodiment of a memory read-write method shown in the present application.
Fig. 3 is a general flow chart of an exemplary embodiment of a memory read/write method shown in the present application.
Fig. 4 is an overall architecture diagram of an exemplary embodiment of a memory read/write method shown in the present application.
Fig. 5 is a schematic diagram of a memory read-write device shown in the present application.
Fig. 6 is a schematic diagram of an electronic device shown in the present application.
Detailed Description
Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of an exemplary embodiment of a memory read/write method shown in the present application, and as shown in fig. 1, the memory read/write method includes the following steps:
s101, obtaining root metadata corresponding to a read transaction/write transaction to be executed, wherein the root metadata comprises a root node pointer, a tree version number and a list to be recycled.
Read transactions and write transactions are two important concepts in database management systems for controlling the manner in which databases are concurrently accessed. Wherein:
read transaction (Read Transact ion): a read transaction refers to a sequence of database operations that contains only operations to read data, and no operations to modify the data.
Write transaction (Wr ite Transact ion): a write transaction refers to a sequence of database operations that contain operations that modify data, such as inserting, updating, or deleting data.
In this application, each read/write transaction has a unique identifier or ID. Root metadata associated with a read/write transaction may be retrieved from memory based on the ID of the transaction. The root metadata typically includes information such as a root node pointer (pointing to the root node of the tree), a tree version number (for tracking version changes of the tree), and a to-be-reclaimed list (recording resources or memory blocks to be reclaimed). By retrieving these root metadata, the data structure and resource status involved in the read/write transaction can be determined.
S102, determining a corresponding first balanced search tree in the memory area according to the root node pointer.
The balanced lookup tree stored in the memory is located by the root node pointer included in the root metadata, and is named herein as the first balanced lookup tree since a replacement update operation is subsequently performed on the balanced lookup tree.
Optionally, the balanced search tree in the present application may be a B-tree. The B-tree is a self-balancing search tree data structure used to organize and store large amounts of key data.
And S103, copying the root metadata in response to the transaction to be executed as a read transaction, and reading the data of the first balance search tree based on the first copied root metadata obtained by copying.
In order to ensure isolation and consistency of the read transaction, in the application, when the read transaction is executed, the root metadata is duplicated to create a duplicate, so that the read transaction is not affected by other concurrent transactions during execution, and the data reading is performed on the first balanced search tree through the duplicated first duplicated root metadata.
And S104, copying the root metadata in response to the transaction to be executed as a write transaction, and performing write operation on the first balance search tree based on the second copied root metadata obtained by copying.
Similarly to the read transaction, in order to ensure isolation and consistency of the write transaction, in the present application, root metadata is also replicated when the write transaction is executed, a copy is created, and corresponding write operation is performed on the first balanced search tree through the second replicated root metadata obtained by replication. This ensures that write transactions do not affect other concurrent transactions during execution and that other transactions cannot see the written data until the transaction commits.
Wherein the write operation includes an insert operation, a delete operation, and a modify operation on the first balanced lookup tree.
The embodiment of the application provides a memory read-write method, which is characterized in that root metadata corresponding to a read transaction/write transaction to be executed is obtained, wherein the root metadata comprises a root node pointer, a tree version number and a list to be recovered; determining a corresponding first balance search tree in the memory area according to the root node pointer; in response to the transaction to be executed being a read transaction, copying the root metadata, and reading data of the first balanced search tree based on the first copied root metadata obtained by copying; and in response to the transaction to be executed being a write transaction, copying the root metadata, and performing write operation on the first balanced search tree based on the second copied root metadata obtained by copying. According to the method and the device, read-read concurrency and read-write concurrency can be achieved through copying the root metadata and performing read-write operation based on copying, a plurality of read transactions can be performed simultaneously, each transaction uses own copy root metadata, conflicts and mutual interference among the read transactions are avoided, concurrency performance of a system is improved, read-write isolation can be achieved through copying the root metadata and performing write operation based on copying, when the write transaction is performed, the copied root metadata ensures that the read transaction can still perform read operation based on original root metadata and cannot be influenced by the write transaction, the read data of the read transaction are always consistent during the execution period, isolation and reliability of the data are improved, in addition, in the method and the device, even if faults or errors occur during the execution of the transaction, the original root metadata still remain unchanged, the state before the execution of the transaction can be restored through rollback or other mechanisms, and fault tolerance of the system can be improved.
Fig. 2 is a schematic diagram of an exemplary embodiment of a memory read/write method shown in the present application, and as shown in fig. 2, the memory read/write method includes the following steps:
s201, obtaining root metadata corresponding to a read transaction/write transaction to be executed, wherein the root metadata comprises a root node pointer, a tree version number and a list to be recycled.
Receiving a read transaction/write transaction instruction sent by a user; analyzing the read transaction/write transaction instruction to obtain a root pointer carried by the read transaction/write transaction instruction; root metadata pointed to by the root metadata pointer is determined. Wherein, the root element pointer and the root element data are in one-to-one mapping relation.
In the process of reading and writing the memory, the method introduces the concept of root metadata, can track and manage the state of the data through the root metadata, ensures the consistency of the data in the reading and writing transaction, and can record the version, locking state and other related information of the data so as to coordinate the access and modification of the data among different transactions.
S202, determining a corresponding first balanced search tree in the memory area according to the root node pointer.
And S203, copying the root metadata in response to the transaction to be executed as a read transaction, and reading the data of the first balance search tree based on the first copied root metadata obtained by copying.
For the specific implementation of steps S202 to S203, reference may be made to the specific description of the relevant parts in the above embodiments, and the detailed description is omitted here.
S204, in response to the transaction to be executed being a write transaction, copying the root metadata, acquiring a node to be modified data on the first balance search tree as an initial structure node based on the second copied root metadata obtained by copying, and placing the initial structure node into a to-be-recovered list contained in the second copied root metadata.
At the beginning of a write transaction, a copy operation is performed on the original root metadata, creating a second copy root metadata to ensure that each write transaction has its own modification space. And operating on the first balanced search tree based on the second replication root metadata, finding out the nodes needing to be modified, and taking the nodes to be modified as initial structure nodes.
After determining the initial structure nodes, adding all the initial structure nodes to a to-be-reclaimed list contained in the second replication root metadata, wherein the to-be-reclaimed list is used for recording nodes needing to be reclaimed or released at a later stage.
S205, copying each initial structure node, and modifying data on the copied structure node generated after copying.
After the initial structure nodes are determined, each initial structure node is duplicated, and data modification is carried out on the duplicated structure nodes generated after duplication.
S206, after all the replication structure nodes complete data modification and write operation submission, corresponding replacement is carried out on the initial structure nodes based on the modified structure nodes generated after modification, a second balance search tree generated after replacement is obtained, and root metadata is replaced based on second replication root metadata at the current moment.
It should be noted that, the replacement herein is to replace one initial structure node by one based on each modified structure node generated after the modification after all the replication structure nodes complete the data modification and perform the write operation commit, instead of modifying one replication structure node.
Since the version number of the tree needs to be updated after the write operation is submitted, in the present application, after all the replication structure nodes complete data modification and perform write operation submission, the root metadata needs to be replaced based on the second replication root metadata at the current time.
In the embodiment of the application, the execution process of the writing transaction is specifically introduced, read-write isolation can be realized by copying the root metadata and performing writing operation based on copying, the initial structure node is put into the list to be recycled, and the node needing to be recycled or released in the subsequent stage can be recorded, so that the memory resource is effectively managed, the structural integrity of the tree is maintained, the memory use of the system is optimized, more flexible and extensible system design can be provided by introducing the root metadata and modifying the structure node, and different transactions can independently operate respective copies, thereby reducing the competition to shared resources and improving the stability and expansibility of the system.
Further, after replacing the root metadata based on the second copy root metadata at the current time, the method further includes: acquiring a tree version number corresponding to the first balance search tree as a reference tree version number; acquiring a tree version number carried by root metadata corresponding to each read transaction currently in an execution state as a read transaction tree version number; performing execution state monitoring on each read transaction with the read transaction tree version number smaller than or equal to the reference tree version number; and after all the read transactions with the read transaction tree version numbers smaller than or equal to the reference tree version number are detected to be executed, releasing the initial structure nodes in the to-be-recycled list. It should be noted that, since the root metadata is replaced based on the second copy root metadata corresponding to the write operation, that is, the initial structure node of the data to be modified corresponding to the write object is stored in the to-be-recycled list included in the root metadata at this moment, that is, all the read transactions with version numbers smaller than or equal to the reference tree version number can read the information stored in the to-be-recycled list. In this way, by monitoring the tree version number of the read transaction and comparing with the reference tree version number, whether the read transaction is in an execution state is judged so as to avoid conflict between the read transaction and the write transaction, and the effect of concurrency control is improved; the nodes of the initial structure in the to-be-recycled list are released, so that nodes which are not needed any more can be recycled in time, the use of memory resources is optimized, and the stability and performance of the system are improved.
Further, since the balanced lookup tree may cause an unbalanced state after inserting or deleting nodes, it may affect the performance and efficiency of the tree. In the application, after the second balance search tree generated after replacement is obtained, if it is monitored that structural nodes exist on the second balance search tree and are in an unbalanced state, a rotation splitting operation is performed to adjust the tree structure of the second balance search tree so as to rebalance the tree structure, and the tree is kept in a balanced state. The balanced tree structure can provide faster search and insert/delete operation time complexity, improving tree performance.
Further, after performing the rotation splitting operation to adjust the tree structure of the second balanced search tree, the method further includes: after the tree structure of the second balance lookup tree is adjusted, whether the root node of the second balance lookup tree is changed is judged.
If the root node of the second balanced search tree is changed, the tree version number and the root node pointer carried by the root metadata are updated, so that the current state of the root metadata and the current state of the second balanced search tree are ensured to be consistent, reading or modification of reading transactions or other operations based on an expired or wrong tree structure is avoided, and the consistency and the correctness of data are improved.
If the root node of the second balance search tree is not changed, the tree version number carried by the root metadata is updated, so that the read transaction and other operations judge whether to operate based on the latest tree structure. Thus, unnecessary waiting or reading of old version data can be avoided, and the efficiency of inquiry and operation is improved.
Because the root pointer points to the root metadata, in the present application, updating the tree version number and the root node pointer carried by the root metadata, or after updating the tree version number carried by the root metadata, further includes: based on the updated root metadata, the root pointer is updated, and the corresponding relation between the root pointer and the root metadata is ensured to be maintained.
Fig. 3 is a general flow chart of an exemplary embodiment of a memory read/write method shown in the present application, and as shown in fig. 3, the memory read/write method includes the following steps:
s301, receiving a read transaction/write transaction instruction sent by a user.
S302, analyzing the read transaction/write transaction instruction to obtain a root pointer carried by the read transaction/write transaction instruction.
S303, determining root metadata pointed by the root metadata pointer, wherein the root metadata comprises a root node pointer, a tree version number and a list to be recycled.
For the specific implementation of steps S301 to S303, reference may be made to the specific description of the relevant parts in the above embodiments, and the detailed description is omitted here.
S304, determining a corresponding first balance search tree in the memory area according to the root node pointer.
And S305, copying the root metadata in response to the transaction to be executed as a read transaction, and reading the data of the first balanced search tree based on the first copied root metadata obtained by copying.
For the specific implementation of steps S304 to S305, reference may be made to the specific description of the relevant parts in the above embodiments, and the detailed description will not be repeated here.
And S306, copying the root metadata in response to the transaction to be executed as a write transaction, acquiring a node to be modified data on the first balance search tree as an initial structure node based on the second copied root metadata obtained by copying, and placing the initial structure node into a to-be-recovered list contained in the second copied root metadata.
S307, copying each initial structure node, and modifying data on the copied structure node.
And S308, after all the replication structure nodes finish data modification and write operation submission, correspondingly replacing the initial structure node based on the modified structure node generated after modification, acquiring a second balance search tree generated after replacement, and replacing the root metadata based on the second replication root metadata at the current moment.
S309, if it is detected that the structural nodes on the second balanced search tree are in an unbalanced state, performing a rotation splitting operation to adjust the tree structure of the second balanced search tree.
S310, judging whether the root node of the second balance search tree is changed after adjusting the tree structure of the second balance search tree;
and S311, if the root node of the second balanced search tree is changed, updating the tree version number and the root node pointer carried by the root metadata.
And S312, if the root node of the second balance search tree is not changed, updating the tree version number carried by the root metadata.
And S313, updating the root pointer based on the updated root metadata.
For the specific implementation of steps S306 to S313, reference may be made to the specific description of the relevant parts in the above embodiments, and the detailed description is omitted here.
According to the method and the device, read-read concurrency and read-write concurrency can be achieved through copying the root metadata and performing read-write operation based on copying, a plurality of read transactions can be performed simultaneously, each transaction uses own copy root metadata, conflicts and mutual interference among the read transactions are avoided, concurrency performance of a system is improved, read-write isolation can be achieved through copying the root metadata and performing write operation based on copying, when the write transaction is performed, the copied root metadata ensures that the read transaction can still perform read operation based on original root metadata and cannot be influenced by the write transaction, the read data of the read transaction are always consistent during the execution period, isolation and reliability of the data are improved, in addition, in the method and the device, even if faults or errors occur during the execution of the transaction, the original root metadata still remain unchanged, the state before the execution of the transaction can be restored through rollback or other mechanisms, and fault tolerance of the system can be improved.
Fig. 4 is an overall architecture diagram of an exemplary embodiment of a memory read/write method shown in the present application, and as shown in fig. 4, the memory read/write method includes the following steps:
and receiving a read transaction/write transaction instruction sent by the user.
And analyzing the read transaction/write transaction instruction to obtain a root pointer carried by the read transaction/write transaction instruction.
And determining root metadata pointed by the root metadata pointer, wherein the root metadata comprises a root node pointer, a tree version number and a list to be recycled.
And determining a corresponding first balanced search tree in the memory area according to the root node pointer.
And in response to the transaction to be executed being a read transaction, copying the root metadata, and reading the data of the first balanced search tree based on the first copied root metadata obtained by copying.
And responding to the transaction to be executed as a write transaction, copying the root metadata, acquiring a node to be modified data on the first balanced search tree as an initial structure node based on the second copied root metadata obtained by copying, and placing the initial structure node into a to-be-recovered list contained in the second copied root metadata. In fig. 4, the modification of the node 1, the node 3 and the node 9 is taken as an example, that is, the node 1, the node 3 and the node 9 are determined as initial structure nodes, and the node 1, the node 3 and the node 9 are put into a to-be-recycled list contained in the second replication root metadata.
And copying each initial structure node, and modifying data on the copied structure node generated after copying. That is, the nodes 1, 3, and 9 are duplicated, and the duplicated versions of each of the nodes 1, 3, and 9 are denoted as nodes 10, 11, and 12 in fig. 4.
After all the replication structure nodes complete data modification and write operation submission, corresponding replacement is carried out on the initial structure nodes based on the modification structure nodes generated after modification, a second equilibrium search tree generated after replacement is obtained, and root metadata is replaced based on second replication root metadata at the current moment. That is, after data modification is completed on each of the nodes 10, 11 and 12 and writing operation is submitted, corresponding replacement is performed on the nodes 1, 3 and 9 based on the modified nodes 10, 11 and 12 at the same time, and a second balance search tree generated after replacement is obtained.
Since the root pointer is a pointer pointing to root metadata, in this application, after the root metadata is replaced, the root pointer needs to be updated.
Fig. 5 is a schematic diagram of a memory read/write device shown in the present application, and as shown in fig. 5, the memory read/write device 500 includes an obtaining module 501, a determining module 502, a first executing module 503, and a first executing module 503, where:
the obtaining module 501 is configured to obtain root metadata corresponding to a read transaction/write transaction to be executed, where the root metadata includes a root node pointer, a tree version number, and a list to be reclaimed.
The determining module 502 is configured to determine a corresponding first balanced search tree in the memory area according to the root node pointer.
The first execution module 503 is configured to replicate the root metadata in response to the transaction to be executed being a read transaction, and perform data reading on the first balanced search tree based on the replicated first replicated root metadata.
And the second execution module 504 is configured to copy the root metadata in response to the transaction to be executed being a write transaction, and perform a write operation on the first balanced search tree based on the copied second copy root metadata.
Further, the second execution module 504 is further configured to: based on the second replication root metadata obtained by replication, acquiring nodes to be modified data on the first balance search tree as initial structure nodes, and placing the initial structure nodes into a to-be-recovered list contained in the second replication root metadata; copying each initial structure node, and modifying data on the copied structure node; after all the replication structure nodes complete data modification and write operation submission, corresponding replacement is carried out on the initial structure nodes based on the modification structure nodes generated after modification, a second equilibrium search tree generated after replacement is obtained, and root metadata is replaced based on second replication root metadata at the current moment.
Further, the second execution module 504 is further configured to: if it is detected that there are structural nodes on the second balanced search tree that are in an unbalanced state, performing a rotation splitting operation to adjust the tree structure of the second balanced search tree.
Further, the second execution module 504 is further configured to: acquiring a tree version number corresponding to the first balance search tree as a reference tree version number; acquiring a tree version number carried by root metadata corresponding to each read transaction currently in an execution state as a read transaction tree version number; performing execution state monitoring on each read transaction with the read transaction tree version number smaller than or equal to the reference tree version number; and after all the read transactions with the read transaction tree version numbers smaller than or equal to the reference tree version number are detected to be executed, releasing the initial structure nodes in the to-be-recycled list.
Further, the obtaining module 501 is further configured to: receiving a read transaction/write transaction instruction sent by a user; analyzing the read transaction/write transaction instruction to obtain a root pointer carried by the read transaction/write transaction instruction; root metadata pointed to by the root metadata pointer is determined.
Further, the second execution module 504 is further configured to: judging whether the root node of the second balance search tree is changed after adjusting the tree structure of the second balance search tree; and if the root node of the second balanced search tree is changed, updating the tree version number and the root node pointer carried by the root metadata.
Further, the second execution module 504 is further configured to: and if the root node of the second balance search tree is not changed, updating the tree version number carried by the root metadata.
Further, the second execution module 504 is further configured to: and updating the root pointer based on the updated root metadata.
Further, the write operations in the second execution module 504 include insert operations, delete operations, and modify operations on the first balanced lookup tree.
According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
Fig. 6 illustrates a schematic block diagram of an example electronic device 600 that may be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 6, the apparatus 600 includes a computing unit 601 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 602 or a computer program loaded from a storage unit 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the device 600 may also be stored. The computing unit 601, ROM 602, and RAM 603 are connected to each other by a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Various components in the device 600 are connected to the I/O interface 605, including: an input unit 606 such as a keyboard, mouse, etc.; an output unit 607 such as various types of displays, speakers, and the like; a storage unit 608, such as a magnetic disk, optical disk, or the like; and a communication unit 609 such as a network card, modem, wireless communication transceiver, etc. The communication unit 609 allows the device 600 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The computing unit 601 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 601 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 601 performs the various methods and processes described above, such as memory read-write methods. For example, in some embodiments, the memory read-write method may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as the storage unit 608. In some embodiments, part or all of the computer program may be loaded and/or installed onto the device 600 via the ROM 602 and/or the communication unit 609. When the computer program is loaded into RAM 603 and executed by computing unit 601, one or more steps of the memory read-write method described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform the memory read-write method in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the internet.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel or sequentially or in a different order, provided that the desired results of the technical solutions of the present disclosure are achieved, and are not limited herein.
The above detailed description should not be taken as limiting the scope of the present disclosure. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present disclosure are intended to be included within the scope of the present disclosure.

Claims (21)

1. A memory read-write method includes:
acquiring root metadata corresponding to a read transaction/write transaction to be executed, wherein the root metadata comprises a root node pointer, a tree version number and a list to be recovered;
determining a corresponding first balance search tree in the memory area according to the root node pointer;
copying the root metadata in response to the transaction to be executed as a read transaction, and reading data of the first balanced search tree based on the first copied root metadata obtained by copying;
And in response to the transaction to be executed being a write transaction, copying the root metadata, and performing write operation on the first balanced search tree based on the second copied root metadata obtained by copying.
2. The method of claim 1, wherein the writing the first balanced lookup tree based on the replicated second replication root metadata comprises:
based on second replication root metadata obtained by replication, acquiring a node to be subjected to data modification on the first balance search tree as an initial structure node, and placing the initial structure node into the to-be-recovered list contained in the second replication root metadata;
copying each initial structure node, and modifying data on the copied structure node;
after all the replication structure nodes complete data modification and write operation submission, correspondingly replacing the initial structure node based on the modified structure node generated after modification, acquiring a second balance search tree generated after replacement, and,
and replacing the root metadata based on the second copy root metadata at the current moment.
3. The method of claim 2, wherein after the obtaining the second balance lookup tree generated after the replacing, further comprising:
If it is detected that the structural nodes on the second balanced search tree are in an unbalanced state, performing a rotation splitting operation to adjust the tree structure of the second balanced search tree.
4. The method of claim 2, wherein the replacing the root metadata based on the second duplicate root metadata at the current time further comprises:
acquiring a tree version number corresponding to the first balanced search tree as a reference tree version number;
acquiring a tree version number carried by root metadata corresponding to each read transaction currently in an execution state as a read transaction tree version number;
performing execution state monitoring on each read transaction with the read transaction tree version number smaller than or equal to the reference tree version number;
and after the fact that all the read transactions with the read transaction tree version numbers smaller than or equal to the reference tree version number are executed is detected, releasing the initial structure node in the list to be recycled.
5. The method according to any one of claims 1-4, wherein the obtaining root metadata corresponding to a read transaction/write transaction to be performed includes:
receiving a read transaction/write transaction instruction sent by a user;
Analyzing the read transaction/write transaction instruction to obtain a root pointer carried by the read transaction/write transaction instruction;
and determining the root metadata pointed by the root metadata pointer.
6. The method of claim 3, wherein after the performing a rotation splitting operation to adjust the tree structure of the second balanced lookup tree, further comprising:
judging whether the root node of the second balance search tree is changed after adjusting the tree structure of the second balance search tree;
and if the root node of the second balanced search tree is changed, updating the tree version number and the root node pointer carried by the root metadata.
7. The method of claim 6, wherein the method further comprises:
and if the root node of the second balanced search tree is not changed, updating the tree version number carried by the root metadata.
8. The method according to claim 6 or 7, wherein updating the tree version number and the root node pointer carried by the root metadata, or after updating the tree version number carried by the root metadata, further comprises:
and updating the root element pointer based on the updated root element data.
9. The method of any of claims 1-4, wherein the write operation comprises an insert operation, a delete operation, and a modify operation on the first balanced lookup tree.
10. A memory read-write device comprising:
the system comprises an acquisition module, a recovery module and a recovery module, wherein the acquisition module is used for acquiring root metadata corresponding to a read transaction/write transaction to be executed, and the root metadata comprises a root node pointer, a tree version number and a list to be recovered;
the determining module is used for determining a corresponding first balance search tree in the memory area according to the root node pointer;
the first execution module is used for responding to the transaction to be executed as a read transaction, copying the root metadata, and reading the data of the first balance search tree based on the first copied root metadata obtained by copying;
and the second execution module is used for responding to the transaction to be executed as a write transaction, copying the root metadata, and performing write operation on the first balanced search tree based on the copied second copied root metadata.
11. The apparatus of claim 10, wherein the second execution module is further to:
based on second replication root metadata obtained by replication, acquiring a node to be subjected to data modification on the first balance search tree as an initial structure node, and placing the initial structure node into the to-be-recovered list contained in the second replication root metadata;
Copying each initial structure node, and modifying data on the copied structure node;
after all the replication structure nodes complete data modification and write operation submission, correspondingly replacing the initial structure node based on the modified structure node generated after modification, acquiring a second balance search tree generated after replacement, and,
and replacing the root metadata based on the second copy root metadata at the current moment.
12. The apparatus of claim 11, wherein the second execution module is further to:
if it is detected that the structural nodes on the second balanced search tree are in an unbalanced state, performing a rotation splitting operation to adjust the tree structure of the second balanced search tree.
13. The apparatus of claim 11, wherein the second execution module is further to:
acquiring a tree version number corresponding to the first balanced search tree as a reference tree version number;
acquiring a tree version number carried by root metadata corresponding to each read transaction currently in an execution state as a read transaction tree version number;
performing execution state monitoring on each read transaction with the read transaction tree version number smaller than or equal to the reference tree version number;
And after the fact that all the read transactions with the read transaction tree version numbers smaller than or equal to the reference tree version number are executed is detected, releasing the initial structure node in the list to be recycled.
14. The apparatus of any of claims 10-13, wherein the acquisition module is further to:
receiving a read transaction/write transaction instruction sent by a user;
analyzing the read transaction/write transaction instruction to obtain a root pointer carried by the read transaction/write transaction instruction;
and determining the root metadata pointed by the root metadata pointer.
15. The apparatus of claim 12, wherein the second execution module is further to:
judging whether the root node of the second balance search tree is changed after adjusting the tree structure of the second balance search tree;
and if the root node of the second balanced search tree is changed, updating the tree version number and the root node pointer carried by the root metadata.
16. The apparatus of claim 15, wherein the second execution module is further to:
and if the root node of the second balanced search tree is not changed, updating the tree version number carried by the root metadata.
17. The apparatus of claim 15 or 16, wherein the second execution module is further configured to:
and updating the root element pointer based on the updated root element data.
18. The apparatus of any of claims 10-13, wherein the write operation comprises an insert operation, a delete operation, and a modify operation on the first balanced lookup tree.
19. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-9.
20. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-9.
21. A computer program product comprising a computer program which, when executed by a processor, implements the steps of the method according to any one of claims 1-9.
CN202311459996.8A 2023-11-03 2023-11-03 Memory read-write method and device Pending CN117390027A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311459996.8A CN117390027A (en) 2023-11-03 2023-11-03 Memory read-write method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311459996.8A CN117390027A (en) 2023-11-03 2023-11-03 Memory read-write method and device

Publications (1)

Publication Number Publication Date
CN117390027A true CN117390027A (en) 2024-01-12

Family

ID=89440708

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311459996.8A Pending CN117390027A (en) 2023-11-03 2023-11-03 Memory read-write method and device

Country Status (1)

Country Link
CN (1) CN117390027A (en)

Similar Documents

Publication Publication Date Title
US10552372B2 (en) Systems, methods, and computer-readable media for a fast snapshot of application data in storage
US9619430B2 (en) Active non-volatile memory post-processing
US7676492B2 (en) Migration of database using serialized objects
JP2022141957A (en) Metadata snapshot method and snap device thereof
CN113364877B (en) Data processing method, device, electronic equipment and medium
US10489356B1 (en) Truncate and append database operation
US20210365439A1 (en) Distributed transaction execution in distributed databases
EP3877859A1 (en) Write-write conflict detection for multi-master shared storage database
CN113792024A (en) Method, device, equipment and storage medium for migrating data
JP2022141980A (en) Metadata snapshot method and snapshot device thereof
CN105938446B (en) The data supported based on RDMA and hardware transactional memory replicate fault-tolerance approach
US10127270B1 (en) Transaction processing using a key-value store
US8738873B2 (en) Interfacing with a point-in-time copy service architecture
US11093348B2 (en) Method, device and computer program product for recovering metadata
US11934927B2 (en) Handling system-characteristics drift in machine learning applications
CN117390027A (en) Memory read-write method and device
CN109710698A (en) A kind of data assemblage method, device, electronic equipment and medium
CN115469810A (en) Data acquisition method, device, equipment and storage medium
US9424261B2 (en) Techniques to take clean database file snapshot in an online database
US11334445B2 (en) Using non-volatile memory to improve the availability of an in-memory database
US10339011B1 (en) Method and system for implementing data lossless synthetic full backups
JP5832592B1 (en) Data management device
US11271999B2 (en) Flexible associativity in multitenant clustered environments
US11042356B2 (en) Tournament tree rollback for payload write exception
US20240126785A1 (en) Failover of database sessions to a logical replica database

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination