Data writing and reading method, device and server
By writing the transaction ID and generating data mapping relationships during the execution of the write transaction, the problem of high IO and lock overhead when external read consistency is solved, and the data processing efficiency is improved.
Patent Information
- Application Number
- CN202011105602.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-15
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2040-10-15
AI Technical Summary
When the existing technology achieves external read consistency, the IO overhead and lock overhead are large, resulting in low efficiency.
During the execution of a write transaction, the transaction ID is written into the version data, and a data mapping relationship is generated during submission. The submission timestamp and transaction ID are used to avoid directly writing the submission timestamp during reading, thereby reducing IO and lock operations.
It effectively reduces IO and lock overhead, ensures external read consistency, and improves data processing efficiency.
Smart Images

Figure CN112231070B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a data writing and reading method, device and server. Background Art
[0002] External read consistency is the core topic of distributed transactions, which means that the visible order of transactions complies with the externally visible commit order. In order to achieve external read consistency, central timing applications are born, that is, TM (Transaction Manager) obtains the transaction start timestamp from the TSO (Time Stamp Oracle) node, i.e., the central timing node, when the transaction is started, and obtains the transaction commit timestamp from the TSO node during the transaction commit phase.
[0003] In the related art, the data processing flow applicable to the MVCC (Multi-Version Concurrency Control) mechanism is as follows: when a resource server in a distributed system receives a processing request for a write transaction, it executes the write transaction, that is, generates new version data for the row record targeted by the write transaction, and enters the transaction commit phase when the write transaction is completed; in the transaction commit phase, the commit timestamp of the write transaction is written into the generated version data, and the version data is committed; and when a processing request for a read transaction is received, if the start timestamp of the read transaction is greater than the commit timestamp in at least one version data of the targeted row record, indicating that the read transaction is visible to the at least one version data, then the response result of the read transaction is determined based on the at least one version data.
[0004] However, during the execution of a write transaction, the version data of the row record is changed, which involves applying for and releasing page locks and row locks. The commit timestamp of a write transaction is only generated during the transaction commit phase. Therefore, when writing the commit timestamp of the write transaction to the corresponding version data, the version data needs to be changed again. It can be seen that in the related technology, when achieving external read consistency, there are problems of large IO overhead and lock overhead. Summary of the invention
[0005] The purpose of the embodiments of the present invention is to provide a data writing and reading method, device and server to solve the problem of large IO overhead and lock overhead when realizing external read consistency in related technologies. The specific technical solution is as follows:
[0006] In a first aspect, an embodiment of the present invention provides a data writing method, which is applied to a resource server; the method comprises:
[0007] When receiving a processing request for a target write transaction, executing the target write transaction, and during the execution of the target write transaction, writing the transaction ID of the target write transaction into the target version data, the target version data being new version data of the row record targeted by the target write transaction;
[0008] When the target write transaction is executed, obtaining a commit timestamp of the target write transaction;
[0009] The target version data is submitted, and a data mapping relationship corresponding to the target write transaction is generated using the submission timestamp and transaction ID of the target write transaction.
[0010] Optionally, the method further comprises:
[0011] The data mapping relationship corresponding to the target write transaction is saved. Optionally, the memory of the resource server includes a plurality of first-category data blocks with consecutive block numbers, and each first-category data block is used to store the data mapping relationship corresponding to a first number of write transactions with consecutive transaction IDs;
[0012] The storing of the data mapping relationship corresponding to the target write transaction includes:
[0013] Calculate, based on the transaction ID of the target transaction and the first quantity, a first block number of a first-category data block to be written in the data mapping relationship corresponding to the target write transaction, and a first offset address when writing into the first-category data block;
[0014] In the first-type data block having the first block number, the data mapping relationship corresponding to the target write transaction is stored in the storage space indicated by the first offset address.
[0015] Optionally, the memory further comprises a plurality of second-category data blocks with consecutive block numbers, each of which is used to store memory addresses of a second number of first-category data blocks with consecutive block numbers;
[0016] The storing, in the first type of data block having the first block number, in the storage space indicated by the first offset address, a data mapping relationship corresponding to the target write transaction comprises:
[0017] Based on the first block number and the second number, calculating a second block number of the second type of data block where the target memory address is located, and a second offset address of the target memory address in the second type of data block; wherein the target memory address is a memory address of the first type of data block having the first block number;
[0018] Reading a memory address at the second offset address in a second type storage block having the second block number to obtain a target memory address;
[0019] In the first type of data block indicated by the target memory address, the data mapping relationship corresponding to the target write transaction is stored in the storage space indicated by the first offset address.
[0020] Optionally, the method further comprises:
[0021] For each first-category data block, if it is detected that the number of recorded data mapping relationships in the first-category data block is equal to the first number, and the largest commit timestamp in the recorded data mapping relationships is less than the start timestamp of a pending or executed read transaction, an identification content used to characterize the recovery status is written in the storage space storing the memory address of the first-category data block.
[0022] In a second aspect, an embodiment of the present invention provides a data reading method, which is applied to a resource server; the method comprises:
[0023] When a processing request for a target read transaction is received, a target transaction ID in each version data of a target row record is obtained; wherein the target row record is a row record targeted by the target read transaction;
[0024] For each target transaction ID, search for a data mapping relationship corresponding to a write transaction having the target transaction ID from the pre-generated data mapping relationships corresponding to each write transaction;
[0025] For each target transaction ID, if the commit timestamp in the found data mapping relationship is less than the start timestamp of the target read transaction, the version data having the target transaction ID is determined as the version data to be used;
[0026] Based on the version data to be used, a response result of the target read transaction is determined.
[0027] Optionally, the memory of the resource server includes a plurality of first-category data blocks with consecutive block numbers, and each first-category data block is used to store data mapping relationships corresponding to a first number of write transactions with consecutive transaction IDs;
[0028] The step of searching, for each target transaction ID, a data mapping relationship corresponding to a write transaction having the target transaction ID from pre-saved data mapping relationships corresponding to various write transactions includes:
[0029] For each target transaction ID, based on the target transaction ID and the first number, calculating a third block number of a first-type data block for storing a data mapping relationship corresponding to a target write transaction, and a third offset address of the data mapping relationship corresponding to the target write transaction when writing; wherein the target write transaction is a write transaction having the target transaction ID;
[0030] In the first-category data block having the third block number, the data mapping relationship corresponding to the target write transaction is read in the storage space indicated by the third offset address.
[0031] Optionally, the memory further comprises a plurality of second-category data blocks with consecutive block numbers, each of which is used to store memory addresses of a second number of first-category data blocks with consecutive block numbers;
[0032] In the first-category data block having the third block number, within the storage space indicated by the third offset address, reading the data mapping relationship corresponding to the target write transaction includes:
[0033] Based on the third block number and the second number, calculate a fourth block number of the second type of data block where the target memory address is located, and a fourth offset address of the target memory address in the second type of data block; wherein the target memory address is a memory address of the first type of data block having the third block number;
[0034] Reading a memory address at the fourth offset address in a second-type storage block having the fourth block number to obtain a target memory address;
[0035] In the first type of data block indicated by the target memory address, within the storage space indicated by the third offset address, the data mapping relationship corresponding to the target write transaction is read.
[0036] Optionally, the method further comprises:
[0037] If the identification content used to characterize the recycling status is marked at the fourth offset address in the second-type storage block having the fourth block number, the version data recording the target transaction ID is determined as the version data to be used.
[0038] In a third aspect, an embodiment of the present invention provides a data writing device, which is applied to a resource server; the device comprises:
[0039] a first processing module, configured to execute the target write transaction upon receiving a processing request of the target write transaction, and write the transaction ID of the target write transaction into target version data during the execution of the target write transaction, wherein the target version data is new version data generated for the row record targeted by the target write transaction;
[0040] A second processing module, configured to obtain a commit timestamp of the target write transaction when the target write transaction is executed;
[0041] The third processing module is used to commit the executed target write transaction and generate a data mapping relationship corresponding to the target write transaction by using the commit timestamp and transaction ID of the target write transaction.
[0042] In a fourth aspect, an embodiment of the present invention provides a data reading device, which is applied to a resource server; the device comprises:
[0043] An acquisition module, configured to acquire a target transaction ID in each version data of a target row record when receiving a processing request of a target read transaction; wherein the target row record is a row record targeted by the target read transaction;
[0044] A search module, used for searching, for each target transaction ID, a data mapping relationship corresponding to a write transaction having the target transaction ID from the pre-generated data mapping relationships corresponding to each write transaction;
[0045] An analysis module is used for obtaining, for each target transaction ID, version data recorded with the target transaction ID as the version data to be used if, in the data mapping relationship found, the commit timestamp is less than the start timestamp of the target read transaction;
[0046] A response module is used to determine a response result of the target read transaction based on the version data to be used.
[0047] In a fifth aspect, an embodiment of the present invention provides a resource server, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0048] Memory, used to store computer programs;
[0049] The processor is used to implement the method steps provided in the first aspect and / or the second aspect when executing the program stored in the memory.
[0050] In a sixth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect and / or the method steps described in the second method are performed.
[0051] Beneficial effects of the embodiments of the present invention:
[0052] In the data writing scheme provided by the embodiment of the present invention, during the execution of the target write transaction, the transaction ID of the target write transaction is written into the new version data of the row record targeted by the target write transaction, i.e., the target version data; when the target write transaction is executed, the target version data is committed, and the commit timestamp and transaction ID of the target write transaction are used to generate the data mapping relationship corresponding to the target write transaction. In this scheme, the transaction ID is recorded in the new version data of the row record targeted by the write transaction, and a data mapping relationship between the commit timestamp of the write transaction and the transaction ID of the write transaction is generated for the data reading process. In this way, the IO overhead and lock overhead generated when the commit timestamp is written in the version data of the row record can be avoided. Therefore, this scheme can solve the problem of large IO overhead and lock overhead in the related technology when realizing external read consistency.
[0053] In addition, in the data reading method provided based on the above data writing method, the commit timestamp of the write transaction can be determined through the transaction ID, and then it can be determined whether each version of data is visible to the read transaction based on the relationship between the start timestamp of the read transaction and the commit timestamp of the write transaction, thereby determining the response result of the read transaction. Therefore, through this solution, external read consistency can be guaranteed.
[0054] Of course, it is not necessary to achieve all of the advantages described above at the same time to implement any product or method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other embodiments can be obtained based on these drawings without paying creative work.
[0056] Figure 1 A flow chart of a data writing method provided by an embodiment of the present invention;
[0057] FIG2(a) is a schematic diagram of the interaction process between the resource manager, the transaction manager and the central timing node;
[0058] FIG2( b ) is a schematic diagram of storage of a first type of storage block in an embodiment of the present invention;
[0059] FIG2( c ) is a schematic diagram of the storage structure of the first type of storage block and the second type of storage block in an embodiment of the present invention;
[0060] FIG2( d ) is a schematic diagram of a storage structure of a first type of storage block provided in an embodiment of the present invention;
[0061] FIG2(e) is a schematic diagram of storage provided with a recycling mark according to an embodiment of the present invention;
[0062] Figure 3 A flow chart of a data reading method provided by an embodiment of the present invention;
[0063] Figure 4 A schematic diagram of the structure of a data writing device provided by an embodiment of the present invention;
[0064] Figure 5 A schematic diagram of the structure of a data reading device provided by an embodiment of the present invention;
[0065] Figure 6 A schematic diagram of the structure of a resource server provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0066] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0067] In order to solve the problems in the prior art, embodiments of the present invention provide a data writing and reading method, device and server.
[0068] The following first introduces the data writing method provided by the embodiment of the present invention.
[0069] The data writing method provided in the embodiment of the present invention is applied to a resource server. Specifically, the execution subject of the data writing method can be a RM (Resource Manager) in the resource server. The resource server is a server for resource management in a data storage system, and the data storage system can also include: a transaction management server and a central timing node, wherein the transaction management server is provided with a transaction manager. When central timing is adopted, the interaction process of the resource manager, transaction manager and TSO node can be shown in FIG2(a), wherein the transaction manager TM requests the start timestamp of the write transaction from the TSO node when generating a write transaction, i.e., Get start_ts; sends the write transaction to the RM through SQL statements such as SQL1 and SQL2, and the SQL statements carry the start timestamp start_ts; after completing the execution phase, the write transaction can enter the commit phase, and before the commit phase of the write transaction, the TM can first request the commit timestamp of the write transaction from the TSO node, i.e., Get commit_ts, and then commit the write transaction based on the commit timestamp commit_ts. Among them, Xa_perpare in FIG2(a) is used to indicate that the write transaction enters the execution phase, and Xa_Commit is used to indicate that the write transaction enters the execution phase. When the transaction manager generates a read transaction, it requests the start timestamp of the read transaction from the central timing node. It can be understood that the start timestamp and the commit timestamp are both logical timestamps, and the specific manner in which the central timing node generates the start timestamp and the commit timestamp is not limited in the embodiment of the present invention.
[0070] In addition, the transactions involved in the embodiments of the present invention may be pessimistic transactions. The so-called pessimistic transactions specifically refer to transactions that use locking methods and data writing methods to a public database during transaction processing; the optimistic transactions corresponding to pessimistic transactions refer to transactions that do not use locking methods and data writing methods to a cache. In addition, the processing of write transactions is divided into two phases: an execution phase and a commit phase. Among them, the execution phase is the execution process of the write transaction, which is used to change the version data of the row record of the write transaction, thereby forming a new version data; and the commit phase of the write transaction is to submit the new version data of the row record of the write transaction to the database, thereby persisting the processing.
[0071] Furthermore, the solution provided by the embodiment of the present invention is applicable to the data processing flow under the MVCC (Multi-Version Concurrency Control) mechanism. Under this mechanism, each row record in the database has at least one version of data, and each version of data is data formed by executing a write transaction.
[0072] like Figure 1As shown, a data writing method provided by an embodiment of the present invention may include the following steps:
[0073] S101, when a processing request of a target write transaction is received, the target write transaction is executed, and during the execution of the target write transaction, the transaction ID of the target write transaction is written into the target version data;
[0074] The target version data is new version data for the row record of the target write transaction. Specifically, the target version data is new version data for the row record of the target write transaction that is generated when the target write transaction is executed.
[0075] Since the transaction ID is the identity information of the transaction, it exists from the time the transaction is generated; and the transaction ID can uniquely identify the transaction, that is, it has a unique correspondence with the commit timestamp of the transaction. Then, during the execution of the target write transaction, the transaction ID of the target write transaction can be written into the target version data, and after obtaining the commit timestamp, the mapping relationship between the transaction ID of the target write transaction and the commit timestamp is saved. In this way, the strategy of exchanging space for time can solve the technical problems existing in the prior art, namely, the problems of IO redundancy and lock redundancy.
[0076] S102, when the target write transaction is executed, obtaining a commit timestamp of the target write transaction;
[0077] The commit timestamp of the target write transaction is a timestamp generated in the commit phase of the target write transaction. When the target write transaction is executed, the commit phase of the target write transaction can be entered, so that the transaction manager can request the commit timestamp from the central timing node, thereby sending the commit timestamp of the target write transaction to the resource manager in the resource server, thereby obtaining the commit timestamp of the target write transaction.
[0078] S103, submitting the target version data, and using the commit timestamp and transaction ID of the target write transaction to generate a data mapping relationship corresponding to the target write transaction;
[0079] The data mapping relationship corresponding to any write transaction is a mapping relationship between a commit timestamp and a transaction ID of the write transaction.
[0080] Since the commit timestamp of the write transaction and the start timestamp of the read transaction are the key to ensuring external read consistency, after the transaction ID of the target write transaction is written into the target version data of the row record, the data mapping relationship corresponding to the target write transaction can be generated, thereby establishing an association relationship between the commit timestamp of the target write transaction and the target version data. In this way, when the data is subsequently read, the corresponding commit timestamp can be found based on the transaction ID of the record in the version data, and then based on the relationship between the commit timestamp of the write transaction and the start timestamp of the read transaction, it can be determined whether each version of the row record targeted by the read transaction is visible to the read transaction, thereby ensuring external read consistency. It can be understood that the target version data is submitted, that is, entering the submission stage of the target write transaction.
[0081] It should be noted that after the data mapping relationship corresponding to the target write transaction is generated using the commit timestamp and transaction ID of the target write transaction, the data mapping relationship corresponding to the target write transaction can be saved. Exemplarily, the data mapping relationship corresponding to the target write transaction can be saved in the memory of the resource server. There are many specific implementation methods for saving the data mapping relationship corresponding to the target write transaction in the memory of the resource management server, which will be explained in conjunction with specific examples later.
[0082] In the data writing scheme provided by the embodiment of the present invention, during the execution of the target write transaction, the transaction ID of the target write transaction is written into the new version data of the row record targeted by the target write transaction, i.e., the target version data; when the target write transaction is executed, the target version data is committed, and the commit timestamp and transaction ID of the target write transaction are used to generate the data mapping relationship corresponding to the target write transaction. In this scheme, the transaction ID is recorded in the new version data of the row record targeted by the write transaction, and a data mapping relationship between the commit timestamp of the write transaction and the transaction ID of the write transaction is generated for the data reading process. In this way, the IO overhead and lock overhead generated when the commit timestamp is written in the version data of the row record can be avoided. Therefore, this scheme can solve the problem of large IO overhead and lock overhead in the related technology when realizing external read consistency.
[0083] The following example introduces a specific implementation method for saving the data mapping relationship corresponding to the target write transaction.
[0084] The memory of the resource server includes a plurality of first-class data blocks with consecutive block numbers, each of which is used to store data mapping relationships corresponding to a first number of write transactions with consecutive transaction IDs; the first-class data block may also be referred to as a block;
[0085] Saving the data mapping relationship corresponding to the target write transaction may include step A1 and step A2:
[0086] Step A1, based on the transaction ID of the target transaction and the first quantity, calculating the first block number of the first type of data block to be written in the data mapping relationship corresponding to the target write transaction, and the first offset address when writing into the first type of data block;
[0087] Step A2: storing the data mapping relationship corresponding to the target write transaction in the storage space indicated by the first offset address in the first type data block having the first block number.
[0088] The block numbers of the plurality of first-category data blocks are continuous block numbers, and each first-category data block stores data mapping relationships corresponding to a first number of write transactions with continuous transaction IDs. Therefore, after obtaining the transaction ID of any target write transaction, the first-category storage block and the first offset address where the mapping relationship corresponding to the target write transaction is to be stored can be obtained by performing mathematical operations on the transaction ID and the first number of the target write transaction. After determining the first block number and the first offset address, the data mapping relationship corresponding to the target write transaction can be stored in the storage space indicated by the first offset address in the first-category data block with the first block number.
[0089] Exemplarily, the first block number is obtained by rounding the transaction ID of the target write transaction and the first quantity; and the first offset address is obtained by modulo the transaction ID of the target write transaction and the first quantity.
[0090] To facilitate understanding of the specific implementation process of step A1, an example is given below:
[0091] For example, as shown in FIG2(b), assuming that the block numbers of multiple first-class data blocks are from 1 to 3, and the transaction IDs are numbered from 1 to 3072, each first-class data block stores KV key-value pairs corresponding to 1024 write transactions, where the KV key-value pairs are data mapping relationships between transaction IDs and commit timestamps;
[0092] Based on the above description, assuming that the transaction ID of a target write transaction is 5, then the calculation method of the first block number of the first type of data block to be written in the data mapping relationship corresponding to the target write transaction is: The calculation method of the first offset address when writing into the first type data block is: 5%1024=5. Through calculation, it can be known that the first block number of the first type data block to be written in the data mapping relationship corresponding to the target write transaction is 1, and the first offset address when writing into the first type data block is 5.
[0093] For another example: Assume that the block numbers of multiple first-class data blocks are from 0 to 2, and the transaction IDs are numbered from 1 to 3072, and each first-class data block stores KV key-value pairs corresponding to 1024 write transactions, where the KV key-value pairs are data mapping relationships between transaction IDs and commit timestamps;
[0094] Based on the above description, assuming that the transaction ID of a target write transaction is 5, then the calculation method of the first block number of the first type of data block to be written in the data mapping relationship corresponding to the target write transaction is: The calculation method of the first offset address when writing into the first type data block is: 5%1024=5. Through calculation, it can be known that the first block number of the first type data block to be written in the data mapping relationship corresponding to the target write transaction is 0, and the first offset address when writing into the first type data block is 5.
[0095] It is understandable that if the size of each first-class data block is 16KB, it can store 1,000 KVs. If there are 50,000 write transactions per second, then in the absence of recycling, the relationship between the time that allows write transactions to run in parallel and the number of data blocks is as follows:
[0096] Parallel write transactions within 1 second require 50 first-class data blocks, or 800KB of memory space.
[0097] The parallelism of write transactions within 10 seconds requires 500 first-class data blocks, that is, 8M of memory space;
[0098] The parallelism of write transactions within 60 seconds requires 3,000 first-class data blocks, that is, 50MB of memory space;
[0099] The parallelism of write transactions within 600 seconds requires 30,000 first-class data blocks, that is, 500 MB of memory space.
[0100] That is to say, through the storage method provided by the embodiment of the present invention, in the absence of recycling, 500MB of memory space can accommodate 600s of write transactions for parallel processing.
[0101] It is understandable that in different application scenarios, the level of transaction duration is different. The corresponding memory space can be selected as the KV storage space according to the transaction duration, so as to cope with a large number of parallel transactions. For example: in the oltp scenario, the transaction duration is in seconds, generally around 10 seconds, so selecting 500MB of memory space can cope with a large number of parallel transactions. Among them, the oltp (On-Line Transaction Processing) scenario, also known as the transaction-oriented processing process, has the basic feature that the user data received by the foreground can be immediately transmitted to the computing center for processing, and the processing results are given in a very short time, which is one of the ways to quickly respond to user operations.
[0102] It can be seen that through this storage method, when querying KV, the effect of locked access can be achieved without locking.
[0103] In addition, in order to achieve fast access to each first-category data block, the memory includes a plurality of second-category data blocks with consecutive block numbers, and each second-category data block is used to store memory addresses of a second number of first-category data blocks with consecutive block numbers;
[0104] Storing a data mapping relationship corresponding to a target write transaction in a storage space indicated by a first offset address in a first-type data block having a first block number may include steps B1-B3:
[0105] Step B1, based on the first block number and the second quantity, calculating the second block number of the second type data block where the target memory address is located, and the second offset address of the target memory address in the second type data block; wherein the target memory address is the memory address of the first type data block having the first block number;
[0106] Step B2, reading the memory address at the second offset address in the second type storage block having the second block number to obtain a target memory address;
[0107] Step B3: In the first type of data block indicated by the target memory address, in the storage space indicated by the first offset address, the data mapping relationship corresponding to the target write transaction is stored.
[0108] Among them, the block numbers of multiple second-category data blocks are continuous block numbers, and each second-category data block stores the memory addresses of a second number of first-category data blocks with continuous block numbers. Therefore, after obtaining the first block number of the first-category data block, the second block number of the second-category data block where the memory address of the first-category data block is located, and the second offset address in the second-category data block can be obtained by performing mathematical operations on the first block number and the second number of the first-category data blocks.
[0109] Exemplarily, the second block number is obtained by performing a rounding operation on the first block number and the second number; and the second offset address is obtained by performing a modulo operation on the first block number and the second number.
[0110] To facilitate understanding of the specific implementation process of step A1, an example is given below:
[0111] For example: Assume that the block numbers of multiple second-class data blocks are from 1 to 1024, and the block numbers of multiple first-class data blocks are from 1 to 6000, and each second-class data block stores the memory addresses of 2000 first-class data blocks;
[0112] Based on the above description, assuming that the first block number of the first type of data block is 3, then the block number of the second type of data block where the target memory address of the first type of data block is located is: The calculation method of the second offset address when the memory address is written into the second type data block is: 3%2000=3. Through calculation, it can be known that the second block number of the second type data block where the target memory address is located is 1, and the second offset address of the target memory address in the second type data block is 5.
[0113] It is understandable that if the memory address of each first-class data block is stored in 8 bytes, 16KB of memory space can store 2,000 first-class data blocks, and if there are 50,000 write transactions per second and each first-class data block can store 1,000 KVs, it can satisfy 40s of parallel transactions. 16MB of memory space can satisfy 40,000S of parallel business.
[0114] Figure 2(c) shows the relationship between the first-category data and the second-category data blocks, where Block_index_block is a second-category data block, and each second-category data records the memory addresses Mem-addr of multiple first-category data blocks. Each memory address Mem-addr is used to indicate a 16KB BLOCK_MEM, i.e., a first-category data block. Each type of data block records 1024 KVs, and max_continu_wm is the maximum commit timestamp recorded in the first-category data block described below.
[0115] It can be seen that a large number of parallel businesses can be satisfied with a smaller memory space, and the access effect can be locked first in a lock-free manner.
[0116] In addition, since at a certain moment, the smallest start timestamp in the active read transactions is greater than the commit timestamp, the version data formed by the write transaction corresponding to the commit timestamp is visible to all read transactions, so the commit timestamp has no meaning. Based on this consideration, the embodiment of the present invention also provides a storage space recovery mechanism. Specifically, the method also includes:
[0117] For each first-category data block, if it is detected that the number of recorded data mapping relationships in the first-category data block is equal to the first number, and the largest commit timestamp in the recorded data mapping relationships is less than the start timestamp of a pending or executed read transaction, an identification content used to characterize the recovery status is written in the storage space storing the memory address of the first-category data block.
[0118] It can be understood that, after the identification content used to characterize the recycling status is written into the storage space storing the memory address of the first-category data block, the version data generated by the write transaction corresponding to each data mapping relationship in the first-category data block is visible to any read transaction. In addition, after the identification content used to characterize the recycling status is written into the storage space storing the memory address of the first-category data block, the first-category data block is a recycled data block.
[0119] Among them, the recycling of memory space can be carried out in a timed recycling manner, but it is certainly not limited to this. Exemplarily, the time interval of the timed recycling can be 30s, 50s, 60s, etc. Figure 2(d) exemplarily shows the storage memory of two first-category data blocks. The first first-category data block stores data mapping relationships of transactions with transaction IDs of 1-1000. The content below the first first-category data is the stored content. The transaction ID is on the left outside the first row, and the commit timestamp is on the right. In the first row, the maximum commit timestamp in the first-category storage block is recorded on the left, and the number of data mapping relationships that have been written to the first-category data block is recorded on the right. Similarly, the content below the second first-category data block storing transaction IDs of 1001-2000 is similar to the storage structure of the first first-category data block.
[0120] The above recycling mechanism can solve the problem of large IO overhead and lock overhead when realizing external read consistency in related technologies; at the same time, it can ensure the reasonable use of memory and avoid space waste.
[0121] Based on the above data writing method, the embodiment of the present invention further provides a data reading method. The data reading method provided by the embodiment of the present invention is introduced below.
[0122] The data reading method provided in the embodiment of the present invention is applied to a resource server. Specifically, the execution subject of the data reading method can be a resource manager in the resource server. The resource server is a server for resource management in a data storage system, and the data storage system can also include: a transaction management server and a central timing node, wherein the transaction management server is provided with a transaction manager.
[0123] like Figure 3As shown, the data reading method provided by the embodiment of the present invention may include the following steps:
[0124] S301, when a processing request of a target read transaction is received, a target transaction ID in each version data of a target row record is obtained; wherein the target row record is a row record targeted by the target read transaction;
[0125] When a processing request for a target read transaction is received, in order to determine which version data of the target row record is visible to the target read transaction, the target transaction ID in each version data of the target row record can be obtained. The target transaction ID in each version data is the transaction ID of the write transaction written when the version data is generated.
[0126] S302, for each target transaction ID, searching for a data mapping relationship corresponding to a write transaction having the target transaction ID from pre-generated data mapping relationships corresponding to various write transactions;
[0127] Whether the target read transaction is visible to the version data depends on the start timestamp of the target read transaction and the commit timestamp of the write transaction that generates the version data. Therefore, after obtaining each transaction ID, the data mapping relationship corresponding to the write transaction with the target transaction ID can be searched from the pre-generated data mapping relationships corresponding to each write transaction, thereby obtaining the commit timestamp of the write transaction corresponding to the version data.
[0128] Among them, the pre-generated data mapping relationships corresponding to each write transaction can be stored in the memory of the resource server. At this time, the data mapping relationship corresponding to the write transaction with the target transaction ID is searched from the data mapping relationships stored in the memory. It can be understood that there can be multiple ways to store data mapping relationships in the memory, and the way to search for the data mapping relationship corresponding to the write transaction with the target transaction ID corresponds to the way the data mapping relationship is stored. In order to make the scheme clear and the layout clear, the following introduces the specific implementation method of searching for the data mapping relationship corresponding to the write transaction with the target transaction ID from the data mapping relationships corresponding to each pre-generated write transaction.
[0129] S303, for each target transaction ID, if the commit timestamp in the found data mapping relationship is less than the start timestamp of the target read transaction, obtain the version data recorded with the target transaction ID as the version data to be used;
[0130] If the commit timestamp in the data mapping relationship found to contain a target transaction ID is less than the start timestamp of the target read transaction, it means that the version data generated by the write transaction corresponding to the data mapping relationship is visible to the target read transaction. Therefore, the version data recorded with the target transaction ID can be obtained as the version data to be used.
[0131] S304: Determine a response result of the target read transaction based on the version data to be used.
[0132] It is understandable that there may be at least one version data to be used. Since the target read transaction usually reads the latest data, the latest version data may be selected from the version data to be used as the response result of the target read transaction.
[0133] To facilitate understanding of the solution, Figure 2(e) shows four versions of data for a row record, where rowdata in each version of data is the specific data content, Trx_id is the transaction ID written into the version data, and rollptr is a pointer used to concatenate the various version data. That is, the various version data of a row record can be identified through these pointers; from top to bottom, the transaction ID in each version of data corresponds to the commit timestamp of the write transaction: 300, 350, 400, 500. Assuming that the start timestamp of a read transaction is 500, the first three versions of data are visible to the read transaction. NUlL in Figure 2(e) represents that the version data is visible to the read transaction, and 500 in the fourth version of data represents the commit timestamp of the write transaction corresponding to the transaction ID.
[0134] In the data reading method provided based on the above data writing method, the commit timestamp of the write transaction can be determined through the transaction ID, and then it can be determined whether each version of data is visible to the read transaction based on the relationship between the start timestamp of the read transaction and the commit timestamp of the write transaction, thereby determining the response result of the read transaction. Therefore, through this solution, external read consistency can be guaranteed.
[0135] Optionally, the memory of the resource server includes a plurality of first-category data blocks with consecutive block numbers, and each first-category data block is used to store data mapping relationships corresponding to a first number of write transactions with consecutive transaction IDs;
[0136] Based on the storage method of the data mapping relationship given in the embodiment of the above data writing method, for each target transaction ID, searching for the data mapping relationship corresponding to the write transaction having the target transaction ID from the pre-generated data mapping relationships corresponding to each write transaction may include steps C1-C2:
[0137] Step C1, for each target transaction ID, based on the target transaction ID and the first quantity, calculating a third block number of a first-type data block for storing a data mapping relationship corresponding to a target write transaction, and a third offset address of the data mapping relationship corresponding to the target write transaction when writing; wherein the target write transaction is a write transaction having the target transaction ID;
[0138] Step C2: reading the data mapping relationship corresponding to the target write transaction in the storage space indicated by the third offset address in the first-category data block having the third block number.
[0139] The block numbers of the plurality of first-category data blocks are continuous block numbers, and each first-category data block stores data mapping relationships corresponding to a first number of write transactions with continuous transaction IDs. Therefore, after obtaining any target transaction ID, a mathematical operation can be performed on the target transaction ID and the first number to obtain the third block number of the first-category data block for storing the data mapping relationship corresponding to the target write transaction and the third offset address of the data mapping relationship corresponding to the target write transaction when writing. After determining the third block number and the third offset address, the data mapping relationship corresponding to the target write transaction can be read in the storage space indicated by the third offset address in the first-category data block with the third block number.
[0140] Exemplarily, the third block number is obtained by performing a rounding operation on the target transaction ID and the first quantity; and the third offset address is obtained by performing a modulo operation on the target transaction ID and the first quantity. For the method of determining the block number and offset address of the first type of data block by the target transaction ID, reference can be made to the corresponding determination process in the above-mentioned data writing method, which will not be described in detail here.
[0141] In addition, in order to achieve fast access to each first-category data block, the memory includes a plurality of second-category data blocks with consecutive block numbers, and each second-category data block is used to store memory addresses of a second number of first-category data blocks with consecutive block numbers;
[0142] Based on the above storage result, in the first type data block with the third block number, in the storage space indicated by the third offset address, reading the data mapping relationship corresponding to the target write transaction may include steps D1-D3:
[0143] Step D1, based on the third block number and the second quantity, calculating the fourth block number of the second type data block where the target memory address is located, and the fourth offset address of the target memory address in the second type data block; wherein the target memory address is the memory address of the first type data block having the third block number;
[0144] Step D2, reading the memory address at the fourth offset address in the second type storage block having the fourth block number to obtain a target memory address;
[0145] Step D3, in the first type of data block indicated by the target memory address, in the storage space indicated by the third offset address, read the data mapping relationship corresponding to the target write transaction.
[0146] Among them, the block numbers of multiple second-category data blocks are continuous block numbers, and each second-category data block stores the memory addresses of a second number of first-category data blocks with continuous block numbers. Therefore, after obtaining the third block number of the first-category data block, the fourth block number of the second-category data block where the memory address of the first-category data block is located and the second offset address in the second-category data block can be obtained by performing mathematical operations on the third block number and the second number of the first-category data block.
[0147] Exemplarily, the fourth block number is obtained by performing a rounding operation on the third block number and the second number; and the fourth offset address is obtained by performing a modulo operation on the third block number and the second number. For the specific implementation of obtaining the block number and the offset address of the second type of data block through mathematical operation on the block number and the second number of the first type of data block, please refer to the corresponding content in the embodiment of the above data writing method.
[0148] Optionally, based on the recycling mechanism in the above data writing method, the method provided by the embodiment of the present invention may further include the following steps:
[0149] If the identification content used to characterize the recycling status is marked at the fourth offset address in the second-type storage block having the fourth block number, the version data recording the target transaction ID is determined as the version data to be used.
[0150] The above recycling mechanism can solve the problem of large IO overhead and lock overhead when realizing external read consistency in related technologies; at the same time, it can ensure the reasonable use of memory and avoid space waste.
[0151] Based on the above method embodiment, the present invention also provides a data writing device. Figure 4 As shown, the data writing device may include:
[0152] The first processing module 410 is configured to execute the target write transaction upon receiving a processing request of the target write transaction, and write the transaction ID of the target write transaction into the target version data during the execution of the target write transaction, wherein the target version data is new version data generated for the row record targeted by the target write transaction;
[0153] The second processing module 420 is used to obtain the commit timestamp of the target write transaction when the target write transaction is executed;
[0154] The third processing module 430 is used to commit the executed target write transaction and generate a data mapping relationship corresponding to the target write transaction using the commit timestamp and transaction ID of the target write transaction.
[0155] Optionally, the third processing module 430 is further configured to save a data mapping relationship corresponding to the target write transaction.
[0156] Optionally, the memory of the resource server includes a plurality of first-category data blocks with consecutive block numbers, and each first-category data block is used to store data mapping relationships corresponding to a first number of write transactions with consecutive transaction IDs;
[0157] The third processing module 430 saves the data mapping relationship corresponding to the target write transaction, including:
[0158] Calculate, based on the transaction ID of the target transaction and the first quantity, a first block number of a first-category data block to be written in the data mapping relationship corresponding to the target write transaction, and a first offset address when writing into the first-category data block;
[0159] In the first-type data block having the first block number, the data mapping relationship corresponding to the target write transaction is stored in the storage space indicated by the first offset address.
[0160] Optionally, the memory further comprises a plurality of second-category data blocks with consecutive block numbers, each of which is used to store memory addresses of a second number of first-category data blocks with consecutive block numbers;
[0161] The third processing module 430 stores the data mapping relationship corresponding to the target write transaction in the storage space indicated by the first offset address in the first type data block having the first block number, including:
[0162] Based on the first block number and the second number, calculating a second block number of the second type of data block where the target memory address is located, and a second offset address of the target memory address in the second type of data block; wherein the target memory address is a memory address of the first type of data block having the first block number;
[0163] Reading a memory address at the second offset address in a second type storage block having the second block number to obtain a target memory address;
[0164] In the first type of data block indicated by the target memory address, the data mapping relationship corresponding to the target write transaction is stored in the storage space indicated by the first offset address.
[0165] Optionally, the device further comprises:
[0166] A recycling module is used to write identification content used to characterize the recycling status in the storage space storing the memory address of the first-category data block for each first-category data block if it is detected that the number of recorded data mapping relationships in the first-category data block is equal to the first number, and the largest commit timestamp in the recorded data mapping relationships is less than the start timestamp of a pending or executed read transaction.
[0167] Based on the above method embodiment, the present invention also provides a data reading device. Figure 5 As shown, the data reading device may include:
[0168] The acquisition module 510 is used to acquire the target transaction ID in each version data of the target row record when receiving the processing request of the target read transaction; wherein the target row record is the row record targeted by the target read transaction;
[0169] A search module 520 is used to search, for each target transaction ID, a data mapping relationship corresponding to a write transaction having the target transaction ID from the pre-generated data mapping relationships corresponding to each write transaction;
[0170] The analysis module 530 is used to obtain, for each target transaction ID, version data recorded with the target transaction ID as the version data to be used if, in the data mapping relationship found, the commit timestamp is less than the start timestamp of the target read transaction;
[0171] The response module 540 is used to determine a response result of the target read transaction based on the version data to be used.
[0172] Optionally, the memory of the resource server includes a plurality of first-category data blocks with consecutive block numbers, and each first-category data block is used to store data mapping relationships corresponding to a first number of write transactions with consecutive transaction IDs;
[0173] The search module 520 searches for a data mapping relationship corresponding to a write transaction having the target transaction ID from the pre-generated data mapping relationships corresponding to each write transaction for each target transaction ID, including:
[0174] For each target transaction ID, based on the target transaction ID and the first number, calculating a third block number of a first-type data block for storing a data mapping relationship corresponding to a target write transaction, and a third offset address of the data mapping relationship corresponding to the target write transaction when writing; wherein the target write transaction is a write transaction having the target transaction ID;
[0175] In the first-category data block having the third block number, the data mapping relationship corresponding to the target write transaction is read in the storage space indicated by the third offset address.
[0176] Optionally, the memory further comprises a plurality of second-category data blocks with consecutive block numbers, each of which is used to store memory addresses of a second number of first-category data blocks with consecutive block numbers;
[0177] In the first type of data block with the third block number in the search module 520, reading the data mapping relationship corresponding to the target write transaction in the storage space indicated by the third offset address includes:
[0178] Based on the third block number and the second number, calculate a fourth block number of the second type of data block where the target memory address is located, and a fourth offset address of the target memory address in the second type of data block; wherein the target memory address is a memory address of the first type of data block having the third block number;
[0179] Reading a memory address at the fourth offset address in a second-type storage block having the fourth block number to obtain a target memory address;
[0180] In the first type of data block indicated by the target memory address, within the storage space indicated by the third offset address, the data mapping relationship corresponding to the target write transaction is read.
[0181] Optionally, the analysis module 530 is further configured to:
[0182] If the identification content used to characterize the recycling status is marked at the fourth offset address in the second-type storage block having the fourth block number, the version data recording the target transaction ID is determined as the version data to be used.
[0183] The embodiment of the present invention also provides a resource server, such as Figure 6 As shown, it includes a processor 601, a communication interface 602, a memory 603 and a communication bus 604, wherein the processor 601, the communication interface 602, and the memory 603 communicate with each other through the communication bus 604.
[0184] Memory 603, used for storing computer programs;
[0185] The processor 601 is used to implement the steps of the data writing method and / or the steps of the data reading method provided by the embodiment of the present invention when executing the program stored in the memory 603.
[0186] The communication bus mentioned in the resource server can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0187] The communication interface is used for communication between the resource server and other devices.
[0188] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0189] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0190] In another embodiment provided by the present invention, a computer-readable storage medium is also provided, which stores a computer program. When the computer program is executed by a processor, the steps of the data writing method and / or the steps of the data reading method provided in the embodiment of the present invention are implemented.
[0191] In another embodiment provided by the present invention, a computer program product containing instructions is also provided. When the computer program product is run on a computer, the computer executes the steps of the data writing method and / or the steps of the data reading method provided by the embodiment of the present invention.
[0192] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0193] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0194] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and equipment embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0195] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A data writing method, characterized in that: Applied to a resource server; the method comprises: When receiving a processing request for a target write transaction, executing the target write transaction, and during the execution of the target write transaction, writing the transaction ID of the target write transaction into the target version data, the target version data being new version data of the row record targeted by the target write transaction; When the target write transaction is executed, obtaining a commit timestamp of the target write transaction; The target version data is submitted, and a data mapping relationship corresponding to the target write transaction is generated using the submission timestamp and transaction ID of the target write transaction; Saving the data mapping relationship corresponding to the target write transaction; The memory of the resource server includes a plurality of first-category data blocks with consecutive block numbers, each of which is used to store data mapping relationships corresponding to a first number of write transactions with consecutive transaction IDs; The storing of the data mapping relationship corresponding to the target write transaction includes: Calculate, based on the transaction ID of the target write transaction and the first quantity, a first block number of a first-category data block to be written in the data mapping relationship corresponding to the target write transaction, and a first offset address when writing into the first-category data block; In the first-type data block having the first block number, the data mapping relationship corresponding to the target write transaction is stored in the storage space indicated by the first offset address.
2. The method according to claim 1, characterized in that: The memory also includes a plurality of second-category data blocks with consecutive block numbers, each of which is used to store memory addresses of a second number of first-category data blocks with consecutive block numbers; The storing, in the first type data block having the first block number, in the storage space indicated by the first offset address, a data mapping relationship corresponding to the target write transaction comprises: Based on the first block number and the second number, calculating a second block number of the second type of data block where the target memory address is located, and a second offset address of the target memory address in the second type of data block; wherein the target memory address is a memory address of the first type of data block having the first block number; Reading a memory address at the second offset address in a second type storage block having the second block number to obtain a target memory address; In the first type of data block indicated by the target memory address, the data mapping relationship corresponding to the target write transaction is stored in the storage space indicated by the first offset address.
3. The method according to claim 2, characterized in that The method further comprises: For each first-category data block, if it is detected that the number of recorded data mapping relationships in the first-category data block is equal to the first number, and the largest commit timestamp in the recorded data mapping relationships is less than the start timestamp of a pending or executed read transaction, an identification content used to characterize the recovery status is written in the storage space storing the memory address of the first-category data block.
4. A data reading method, characterized in that: Applied to a resource server; the method comprises: When a processing request for a target read transaction is received, a target transaction ID in each version data of a target row record is obtained; wherein the target row record is a row record targeted by the target read transaction; For each target transaction ID, search for a data mapping relationship corresponding to a write transaction having the target transaction ID from the pre-generated data mapping relationships corresponding to each write transaction; For each target transaction ID, if the commit timestamp in the found data mapping relationship is less than the start timestamp of the target read transaction, the version data having the target transaction ID is determined as the version data to be used; Determining a response result of the target read transaction based on the version data to be used; The memory of the resource server includes a plurality of first-category data blocks with consecutive block numbers, each of which is used to store data mapping relationships corresponding to a first number of write transactions with consecutive transaction IDs; The step of searching, for each target transaction ID, a data mapping relationship corresponding to a write transaction having the target transaction ID from pre-generated data mapping relationships corresponding to various write transactions, includes: For each target transaction ID, based on the target transaction ID and the first number, calculating a third block number of a first-type data block for storing a data mapping relationship corresponding to a target write transaction, and a third offset address of the data mapping relationship corresponding to the target write transaction when writing; wherein the target write transaction is a write transaction having the target transaction ID; In the first-category data block having the third block number, the data mapping relationship corresponding to the target write transaction is read in the storage space indicated by the third offset address.
5. The method according to claim 4, characterized in that The memory also includes a plurality of second-category data blocks with consecutive block numbers, each of which is used to store memory addresses of a second number of first-category data blocks with consecutive block numbers; In the first-category data block having the third block number, within the storage space indicated by the third offset address, reading the data mapping relationship corresponding to the target write transaction comprises: Based on the third block number and the second number, calculate a fourth block number of the second type of data block where the target memory address is located, and a fourth offset address of the target memory address in the second type of data block; wherein the target memory address is a memory address of the first type of data block having the third block number; Reading a memory address at the fourth offset address in a second-type storage block having the fourth block number to obtain a target memory address; In the first type of data block indicated by the target memory address, within the storage space indicated by the third offset address, the data mapping relationship corresponding to the target write transaction is read.
6. The method according to claim 5, characterized in that The method further comprises: If the identification content used to characterize the recycling status is marked at the fourth offset address in the second-type storage block having the fourth block number, the version data recording the target transaction ID is determined as the version data to be used.
7. A data writing device, characterized in that: Applied to a resource server; the device comprises: a first processing module, configured to execute the target write transaction upon receiving a processing request of the target write transaction, and write the transaction ID of the target write transaction into target version data during the execution of the target write transaction, wherein the target version data is new version data generated for the row record targeted by the target write transaction; A second processing module, configured to obtain a commit timestamp of the target write transaction when the target write transaction is executed; A third processing module is used to commit the executed target write transaction and generate a data mapping relationship corresponding to the target write transaction by using the commit timestamp and transaction ID of the target write transaction; The third processing module is further used to save the data mapping relationship corresponding to the target write transaction; The memory of the resource server includes a plurality of first-category data blocks with consecutive block numbers, each of which is used to store data mapping relationships corresponding to a first number of write transactions with consecutive transaction IDs; The third processing module saves the data mapping relationship corresponding to the target write transaction, including: Calculate, based on the transaction ID of the target write transaction and the first quantity, a first block number of a first-category data block to be written in the data mapping relationship corresponding to the target write transaction, and a first offset address when writing into the first-category data block; In the first-type data block having the first block number, the data mapping relationship corresponding to the target write transaction is stored in the storage space indicated by the first offset address.
8. A data reading device, characterized in that: Applied to a resource server; the device comprises: An acquisition module, configured to acquire a target transaction ID in each version data of a target row record when receiving a processing request of a target read transaction; wherein the target row record is a row record targeted by the target read transaction; A search module, used for searching, for each target transaction ID, a data mapping relationship corresponding to a write transaction having the target transaction ID from the pre-generated data mapping relationships corresponding to each write transaction; An analysis module is used for obtaining, for each target transaction ID, version data recorded with the target transaction ID as the version data to be used if, in the data mapping relationship found, the commit timestamp is less than the start timestamp of the target read transaction; A response module, used for determining a response result of the target read transaction based on the version data to be used; The memory of the resource server includes a plurality of first-category data blocks with consecutive block numbers, each of which is used to store data mapping relationships corresponding to a first number of write transactions with consecutive transaction IDs; The search module searches for a data mapping relationship corresponding to a write transaction having the target transaction ID from the pre-generated data mapping relationships corresponding to each write transaction for each target transaction ID, including: For each target transaction ID, based on the target transaction ID and the first number, calculating a third block number of a first-type data block for storing a data mapping relationship corresponding to a target write transaction, and a third offset address of the data mapping relationship corresponding to the target write transaction when writing; wherein the target write transaction is a write transaction having the target transaction ID; In the first-category data block having the third block number, the data mapping relationship corresponding to the target write transaction is read in the storage space indicated by the third offset address.
9. A resource server, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1-3 when executing a program stored in a memory, and / or implementing the method steps described in any one of claims 4-6.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 3 are implemented, and / or the method steps described in any one of claims 4 to 6 are implemented.
Citation Information
Patent Citations
Method for processing database affair, client, and server
CN107577678A
Multi-version concurrency control (MVCC) in non-volatile memory
CN109871386A
