Database storage space management method and device, equipment, medium and program product

By responding to transaction writing and transaction deletion requests in the database, and marking the status of the storage block to cover the historical version of the data, the problem that traditional databases cannot clean up historical version of the data in a timely manner is solved, and rapid storage space cleaning and database efficiency are achieved.

CN119248524AActive Publication Date: 2025-01-03JIANGSU HUAKU DATA TECH CO LTD

Patent Information

Application Number
CN202411783830.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-01-03
Estimated Expiration
2044-12-06

AI Technical Summary

Technical Problem

Traditional databases cannot clean up historical version data in a timely and quickly under the processing snapshot isolation level, resulting in storage space swelling and affecting the efficiency of the database system.

Method used

By responding to write transactions and deletion transaction requests in the database, mark the storage block status to overwrite the historical version data, and update the status after reading the transaction submission, ensuring that the data is not overwritten, and quickly clean up historical version data.

Benefits of technology

It effectively solves the problem of storage space expansion, improves the overall efficiency of the database system, and only needs to modify the memory identity when reading the transaction at the snapshot isolation level, reducing resource overhead.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248524A_ABST
    Figure CN119248524A_ABST
Patent Text Reader

Abstract

The invention provides a database storage space management method and device, equipment, a medium and a program product, which can be applied to the field of database storage management. The method comprises the following steps: in response to a processing request of a target write transaction, executing the target write transaction, covering historical version data in a target storage block with target version data, and marking the state of the target storage block as a full state; under the condition that a read scene of a snapshot isolation level exists, responding to a processing request for deleting target version data submitted by a deletion transaction, marking the state of a target storage block from a full state to an intermediate state, marking the identification of the storage block marked as the intermediate state as an idle identification in a disk, and marking the identification of the storage block marked as the intermediate state as a full identification in a memory; the target version data can be read from the target storage block, and the target version data is not covered by other write transactions; and in response to a submission request of a target read transaction of the snapshot isolation level, re-marking the state of the target storage block from the intermediate state to the idle state.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of database storage management, and more specifically to a database storage space management method, device, equipment, medium and program product. Background Art

[0002] The snapshot isolation level in the database allows transactions to access a stable version of the database. When other transactions commit to modify data, a new version of the data is written to the database and the historical version of the data is stored to ensure that it will not affect the read transaction being executed under snapshot isolation. This is very useful for queries that need to run for a long time or operations that ensure data consistency. It avoids long-term data locking and improves concurrency performance. The inventors found that, as time goes by, outdated data versions need to be cleaned up, otherwise the storage space may expand rapidly, affecting the overall efficiency of the database system. Traditional databases use a delayed background method to clean up historical versions of data, which cannot clean up historical version data in a timely and fast manner, and cannot solve the problem of storage space expansion. Summary of the invention

[0003] In view of the above problems, the present invention provides a database storage space management method, apparatus, device, medium and program product.

[0004] According to a first aspect of the present invention, a database storage space management method is provided, comprising: in response to a processing request of a target write transaction, executing the target write transaction, overwriting historical version data in a target storage block with target version data, and marking the state of the target storage block as a full state, wherein the target storage block is a storage block marked as an idle state, being marked as an idle state indicates that other version data can overwrite historical version data, the identifiers of the target storage block in the disk and in the memory are both idle identifiers, and the identifiers of the storage block marked as a full state in the disk and in the memory are both full identifiers; in the case of a read scenario with a snapshot isolation level, in response to a processing request for a delete transaction to commit the deletion of the target version data, marking the state of the target storage block from a full state to an intermediate state, the identifier of the storage block marked as an intermediate state in the disk is an idle identifier, and the identifier in the memory is a full identifier, so that the target version data can be read from the target storage block and the target version data is not overwritten by other write transactions; in response to a commit request of a target read transaction at the snapshot isolation level, re-marking the state of the target storage block from an intermediate state to an idle state.

[0005] Optionally, executing a target write transaction to overwrite historical version data in a target storage block with target version data, including: determining a target storage block based on version data identifiers corresponding to each of a plurality of storage blocks; executing a target write transaction to overwrite historical version data in a target storage block with target version data.

[0006] Optionally, determining the target storage block based on version data identifiers corresponding to each of the multiple storage blocks includes: determining the version data identifiers corresponding to each of the multiple storage blocks, wherein the version data identifier includes a version number and a timestamp; comparing the multiple version data identifiers based on preset rules to obtain a comparison result; and determining the target storage block based on the comparison result.

[0007] Optionally, before responding to a commit request of a target read transaction at a snapshot isolation level, the method further includes: responding to a read request of a target read transaction at a snapshot isolation level, wherein the read request includes a request version data identifier; determining a storage location of a target storage block from an index table according to the request version data identifier; and determining the target storage block based on the storage location so as to read the target version data in the target storage block.

[0008] Optionally, before responding to a read request of a target read transaction at a snapshot isolation level, the method further includes: when the target write transaction is executed, obtaining a commit timestamp of the target write transaction, wherein a timestamp of responding to the read request of the target read transaction is later than a commit timestamp of the target write transaction.

[0009] Optionally, in response to a deletion transaction submitting a processing request to delete the target version data, marking the state of the target storage block as an intermediate state includes: in response to a deletion transaction submitting a processing request to delete the target version data, marking the target storage block with a deletion flag, and re-marking the state of the target storage block from a full state to an intermediate state.

[0010] A second aspect of the present invention provides a database storage space management device, comprising: an overwrite module, for responding to a processing request of a target write transaction, executing the target write transaction, overwriting the historical version data in the target storage block with the target version data, and marking the state of the target storage block as a full state, wherein the target storage block is a storage block marked as an idle state, being marked as an idle state indicates that other version data can overwrite the historical version data, the identifiers of the target storage block in the disk and the memory are both idle identifiers, and the identifiers of the storage block marked as a full state in the disk and the memory are both full identifiers; a deletion module, for responding to a processing request of a delete transaction to delete the target version data in a read scenario with a snapshot isolation level, marking the state of the target storage block from a full state to an intermediate state, the identifier of the storage block marked as an intermediate state in the disk is an idle identifier, and the identifier in the memory is a full identifier, so that the target version data can be read from the target storage block and the target version data is not overwritten by other write transactions; a commit module, for responding to a commit request of a target read transaction at the snapshot isolation level, re-marking the state of the target storage block from an intermediate state to an idle state.

[0011] A third aspect of the present invention provides an electronic device, comprising: one or more processors; a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above method.

[0012] The fourth aspect of the present invention also provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the above method.

[0013] The fifth aspect of the present invention also provides a computer program product, including a computer program, which implements the above method when executed by a processor.

[0014] Optionally, by responding to a processing request of a target write transaction, executing the target write transaction, overwriting the historical version data in the target storage block with the target version data, and marking the state of the target storage block as full, in the case of a read scenario with a snapshot isolation level, in response to a processing request to submit a deletion transaction to delete the target version data, marking the state of the target storage block from a full state to an intermediate state, the target version data can be read from the storage block marked as the intermediate state and the target version data is not overwritten by other write transactions, responding to a submission request of a target read transaction at the snapshot isolation level, re-marking the state of the target storage block from the intermediate state to an idle state, and the storage block marked as idle can allow other version data to overwrite the historical version data in the storage block, thereby updating the outdated data version in the database and solving the problem of storage space expansion. By adding a new memory identifier, only the memory identifier needs to be modified at the end of the snapshot isolation level read transaction, and the resource overhead when the read transaction is submitted will not be increased too much. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The above contents and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:

[0016] Figure 1 An application scenario diagram of a database storage space management method according to an embodiment of the present invention is shown;

[0017] Figure 2 A flowchart of a database storage space management method according to an embodiment of the present invention is shown;

[0018] Figure 3 A flowchart of determining historical version data that needs to be cleaned up according to an embodiment of the present invention is shown;

[0019] Figure 4 A schematic diagram showing a database storage space management method according to an embodiment of the present invention is shown;

[0020] Figure 5 It shows a structural block diagram of a database storage space management device according to an embodiment of the present invention;

[0021] Figure 6 A block diagram of an electronic device suitable for implementing a database storage space management method according to an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0022] Below, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present invention. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of embodiments of the present invention. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of concepts of the present invention.

[0023] The terms used herein are only for describing specific embodiments and are not intended to limit the present invention. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0024] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0025] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0026] The digital age is full of data. The data comes from many sources, such as travel records, consumption records, web pages browsed, messages sent, etc. In order to facilitate the management of this data, the concept of database management system (abbreviated as: database) was born.

[0027] The snapshot isolation level in the database allows transactions to access a stable version of the database. A read transaction records a timestamp at the beginning, and it accesses the version of the data row based on this timestamp. When other transactions commit to modify data, a new version of the data is written to the database and the historical version of the data is stored. This ensures that the read transaction being executed under snapshot isolation will not be affected. This is very useful for queries that need to run for a long time or operations that ensure data consistency, because it avoids long-term data locking and improves concurrency performance. However, over time, outdated data versions need to be cleaned up, otherwise the storage space may expand rapidly, affecting the overall efficiency of the database system. Traditional databases use a delayed background method to clean up historical versions of data, which cannot clean up historical version data in a timely and fast manner, and cannot completely solve the problem of storage space expansion.

[0028] In view of this, the present invention provides a database storage space management method, device, electronic device and medium, the method comprising: in response to a processing request of a target write transaction, executing the target write transaction, overwriting the historical version data in the target storage block with the target version data, and marking the state of the target storage block as a full state, wherein the target storage block is a storage block marked as an idle state, being marked as an idle state indicates that other version data can overwrite the historical version data, the identifiers of the target storage block in the disk and the memory are both idle identifiers, and the identifiers of the storage block marked as a full state in the disk and the memory are both full identifiers; in the case of a read scenario with a snapshot isolation level, in response to a processing request for a delete transaction to submit the deletion of the target version data, marking the state of the target storage block from a full state to an intermediate state, the identifier of the storage block marked as an intermediate state in the disk is an idle identifier, and the identifier in the memory is a full identifier, so that the target version data can be read from the target storage block and the target version data is not overwritten by other write transactions; in response to a commit request of a target read transaction at the snapshot isolation level, re-marking the state of the target storage block from the intermediate state to the idle state.

[0029] In the technical solution of the present invention, the user information (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0030] Figure 1 An application scenario diagram of a database storage space management method according to an embodiment of the present invention is shown.

[0031] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.

[0032] The user can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).

[0033] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0034] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.

[0035] It should be noted that the database storage space management method provided in the embodiment of the present invention can generally be executed by the server 105. Accordingly, the database storage space management device provided in the embodiment of the present invention can generally be set in the server 105. The database storage space management method provided in the embodiment of the present invention can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Accordingly, the database storage space management device provided in the embodiment of the present invention can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105.

[0036] It should be understood that Figure 1The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0037] The following will be based on Figure 1 The scene described by Figures 2 to 4 The database storage space management method of the disclosed embodiment is described in detail.

[0038] Figure 2 A flow chart of a method for managing database storage space according to an embodiment of the present invention is shown.

[0039] like Figure 2 As shown, the database storage space management method of this embodiment includes operations S210 to S230.

[0040] In operation S210, in response to a processing request of a target write transaction, the target write transaction is executed, the target version data is overwritten with the historical version data in the target storage block, and the state of the target storage block is marked as a full state.

[0041] In operation S220 , in a read scenario with a snapshot isolation level, in response to a delete transaction submitting a processing request to delete target version data, the state of the target storage block is marked from a full state to an intermediate state.

[0042] In operation S230 , in response to a commit request of a target read transaction at the snapshot isolation level, the state of the target storage block is re-marked from an intermediate state to an idle state.

[0043] Optionally, general transaction processing includes opening a transaction, executing an operation, and committing a transaction. In response to a processing request of a target write transaction, the target write transaction may be executed, the target version data may overwrite the historical version data in the target storage block, and the state of the target storage block may be marked as full. After the target write transaction is committed, the changes to the transaction may be permanently saved.

[0044] Optionally, the database usually manages storage space with blocks as basic units. The states of these storage blocks may include a full state where data is already written and new data cannot be inserted, and an idle state where no data has been written, etc., but is not limited to this and the embodiments of the present invention do not limit this.

[0045] Optionally, in order to quickly find free storage blocks, the database generally persists the location information and status of these storage blocks on the disk in a certain data structure, which can be called disk state page information, or disk state for short. Storage block information that is deleted by a deleted transaction but may still be read by a snapshot isolation level read transaction can be recorded in the memory, which can be called memory state page information, or memory state for short. The disk state can include two flags, a free flag and a full flag. The memory state can also include two flags, a free flag and a full flag.

[0046] Optionally, the target storage block is a storage block marked as free, which indicates that other version data can overwrite historical version data. The target storage block is marked as free on disk and in memory. The target storage block is marked as full on disk and in memory.

[0047] Optionally, in a database system, snapshot isolation is a transaction isolation level that allows transactions to read consistent database snapshots rather than the latest real-time data. This isolation level can be implemented through multi-version concurrency control, so that read operations are not affected by write operation locks, thereby improving the concurrency performance of the database.

[0048] Optionally, at the snapshot isolation level, read operations in a transaction see data that already existed and was committed when the transaction started. If other transactions modify the data or commit new data during the transaction, these changes are not visible to the current transaction. This isolation level can avoid dirty reads and non-repeatable reads.

[0049] Optionally, in a read scenario with a snapshot isolation level, the state of the target storage block can be marked from a full state to an intermediate state in response to a processing request submitted by a delete transaction to delete the target version data. The storage block marked as an intermediate state is marked as free in the disk and as full in the memory, so that the target version data can be read from the target storage block and is not overwritten by other write transactions.

[0050] Optionally, the storage block is marked as free in the disk and full in the memory. This state is in response to the request to delete the target version data after the deletion transaction commits, so that the data is not overwritten by the new write transaction. When the subsequent target read transaction commits, only the mark in the memory needs to be changed, and modifying the content in the memory has less resource overhead than modifying the content in the hard disk.

[0051] Optionally, in response to a commit request of a target read transaction at the snapshot isolation level, the state of the target storage block can be re-marked from an intermediate state to an idle state. By determining whether data needs to be overwritten based on the state of the storage block, historical version data can be cleaned up in a timely and rapid manner, thereby improving the overall efficiency of the database system.

[0052] Optionally, in the absence of a snapshot isolation level read scenario, the target version data can be deleted using a delete transaction, and the data cannot be read again.

[0053] The present invention can timely and efficiently release the data space storing the historical version of data when the read transaction at the snapshot isolation level ends, thereby avoiding disk expansion.

[0054] Optionally, by responding to a processing request of a target write transaction, executing the target write transaction, overwriting the historical version data in the target storage block with the target version data, and marking the state of the target storage block as full, in the case of a read scenario with a snapshot isolation level, in response to a processing request to submit a deletion transaction to delete the target version data, marking the state of the target storage block from a full state to an intermediate state, the target version data can be read from the storage block marked as the intermediate state and the target version data is not overwritten by other write transactions, responding to a submission request of a target read transaction at the snapshot isolation level, re-marking the state of the target storage block from the intermediate state to an idle state, and the storage block marked as idle can allow other version data to overwrite the historical version data in the storage block, thereby updating the outdated data version in the database and solving the problem of storage space expansion. By adding a new memory identifier, only the memory identifier needs to be modified at the end of the snapshot isolation level read transaction, and the resource overhead when the read transaction is submitted will not be increased too much.

[0055] Optionally, executing a target write transaction to overwrite historical version data in a target storage block with target version data, including: determining a target storage block based on version data identifiers corresponding to each of a plurality of storage blocks; executing a target write transaction to overwrite historical version data in a target storage block with target version data.

[0056] Optionally, each storage block has a unique corresponding version data identifier, and based on the version data identifiers corresponding to the multiple storage blocks, the target storage block can be determined, and the target write transaction can be executed, and the target version data can overwrite the historical version data that needs to be processed in a timely manner. The version data identifier may include the version number of the data, the timestamp of updating the storage block, the checksum, etc., but is not limited to this, and the embodiments of the present invention do not limit this.

[0057] Optionally, the target version data can be used to overwrite the older historical version data in time according to the version data identifier, to complete the cleaning of the historical version data and solve the storage space collision problem. The corresponding historical version data can also be replaced according to the specified version data identifier.

[0058] Figure 3 A flow chart for determining historical version data that needs to be cleaned up according to an embodiment of the present invention is shown.

[0059] like Figure 3 As shown, the method for determining historical version data that needs to be cleaned up in this embodiment includes operations S310 to S330.

[0060] In operation S310, version data identifiers corresponding to each of a plurality of storage blocks are determined, wherein the version data identifier includes a version number and a timestamp.

[0061] In operation S320, multiple version data identifiers are compared based on a preset rule to obtain a comparison result.

[0062] In operation S330, a target memory block is determined according to the comparison result.

[0063] Optionally, the version data identifiers corresponding to each of the multiple storage blocks can be determined. Version data identifiers are used to ensure data consistency and system stability. They allow developers to track and manage changes to database objects. Version data identifiers can include timestamps, version numbers, etc. Timestamps can identify the specific date and time when data or objects were last modified. Version numbers consist of a set of numbers, sometimes including build numbers, etc.

[0064] Optionally, multiple version data identifiers can be compared based on preset rules to obtain a comparison result. In the case where the version data identifier is a version number, the preset rule can be set to replace the smallest version number in the storage block. Multiple version numbers are compared to obtain the storage block with the smallest version number, and the storage block with the smallest version number is determined as the target storage block. In the case where the version data identifier is a timestamp, the specific date or time when the multiple storage blocks were last modified can be determined, and multiple timestamps are compared to obtain the earliest timestamp, and the storage block corresponding to the earliest timestamp is determined as the target storage block.

[0065] Optionally, a storage block can be specifically specified according to the version data identifier. For example, the version data identifier is the version number, and there are 3 storage blocks, which store 3 different version data, representing the first-generation version data No. 1, the second-generation version data No. 2, and the third-generation version data No. 3. The fourth-generation version data has been developed, and the second-generation version data needs to be deleted. It can be determined that the version number of the second-generation version data is No. 2, and the target write transaction is executed to overwrite the second-generation version data with version number No. 2 with the fourth-generation version data.

[0066] Optionally, before responding to a commit request of a target read transaction at a snapshot isolation level, the method further includes: responding to a read request of a target read transaction at a snapshot isolation level, wherein the read request includes a request version data identifier; determining a storage location of a target storage block from an index table according to the request version data identifier; and determining the target storage block based on the storage location so as to read the target version data in the target storage block.

[0067] Optionally, a read request of a target read transaction at a snapshot isolation level can be responded to, wherein the read request includes a request version data identifier; a storage location of a target storage block can be determined from an index table according to the request version data identifier, and the target storage block can be determined based on the storage location so as to read the target version data in the target storage block.

[0068] Optionally, the location information of the page to be read may be determined from the index table according to the version data identifier, thereby reading the target version data in the page.

[0069] Optionally, before responding to a read request of a target read transaction at a snapshot isolation level, the method further includes: when the target write transaction is executed, obtaining a commit timestamp of the target write transaction, wherein a timestamp of responding to the read request of the target read transaction is later than a commit timestamp of the target write transaction.

[0070] Optionally, when the target write transaction is executed, the commit timestamp of the target write transaction can be obtained, wherein the read request timestamp of the target read transaction is later than the commit timestamp of the target write transaction. For example, the request processing timestamp of the target write transaction is 8:30, and the commit timestamp of the target write transaction is 16:50. If the read request timestamp of the target read transaction is 15:00, because the target write transaction has not been committed and the transaction has not been completed, at this time, the read data may report an error or show that the target read transaction has not queried relevant data. Therefore, it is necessary to ensure that the read request timestamp of the target read transaction is later than the commit timestamp of the target write transaction.

[0071] Optionally, if the system is restarted before the target read transaction is committed, the disk state of the page after the restart becomes idle, and there is no memory state page information at this time. It defaults to idle state, and there is no need to restart again. The startup task sets the memory state to idle state again.

[0072] Optionally, it may be determined that the read request timestamp of the target read transaction is later than the commit timestamp of the target write transaction, so as to avoid errors in reading data when the data has not been committed.

[0073] Optionally, in response to a deletion transaction submitting a processing request to delete the target version data, marking the state of the target storage block as an intermediate state includes: in response to a deletion transaction submitting a processing request to delete the target version data, marking the target storage block with a deletion flag, and re-marking the state of the target storage block from a full state to an intermediate state.

[0074] Optionally, in response to a deletion transaction submitting a processing request to delete the target version data, the target storage block may be marked with a deletion flag, and the state of the target storage block may be re-marked from a full state to an intermediate state.

[0075] Optionally, even if the page is marked as a deleted page, the data is still stored in the page, and the page can still be read using a read transaction without having to search in the database log, which speeds up the search efficiency.

[0076] Figure 4 A schematic diagram of a database storage space management method according to an embodiment of the present invention is shown.

[0077] like Figure 4 As shown, the storage block includes three states, an idle state 410 , a full state 420 , and an intermediate state 430 .

[0078] Optionally, a new database instance can be created, and the system can allocate a portion of free storage blocks to the instance for storing data. In this case, the storage blocks are marked as free state 410, and the identifiers of the storage blocks in the disk and memory are both free identifiers. To execute the target write transaction 1, the status information of the storage blocks can be traversed first. The status of storage block 1 is free state 410, and the target version data can be written to storage block 1. At this time, the status of storage block 1 is set from free state 410 to full state 420, and the identifiers of the storage blocks marked as full state 420 in the disk and memory are both full identifiers.

[0079] Optionally, the target read transaction 1 starts the snapshot isolation level reading, starts the target read transaction 1, and the target read transaction 1 can read the data in the storage block 1. In the case of a read scenario with a snapshot isolation level, in response to the deletion transaction submitting a processing request to delete the data in the storage block 1, the state of the storage block 1 is marked from the full state 420 to the intermediate state 430. At this time, the deletion transaction still saves the data in the storage block 1, and the storage block marked as the intermediate state 430 is marked as a free mark in the disk and a full mark in the memory. At this time, the target read transaction 1 can still read the data in the storage block 1.

[0080] Optionally, in response to the processing request of the target write transaction 2, the status information of the storage blocks can be traversed first. If it is found that the status information of the storage block 1 is the intermediate state 430, it is necessary to skip the storage block 1 and continue to look for the storage block in the idle state 410. After finding the storage block 2 in the idle state 410, the target write transaction 2 is executed to write the corresponding data into the storage block 2.

[0081] Optionally, in response to a commit request of the target read transaction 1, the target read transaction 1 is committed, and the state of the storage block 1 is changed from the intermediate state 430 to the idle state 410, at which point the storage block 1 can be written with other data by a new transaction.

[0082] Optionally, when the storage block is in full state 420 and there is no read scenario at the snapshot isolation level, a delete transaction occurs, and the data in the storage block is deleted and cannot be read again.

[0083] Based on the above database storage space management method, the present invention also provides a database storage space management device. Figure 5 The device is described in detail.

[0084] Figure 5 A structural block diagram of a database storage space management device according to an embodiment of the present invention is shown.

[0085] like Figure 5 As shown, the database storage space management device 500 of this embodiment includes: an overwriting module 510 , a deleting module 520 and a submitting module 530 .

[0086] The overwrite module 510 is used to respond to the processing request of the target write transaction, execute the target write transaction, overwrite the historical version data in the target storage block with the target version data, and mark the state of the target storage block as a full state, wherein the target storage block is a storage block marked as an idle state, and being marked as an idle state indicates that other version data can overwrite the historical version data, the identifiers of the target storage block in the disk and the memory are both idle identifiers, and the identifiers of the storage block marked as a full state in the disk and the memory are both full identifiers.

[0087] The deletion module 520 is used to, in a read scenario with a snapshot isolation level, mark the state of the target storage block from a full state to an intermediate state in response to a processing request for deleting the target version data submitted by a deletion transaction, and mark the storage block marked as the intermediate state as a free mark in the disk and as a full mark in the memory, so that the target version data can be read from the target storage block and the target version data is not overwritten by other write transactions.

[0088] The commit module 530 is used to re-mark the state of the target storage block from the intermediate state to the idle state in response to the commit request of the target read transaction at the snapshot isolation level.

[0089] Optionally, by responding to a processing request of a target write transaction, executing the target write transaction, overwriting the historical version data in the target storage block with the target version data, and marking the state of the target storage block as full, in the case of a read scenario with a snapshot isolation level, in response to a processing request to submit a deletion transaction to delete the target version data, marking the state of the target storage block from a full state to an intermediate state, the target version data can be read from the storage block marked as the intermediate state and the target version data is not overwritten by other write transactions, responding to a submission request of a target read transaction at the snapshot isolation level, re-marking the state of the target storage block from the intermediate state to an idle state, and the storage block marked as idle can allow other version data to overwrite the historical version data in the storage block, thereby updating the outdated data version in the database and solving the problem of storage space expansion. By adding a new memory identifier, only the memory identifier needs to be modified at the end of the snapshot isolation level read transaction, and the resource overhead when the read transaction is submitted will not be increased too much.

[0090] Optionally, the overwriting module includes: a target storage block determination unit and a historical version data overwriting unit.

[0091] The target storage block determination unit is used to determine the target storage block based on the version data identifiers corresponding to each of the plurality of storage blocks.

[0092] The historical version data overwriting unit is used to execute a target write transaction to overwrite the historical version data in the target storage block with the target version data.

[0093] Optionally, the target storage block determination unit includes: a version data identification determination subunit, a comparison subunit and a target storage block determination subunit.

[0094] The version data identifier determining subunit is used to determine the version data identifiers corresponding to each of the plurality of storage blocks, wherein the version data identifier includes a version number and a timestamp.

[0095] The comparison subunit is used to compare multiple version data identifiers based on preset rules to obtain a comparison result.

[0096] The target storage block determination subunit is used to determine the target storage block according to the comparison result.

[0097] Optionally, the database storage space management device 500 of this embodiment further includes: a read request response module, a storage location determination module and a target storage block module.

[0098] The read request response module is used to respond to a read request of a target read transaction at a snapshot isolation level, wherein the read request includes a request version data identifier.

[0099] The storage location determination module is used to determine the storage location of the target storage block from the index table according to the request version data identifier.

[0100] The target storage block module is used to determine the target storage block based on the storage position so as to read the target version data in the target storage block.

[0101] Optionally, the database storage space management device 500 of this embodiment further includes: a submission timestamp acquisition module.

[0102] The commit timestamp acquisition module is used to acquire the commit timestamp of the target write transaction when the target write transaction is executed, wherein the read request timestamp in response to the target read transaction is later than the commit timestamp of the target write transaction.

[0103] Optionally, the deletion module includes: a mark deletion unit.

[0104] The marking deletion unit is used to mark the target storage block with a deletion identifier in response to a processing request for deleting the target version data submitted by the deletion transaction, and to re-mark the state of the target storage block from a full state to an intermediate state.

[0105] Optionally, any multiple modules among the overlay module 510, the deletion module 520 and the submission module 530 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. Optionally, at least one of the overlay module 510, the deletion module 520 and the submission module 530 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in any appropriate combination of any of them. Or at least one of the overlay module 510, the deletion module 520 and the submission module 530 can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be performed.

[0106] Figure 6 A block diagram of an electronic device suitable for implementing a database storage space management method according to an embodiment of the present invention is shown.

[0107] like Figure 6 As shown, the electronic device 600 according to an embodiment of the present invention includes a processor 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 to a random access memory (RAM) 603. The processor 601 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include an onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.

[0108] In RAM 603, various programs and data required for the operation of electronic device 600 are stored. Processor 601, ROM 602 and RAM 603 are connected to each other via bus 604. Processor 601 performs various operations of the method flow according to the embodiment of the present invention by executing the program in ROM 602 and / or RAM 603. It should be noted that the program can also be stored in one or more memories other than ROM 602 and RAM 603. Processor 601 can also perform various operations of the method flow according to the embodiment of the present invention by executing the program stored in the one or more memories.

[0109] Optionally, the electronic device 600 may further include an input / output (I / O) interface 605, which is also connected to the bus 604. The electronic device 600 may further include one or more of the following components connected to the I / O interface 605: an input portion 606 including a keyboard, a mouse, etc.; an output portion 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 608 including a hard disk, etc.; and a communication portion 609 including a network interface card such as a LAN card, a modem, etc. The communication portion 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage portion 608 as needed.

[0110] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiment; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present invention is implemented.

[0111] Optionally, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, optionally, the computer-readable storage medium may include the ROM 602 and / or RAM 603 described above and / or one or more memories other than ROM 602 and RAM 603.

[0112] The embodiment of the present invention also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the database storage space management method provided by the embodiment of the present invention.

[0113] The computer program executes the above functions defined in the system / device of the embodiment of the present invention when it is executed by the processor 601. Optionally, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0114] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 609, and / or installed from a removable medium 611. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0115] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the processor 601, the above functions defined in the system of the embodiment of the present invention are performed. Optionally, the system, device, apparatus, module, unit, etc. described above can be implemented by a computer program module.

[0116] Optionally, the program code for executing the computer program provided by the embodiment of the present invention can be written in any combination of one or more programming languages, specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, such as Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).

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

[0118] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present invention may be combined and / or coupled in various ways, even if such combinations and / or couplings are not explicitly described in the present invention. In particular, the features described in the various embodiments and / or claims of the present invention may be combined and / or coupled in various ways without departing from the spirit and teachings of the present invention. All of these combinations and / or couplings fall within the scope of the present invention.

[0119] The embodiments of the present invention are described above. However, these embodiments are only for the purpose of illustration, and are not intended to limit the scope of the present invention. Although each embodiment is described above, it does not mean that the measures in each embodiment cannot be used in combination advantageously. Without departing from the scope of the present invention, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present invention.

Claims

1. A database storage space management method, characterized in that: The method comprises: In response to a processing request of a target write transaction, the target write transaction is executed, the target version data is overwritten with the historical version data in the target storage block, and the state of the target storage block is marked as a full state, wherein the target storage block is a storage block marked as an idle state, the marked as an idle state indicates that other version data can overwrite the historical version data, the identifiers of the target storage block in the disk and the memory are both idle identifiers, and the identifiers of the storage block marked as the full state in the disk and the memory are both full identifiers; In a read scenario with a snapshot isolation level, in response to a deletion transaction submitting a processing request to delete the target version data, marking the state of the target storage block from the full state to an intermediate state, wherein the storage block marked as the intermediate state is marked as a free mark in the disk and as a full mark in the memory, so that the target version data can be read from the target storage block and the target version data is not overwritten by other write transactions; In response to a commit request of the target read transaction at the snapshot isolation level, the state of the target storage block is re-marked from the intermediate state to the idle state.

2. The method according to claim 1, characterized in that The executing the target write transaction to overwrite the historical version data in the target storage block with the target version data includes: Determine a target storage block based on version data identifiers corresponding to each of the plurality of storage blocks; The target write transaction is executed to overwrite the historical version data in the target storage block with the target version data.

3. The method according to claim 2, characterized in that The determining of the target storage block based on the version data identifiers corresponding to the plurality of storage blocks includes: Determine a version data identifier corresponding to each of the plurality of storage blocks, wherein the version data identifier includes a version number and a timestamp; Compare the multiple version data identifiers based on preset rules to obtain a comparison result; According to the comparison result, a target storage block is determined.

4. The method according to claim 2, characterized in that: Before responding to a commit request of the target read transaction at the snapshot isolation level, the method further includes: Responding to a read request of a target read transaction at the snapshot isolation level, wherein the read request includes a request version data identifier; Determining a storage location of the target storage block from an index table according to the requested version data identifier; The target storage block is determined based on the storage location so as to read the target version data in the target storage block.

5. The method according to claim 4, characterized in that Before responding to a read request of a target read transaction at the snapshot isolation level, the method further includes: When the target write transaction is executed completely, a commit timestamp of the target write transaction is obtained, wherein a read request timestamp in response to the target read transaction is later than the commit timestamp of the target write transaction.

6. The method according to claim 1, characterized in that The step of marking the state of the target storage block as an intermediate state in response to the deletion transaction submitting the processing request to delete the target version data comprises: In response to the deletion transaction submitting a processing request to delete the target version data, the target storage block is marked with a deletion identifier, and the state of the target storage block is re-marked from the full state to the intermediate state.

7. A database storage space management device, characterized in that: The device comprises: an overwriting module, configured to respond to a processing request of a target write transaction, execute the target write transaction, overwrite the historical version data in the target storage block with the target version data, and mark the state of the target storage block as a full state, wherein the target storage block is a storage block marked as an idle state, the idle state indicates that other version data can overwrite the historical version data, the identifiers of the target storage block in the disk and the memory are both idle identifiers, and the identifiers of the storage block marked as the full state in the disk and the memory are both full identifiers; a deletion module, configured to, in a read scenario with a snapshot isolation level, mark the state of the target storage block from the full state to the intermediate state in response to a deletion transaction submitting a processing request to delete the target version data, wherein the storage block marked as the intermediate state is marked as a free mark in the disk and as a full mark in the memory, so that the target version data can be read from the target storage block and the target version data is not overwritten by other write transactions; The commit module is used to re-mark the state of the target storage block from the intermediate state to the idle state in response to a commit request of the target read transaction at the snapshot isolation level.

8. An electronic device, characterized in that: include: one or more processors; a memory for storing one or more computer programs, It is characterized in that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

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

Citation Information

Patent Citations

  • Transaction concurrency control method and device, terminal equipment and medium

    CN111090663A

  • Data writing method and device, data reading method and device and server

    CN112231070A

  • Asynchronous write-back persistent memory transaction persistence method and system

    CN113220490A

  • Database transaction management method and device and database transaction recovery method and device

    CN113986974A

Cited By

  • Data processing method, computing device, storage medium and computer program product

    CN120045524A