CN111367718A - Database starting method, device, equipment and storage medium - Google Patents

Database starting method, device, equipment and storage medium Download PDF

Info

Publication number
CN111367718A
CN111367718A CN202010119144.4A CN202010119144A CN111367718A CN 111367718 A CN111367718 A CN 111367718A CN 202010119144 A CN202010119144 A CN 202010119144A CN 111367718 A CN111367718 A CN 111367718A
Authority
CN
China
Prior art keywords
transaction
rollback
page
target
management
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010119144.4A
Other languages
Chinese (zh)
Other versions
CN111367718B (en
Inventor
王海龙
王蒙蒙
韩朱忠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Dameng Database Co Ltd
Original Assignee
Shanghai Dameng Database Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Dameng Database Co Ltd filed Critical Shanghai Dameng Database Co Ltd
Priority to CN202010119144.4A priority Critical patent/CN111367718B/en
Publication of CN111367718A publication Critical patent/CN111367718A/en
Application granted granted Critical
Publication of CN111367718B publication Critical patent/CN111367718B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1415Saving, restoring, recovering or retrying at system level
    • G06F11/1438Restarting or rejuvenating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/219Managing data history or versioning
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Quality & Reliability (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to a method, a device, equipment and a storage medium for starting a database. The method comprises the following steps: when a starting instruction of the database is detected, scanning each allocated rollback management page to obtain management record information corresponding to each transaction existing when the database is abnormally closed, wherein at least one rollback management page stores the management record information corresponding to a plurality of different transactions; classifying the first target transaction corresponding to the transaction identifier according to the transaction state information aiming at each piece of management record information to obtain an active transaction and a submitted transaction in all transactions; and respectively executing the rollback operation of each active transaction according to the last rollback page address of each active transaction, and respectively executing the clearing operation of each committed transaction according to the first rollback page address of each committed transaction. The method can shorten the time for starting the database, thereby improving the speed for starting the database.

Description

Database starting method, device, equipment and storage medium
Technical Field
The present application relates to the field of database processing, and in particular, to a method, an apparatus, a device, and a storage medium for starting a database.
Background
Due to various problems possibly existing in the database operation process, the database is abnormally closed due to operation faults, and the abnormally closed database needs to be started at the moment. In the process of restarting the database after abnormal shutdown, in order to maintain the consistency of the transactions before and after the startup of the database, it is usually necessary to perform rollback operation on the active transaction existing when the database is abnormally shutdown and perform cleanup operation on the committed transaction.
In the conventional technology, a computer device needs to scan all allocated rollback pages, collect active transactions and committed transactions existing when a database is abnormally closed through record information in each rollback page, determine transaction information required for performing a rollback operation on each active transaction and transaction information required for performing a clear operation on each committed transaction in the scanning process of each rollback page, and perform the rollback operation on the active transactions and the clear operation on the committed transactions based on the collected transaction information.
However, in the case of a large number of rolled back pages, the conventional approach may result in a slow database startup.
Disclosure of Invention
Based on this, it is necessary to provide a database booting method, apparatus, device and storage medium for solving the technical problem that the conventional manner may cause a slow database booting speed.
In a first aspect, an embodiment of the present application provides a method for starting a database, including:
when a starting instruction of the database is detected, scanning each allocated rollback management page to obtain management record information corresponding to each transaction existing when the database is abnormally closed, wherein at least one rollback management page stores the management record information corresponding to a plurality of different transactions, and each management record information comprises a transaction identifier, transaction state information, a first rollback page address and a last rollback page address of a corresponding first target transaction;
classifying the first target transaction corresponding to the transaction identifier according to the transaction state information aiming at each piece of management record information to obtain an active transaction and a submitted transaction in all transactions;
and respectively executing the rollback operation of each active transaction according to the last rollback page address of each active transaction, and respectively executing the clearing operation of each committed transaction according to the first rollback page address of each committed transaction.
In a second aspect, an embodiment of the present application provides a starting apparatus for a database, including:
the management record information acquisition module is used for scanning each allocated rollback management page when a starting instruction of the database is detected, and obtaining management record information corresponding to each transaction existing when the database is abnormally closed, wherein at least one rollback management page stores the management record information corresponding to a plurality of different transactions, and each management record information comprises a transaction identifier, transaction state information, a first rollback page address and a last rollback page address of a corresponding first target transaction;
the transaction classification module is used for classifying a first target transaction corresponding to the transaction identifier according to the transaction state information aiming at each piece of management record information so as to obtain an active transaction and a submitted transaction in all transactions;
and the operation execution module is used for respectively executing the rollback operation of each active transaction according to the last rollback page address of each active transaction and respectively executing the clearing operation of each committed transaction according to the first rollback page address of each committed transaction.
In a third aspect, an embodiment of the present application provides a computer device, including a memory and a processor, where the memory stores a computer program, and the processor implements the method for starting the database provided in the first aspect of the embodiment of the present application when executing the computer program.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method for starting a database provided in the first aspect of the embodiment of the present application.
According to the starting method, the starting device, the starting equipment and the storage medium of the database, when a starting instruction of the database is detected, the computer equipment scans each allocated rollback management page to obtain the management record information corresponding to each transaction existing when the database is abnormally closed, classifies a first target transaction corresponding to the transaction identifier according to the transaction state information aiming at each management record information to obtain an active transaction and a committed transaction in all transactions, respectively executes the rollback operation of each active transaction according to the last rollback page address of each active transaction, and respectively executes the clearing operation of each committed transaction according to the first rollback page address of each committed transaction. Because at least one rollback management page stores management record information corresponding to a plurality of different transactions, and each management record information comprises a transaction identifier, transaction state information, a first rollback page address and a last rollback page address of a corresponding first target transaction, after detecting a starting instruction of the database, the computer device can obtain an active transaction which needs to be subjected to rollback operation when the database is closed and a submitted transaction which needs to be subjected to clearing operation by scanning a small number of rollback management pages, and can also obtain the last rollback page address of the active transaction and the first rollback page address of the submitted transaction.
Drawings
Fig. 1 is a schematic flowchart of a database booting method according to an embodiment of the present application;
fig. 2 is another schematic flowchart of a database starting method according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a starting apparatus of a database according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions in the embodiments of the present application are further described in detail by the following embodiments in combination with the accompanying drawings. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
It should be noted that the execution subject of the method embodiments described below may be a starting apparatus of a database, and the apparatus may be implemented as part of or all of a computer device by software, hardware, or a combination of software and hardware. The method embodiments described below are described by way of example with the execution subject being a computer device.
Fig. 1 is a schematic flowchart of a database starting method according to an embodiment of the present disclosure. The present embodiment relates to a specific process of how a computer device implements the startup of a database by scanning a rollback management page. As shown in fig. 1, the method may include:
s101, when a starting instruction of the database is detected, scanning each allocated rollback management page to obtain management record information corresponding to each transaction existing when the database is closed abnormally.
Specifically, at least one rollback management page stores management record information corresponding to a plurality of different transactions, and each management record information includes a transaction identifier, transaction state information, a first rollback page address, and a last rollback page address of a corresponding first target transaction.
The database is closed abnormally due to various faults possibly encountered in the running process of the database, and at the moment, the database is very likely to be executing various transactions during abnormal closing, wherein the transaction refers to a program execution unit which accesses and possibly updates various data items in the database, and comprises various associated data operations, so that all the contained data operations can be guaranteed to be executed or not to be executed. In addition, in order to restore the database to a state before the error occurs when the data processing has an error, the database may be preset with a rollback table space for storing rollback records corresponding to each data operation. For example, when a certain transaction is executed, the database will first allocate a corresponding storage area (i.e. a rollback page) in advance for the transaction in the rollback table space for storing a rollback record corresponding to the transaction. Meanwhile, each transaction is allocated with at least one rollback page, and the rollback page records the transaction identifier, the transaction state information and the address of the rollback page. Wherein the transaction state information includes an active state, a committed state, and a cleared state. In a conventional database reboot manner, when a database startup instruction is detected, a computer device needs to scan all allocated rollback pages to collect transaction information of each transaction existing when a database is abnormally closed. The transaction information comprises transaction identification, transaction state information, a first rollback page address and a last rollback page address. However, when there are a large number of concurrent transactions or long transactions in the database system, a large number of rollback pages are allocated, so that when the database is restarted after being abnormally closed, the number of rollback pages in the rollback table space is large, and the time spent on scanning all the allocated rollback pages is long, thereby affecting the database starting speed.
For this purpose, an independent storage space may be previously partitioned to store the transaction information of each transaction, i.e., the management record information. For example, an independent rollback management segment may be previously divided in the rollback table space to store the management record information of each transaction. The data pages in the rollback management section are called rollback management pages, and each rollback management page can store management record information corresponding to a plurality of different transactions. The number of pieces of management record information that can be stored in each rollback management page is related to the size of the rollback management page and the length of each piece of management record information, and the size of the rollback management page can be specified when the database is initialized. It is assumed that each rollback management page may store management record information corresponding to N different transactions (where N is a positive integer greater than 1), so that the management record information of the N different transactions may be collected by scanning one rollback management page. Therefore, when a starting instruction of the database is detected, the computer equipment can obtain the management record information corresponding to each transaction existing when the database is abnormally closed by scanning a small number of rollback management pages.
S102, classifying the first target transaction corresponding to the transaction identification according to the transaction state information aiming at each piece of management record information to obtain an active transaction and a submitted transaction in all transactions.
Specifically, the transaction status information in each management record information may include an active status, a committed status, or a cleared status. In this way, for each piece of management record information, the computer device classifies the first target transaction corresponding to the transaction identifier according to the transaction state information in the management record information, and obtains a corresponding classification result. After all the management record information is processed, the computer equipment can obtain the active transaction and the committed transaction in all the transactions existing at the closing time of the database. The active transaction is a transaction of which the transaction state information is in an active state, and the committed transaction is a transaction of which the transaction state information is in a committed state. Alternatively, the computer device may add all active transactions to a pre-set rollback queue and all committed transactions to a pre-set clear queue.
S103, according to the last rollback page address of each active transaction, executing the rollback operation of each active transaction respectively, and according to the first rollback page address of each committed transaction, executing the clearing operation of each committed transaction respectively.
Wherein the computer device processes a rollback operation for each active transaction in turn and a clear operation for each committed transaction in turn. Taking a target activity transaction in all activity transactions as an example to introduce a rollback process of the activity transaction, specifically: the computer equipment loads each rollback record in the last rollback page corresponding to the last rollback page address in sequence from back to front on a time axis according to the last rollback page address of the target activity transaction, and modifies the data object associated with the target activity transaction into a value before operation; after the last rollback page is completely rolled back, the computer equipment continues to load the last rollback page according to the last rollback page address recorded on the last rollback page, and executes the rollback operation of the target activity transaction according to the last rollback page until the first rollback page of the target activity transaction is completely executed, so that the rollback operation of the target activity transaction is completed. Next, taking a target committed transaction of all committed transactions as an example to describe a clearing process of the committed transaction, specifically: the computer equipment loads a first rollback page corresponding to the first rollback page address according to the first rollback page address, sequentially clears each rollback record in the first rollback page according to a sequence from front to back on a time axis, and after the rollback records of the first rollback page are cleared completely, the computer equipment continues to load a next rollback page according to a next rollback page address recorded on the first rollback page, and executes clearing operation of the target committed transaction according to the next rollback page until clearing of the last rollback page of the target committed transaction is completed, so that clearing operation of the target committed transaction is completed.
According to the starting method of the database provided by the embodiment of the application, when a starting instruction of the database is detected, the computer device scans each allocated rollback management page to obtain the management record information corresponding to each transaction existing when the database is abnormally closed, classifies the first target transaction corresponding to the transaction identifier according to the transaction state information aiming at each management record information to obtain the active transaction and the submitted transaction in all transactions, respectively executes the rollback operation of each active transaction according to the last rollback page address of each active transaction, and respectively executes the clearing operation of each submitted transaction according to the first rollback page address of each submitted transaction. Because at least one rollback management page stores management record information corresponding to a plurality of different transactions, and each management record information comprises a transaction identifier, transaction state information, a first rollback page address and a last rollback page address of a corresponding first target transaction, after detecting a starting instruction of the database, the computer device can obtain an active transaction which needs to be subjected to rollback operation when the database is closed and a submitted transaction which needs to be subjected to clearing operation by scanning a small number of rollback management pages, and can also obtain the last rollback page address of the active transaction and the first rollback page address of the submitted transaction.
In practical applications, in order to further increase the starting speed of the database, on the basis of the foregoing embodiment, optionally, the foregoing S101 may include: when a starting instruction of the database is detected, scanning first bitmap information in a first target rollback management page aiming at each allocated rollback management page, and reading effective management record information stored in the first target rollback management page according to the first bitmap information to obtain management record information corresponding to each transaction existing when the database is abnormally closed.
The first bitmap information is used to indicate whether each piece of management record information stored in the first target rollback management page is valid, that is, it can be known through the first bitmap information which management record information stored in the first target rollback management page is valid management record information and which management record information is invalid management record information. For example, the first bitmap information may indicate, by bit, whether the management record information in the corresponding position in the first target rollback management page is valid, and if the bitmap corresponding to a certain position is marked as 1, it may indicate that the management record information in the position is valid management record information, and if the bitmap is marked as 0, it may indicate that the management record information in the position is invalid management record information. Therefore, the computer device can acquire which management record information stored in which positions is valid management record information and which management record information stored in which positions is invalid management record information according to the first bitmap information by scanning the first bitmap information in the first target rollback management page, and read the valid management record information, and can acquire the management record information corresponding to each transaction existing when the database is abnormally closed after the valid management record information in all rollback management pages is read.
Optionally, the format of the rollback management page may be:
Figure BDA0002392427370000091
wherein, TS _ ID is the identification of the rollback table space to which the rollback management page belongs;
the FILE _ ID is an identifier of a FILE to which the rollback management page belongs;
page _ NO is the PAGE ID of the rollback management PAGE itself;
n _ SLOTS is the number of management record information that can be stored in the rollback management page, and can be calculated according to the size of the rollback management page and the length of the management record information;
n _ RECS is the number of the management record information actually stored in the rollback management page;
the MGR _ RECS is N _ RECS pieces of management record information actually stored in the rollback management page;
the BITMAP is BITMAP information for indicating whether each management record information is valid in the rollback management page.
In this embodiment, the computer device may further shorten the time for starting the database compared with the conventional technology by scanning the first bitmap information in the first target rollback management page and reading only the effective management record information stored in the first target rollback management page according to the first bitmap information, thereby further improving the speed for starting the database.
Next, a maintenance process of the management record information during the database operation is described, and the maintenance of the management record information may include insertion, modification, and deletion of the management record information. Introducing the insertion process of the management record information, on the basis of the foregoing embodiment, optionally, as shown in fig. 2, the method may further include:
s201, when the start of a second target transaction is detected, taking the address of a first rollback page allocated to the second target transaction for the first time as a target first rollback page address and a target last rollback page address of the second target transaction.
S202, generating first management record information corresponding to the second target transaction according to the transaction identifier of the second target transaction, the target first rollback page address, the target last rollback page address and the current state of the second target transaction. Wherein the current state is an active state.
S203, storing the first management record information in a second target rollback management page.
Specifically, when the second target transaction is started, the database may allocate a rollback page to the second target transaction, and at this time, the computer device needs to generate first management record information corresponding to the second target transaction based on an address of the allocated rollback page, a transaction identifier of the second target transaction, and a current state, and store the first management record information in the second target rollback management page. Optionally, the first management record information may further include the number of rollback pages used by the second target transaction, and at this time, in the process of generating the first management record information, the number of rollback pages used by the second target transaction may also be combined, and at this time, the number of rollback pages used by the second target transaction is 1. Meanwhile, after storing the first management record information, a bitmap flag corresponding to the first management record information in the second bitmap information stored in the second target rollback management page may also be modified to "1".
In an alternative embodiment, the format of the first management record information may be: [ TRXID, STATE, PAGES, FIRST _ FILID, FIRST _ PAGENO, LAST _ FILID, LAST _ PAGENO ].
Wherein TRXID is a transaction identifier of the second target transaction;
STATE is the current STATE of the second target transaction, including ACTIVE STATE (ACTIVE), committed STATE (COMMIT), and cleared STATE (PURGE), where the cleared STATE may indicate that the rollback record of the second target transaction has been cleared, and the management record information and the corresponding rollback page of the second target transaction may be reused by being covered;
PAGES is the number of the rollback PAGES currently used by the second target transaction;
the FIRST _ file is the identifier of the file where the FIRST rollback page of the second target transaction is located;
FIRST _ PAGENO is the page identification of the FIRST rollback page of the second target transaction;
LAST _ file is the identifier of the file where the LAST rollback page of the second target transaction is located;
LAST _ page is the page identification of the LAST rollback page of the second target transaction.
In addition, a path formed by the identifier of the file where the first rollback page of the second target transaction is located and the page identifier of the first rollback page may represent a target first rollback page address, and a path formed by the identifier of the file where the last rollback page of the second target transaction is located and the page identifier of the last rollback page may represent a target last rollback page address.
Next, referring to the modification process of the management record information, on the basis of the foregoing embodiment, optionally, the method may further include: when detecting that a second rollback page is allocated to the second target transaction, updating the target last rollback page address by using the address of the second rollback page, wherein the address of the second rollback page is different from the address of the first rollback page. Meanwhile, the number of the rollback pages used by the second target transaction in the first management record information can be modified, and the difference between the number of the rollback pages used by the second target transaction after the modification and the number of the rollback pages used by the second target transaction before the modification is 1.
There is also a case where the management record information needs to be modified when the transaction is committed. For this reason, on the basis of the above embodiment, optionally, the method may further include: and when the second target transaction is detected to be submitted, modifying the current state from an active state to a submitted state.
Next, referring to the deletion process of the management record information, on the basis of the foregoing embodiment, optionally, the method may further include: and when the rollback operation of the second target transaction is detected, deleting the first management record information from the second target rollback management page after the rollback operation is finished. Meanwhile, after the first management record information is deleted, a bitmap flag corresponding to the first management record information in the second bitmap information may also be modified to "0". For example, the above-mentioned process of deleting the first management record information may be: and modifying the transaction identifier of the second target transaction in the first management record information into 0, and modifying the current state of the second target transaction into a cleared state. And when the fact that a second target transaction is submitted and the second target transaction is cleared is detected, deleting the first management record information from the second target rollback management page after the clearing operation is finished.
In order to fully utilize the free storage location of the second target rollback management page in the process of actually storing the first management record information, on the basis of the foregoing embodiment, optionally, the foregoing S203 may include: acquiring second bitmap information in the second target rollback management page; and storing the first management record information in a storage position corresponding to invalid management record information in the second target rollback management page according to the second bitmap information.
The second bitmap information may be used to indicate whether each piece of management record information stored in the second target rollback management page is valid, that is, it may be known through the second bitmap information which management record information stored in the second target rollback management page is valid management record information and which management record information is invalid management record information. For example, the second bitmap information may indicate, by bit, whether the management record information in the corresponding position in the second target rollback management page is valid, and if the bitmap corresponding to a certain position is marked as 1, it may indicate that the management record information in the position is valid management record information, that is, the position may not be written with other management record information, and if the bitmap is marked as 0, it may indicate that the management record information in the position is invalid management record information, and the position may be written with other management record information. Therefore, the computer device can determine the storage location of the invalid management record in the second target rollback management page according to the second bitmap information, and store the first management record information in the determined storage location.
In this embodiment, the computer device may dynamically maintain the management record information corresponding to the transaction in the rollback management page based on the actual operation condition of the transaction, so that when the database is restarted, the management record information of each transaction existing when the database is closed can be collected based on the rollback management page, thereby further improving the starting speed of the database. Meanwhile, the accuracy of the transaction object aimed by the rollback operation and the clearing operation can be ensured.
Fig. 3 is a schematic structural diagram of a starting apparatus of a database according to an embodiment of the present application, and as shown in fig. 3, the apparatus may include: a management record information acquisition module 10, a transaction classification module 11 and an operation execution module 12.
Specifically, the management record information obtaining module 10 is configured to scan each allocated rollback management page when a start instruction of the database is detected, and obtain management record information corresponding to each transaction existing when the database is abnormally closed, where at least one rollback management page stores management record information corresponding to a plurality of different transactions, and each management record information includes a transaction identifier of a corresponding first target transaction, transaction state information, a first rollback page address, and a last rollback page address;
the transaction classification module 11 is configured to classify, according to the transaction state information, a first target transaction corresponding to the transaction identifier for each piece of management record information, so as to obtain an active transaction and a committed transaction among all transactions;
the operation executing module 12 is configured to execute a rollback operation of each active transaction according to the last rollback page address of each active transaction, and execute a clear operation of each committed transaction according to the first rollback page address of each committed transaction.
According to the starting device of the database provided by the embodiment of the application, when a starting instruction of the database is detected, the computer device scans each allocated rollback management page to obtain the management record information corresponding to each transaction existing when the database is abnormally closed, classifies the first target transaction corresponding to the transaction identifier according to the transaction state information aiming at each management record information so as to obtain the active transaction and the submitted transaction in all transactions, respectively executes the rollback operation of each active transaction according to the last rollback page address of each active transaction, and respectively executes the clearing operation of each submitted transaction according to the first rollback page address of each submitted transaction. Because at least one rollback management page stores management record information corresponding to a plurality of different transactions, and each management record information comprises a transaction identifier, transaction state information, a first rollback page address and a last rollback page address of a corresponding first target transaction, after detecting a starting instruction of the database, the computer device can obtain an active transaction which needs to be subjected to rollback operation when the database is closed and a submitted transaction which needs to be subjected to clearing operation by scanning a small number of rollback management pages, and can also obtain the last rollback page address of the active transaction and the first rollback page address of the submitted transaction.
On the basis of the foregoing embodiment, optionally, the management record information obtaining module 10 is specifically configured to, when a start instruction of the database is detected, scan first bitmap information in a first target rollback management page for each allocated rollback management page, and read effective management record information stored in the first target rollback management page according to the first bitmap information, so as to obtain management record information corresponding to each transaction existing when the database is abnormally closed, where the first bitmap information is used to indicate whether each management record information stored in the first target rollback management page is effective.
On the basis of the above embodiment, optionally, the apparatus may further include: the device comprises an address determining module, a management record information generating module and a management record information storage module;
specifically, the address determining module is configured to, when it is detected that a second target transaction is started, use an address of a first rollback page allocated to the second target transaction for the first time as a target first rollback page address and a target last rollback page address of the second target transaction;
the management record information generating module is used for generating first management record information corresponding to the second target transaction according to the transaction identifier of the second target transaction, the target first rollback page address, the target last rollback page address and the current state of the second target transaction, wherein the current state is an active state;
the management record information storage module is used for storing the first management record information in a second target rollback management page.
On the basis of the above embodiment, optionally, the apparatus may further include: a management record information modification module;
specifically, the management record information modifying module is configured to, when it is detected that a second rollback page is allocated to the second target transaction, update an address of a last rollback page of the target by using an address of the second rollback page, where the second rollback page is different from the first rollback page.
On the basis of the foregoing embodiment, optionally, the management record information modifying module is further configured to modify the current state from an active state to a committed state when it is detected that the second target transaction is committed;
the apparatus may further include: a management record information deleting module;
specifically, the management record information deleting module is configured to delete the first management record information from the second target rollback management page after the clearing operation is finished when it is detected that the clearing operation is performed on the second target transaction.
On the basis of the foregoing embodiment, optionally, the management record information deleting module is further configured to delete the first management record information from the second target rollback management page after the rollback operation is finished when it is detected that the rollback operation is performed on the second target transaction.
On the basis of the foregoing embodiment, optionally, the management record information storage module is specifically configured to obtain second bitmap information in the second target rollback management page; and storing the first management record information in a storage position corresponding to invalid management record information in the second target rollback management page according to the second bitmap information.
In one embodiment, a computer device is provided, a schematic structural diagram of which may be as shown in fig. 4. The computer device includes a processor and a memory connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device has stored therein a computer program. The computer program is executed by a processor to implement a method of booting a database.
Those skilled in the art will appreciate that the architecture shown in fig. 4 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, the computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the following steps when executing the computer program:
when a starting instruction of the database is detected, scanning each allocated rollback management page to obtain management record information corresponding to each transaction existing when the database is abnormally closed, wherein at least one rollback management page stores the management record information corresponding to a plurality of different transactions, and each management record information comprises a transaction identifier, transaction state information, a first rollback page address and a last rollback page address of a corresponding first target transaction;
classifying the first target transaction corresponding to the transaction identifier according to the transaction state information aiming at each piece of management record information to obtain an active transaction and a submitted transaction in all transactions;
and respectively executing the rollback operation of each active transaction according to the last rollback page address of each active transaction, and respectively executing the clearing operation of each committed transaction according to the first rollback page address of each committed transaction.
In one embodiment, the processor, when executing the computer program, further performs the steps of: when a starting instruction of a database is detected, scanning first bitmap information in a first target rollback management page aiming at each allocated rollback management page, and reading effective management record information stored in the first target rollback management page according to the first bitmap information to obtain management record information corresponding to each transaction existing when the database is abnormally closed, wherein the first bitmap information is used for indicating whether each management record information stored in the first target rollback management page is effective or not.
In one embodiment, the processor, when executing the computer program, further performs the steps of: when the starting of a second target transaction is detected, taking the address of a first rollback page allocated to the second target transaction for the first time as a target first rollback page address and a target last rollback page address of the second target transaction; generating first management record information corresponding to the second target transaction according to the transaction identifier of the second target transaction, the target first rollback page address, the target last rollback page address and the current state of the second target transaction; and storing the first management record information in a second target rollback management page, wherein the current state is an active state.
In one embodiment, the processor, when executing the computer program, further performs the steps of: when detecting that a second rollback page is allocated to the second target transaction, updating the target last rollback page address by using the address of the second rollback page, wherein the address of the second rollback page is different from the address of the first rollback page.
In one embodiment, the processor, when executing the computer program, further performs the steps of: when the second target transaction is detected to be submitted, the current state is modified from an active state to a submitted state; and when the clearing operation of the second target transaction is detected, deleting the first management record information from the second target rollback management page after the clearing operation is finished.
In one embodiment, the processor, when executing the computer program, further performs the steps of: and when the rollback operation of the second target transaction is detected, deleting the first management record information from the second target rollback management page after the rollback operation is finished.
In one embodiment, the processor, when executing the computer program, further performs the steps of: acquiring second bitmap information in the second target rollback management page; and storing the first management record information in a storage position corresponding to invalid management record information in the second target rollback management page according to the second bitmap information.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
when a starting instruction of the database is detected, scanning each allocated rollback management page to obtain management record information corresponding to each transaction existing when the database is abnormally closed, wherein at least one rollback management page stores the management record information corresponding to a plurality of different transactions, and each management record information comprises a transaction identifier, transaction state information, a first rollback page address and a last rollback page address of a corresponding first target transaction;
classifying the first target transaction corresponding to the transaction identifier according to the transaction state information aiming at each piece of management record information to obtain an active transaction and a submitted transaction in all transactions;
and respectively executing the rollback operation of each active transaction according to the last rollback page address of each active transaction, and respectively executing the clearing operation of each committed transaction according to the first rollback page address of each committed transaction.
In one embodiment, the computer program when executed by the processor further performs the steps of: when a starting instruction of a database is detected, scanning first bitmap information in a first target rollback management page aiming at each allocated rollback management page, and reading effective management record information stored in the first target rollback management page according to the first bitmap information to obtain management record information corresponding to each transaction existing when the database is abnormally closed, wherein the first bitmap information is used for indicating whether each management record information stored in the first target rollback management page is effective or not.
In one embodiment, the computer program when executed by the processor further performs the steps of: when the starting of a second target transaction is detected, taking the address of a first rollback page allocated to the second target transaction for the first time as a target first rollback page address and a target last rollback page address of the second target transaction; generating first management record information corresponding to the second target transaction according to the transaction identifier of the second target transaction, the target first rollback page address, the target last rollback page address and the current state of the second target transaction; and storing the first management record information in a second target rollback management page, wherein the current state is an active state.
In one embodiment, the computer program when executed by the processor further performs the steps of: when detecting that a second rollback page is allocated to the second target transaction, updating the target last rollback page address by using the address of the second rollback page, wherein the address of the second rollback page is different from the address of the first rollback page.
In one embodiment, the computer program when executed by the processor further performs the steps of: when the second target transaction is detected to be submitted, the current state is modified from an active state to a submitted state; and when the clearing operation of the second target transaction is detected, deleting the first management record information from the second target rollback management page after the clearing operation is finished.
In one embodiment, the computer program when executed by the processor further performs the steps of: and when the rollback operation of the second target transaction is detected, deleting the first management record information from the second target rollback management page after the rollback operation is finished.
In one embodiment, the computer program when executed by the processor further performs the steps of: acquiring second bitmap information in the second target rollback management page; and storing the first management record information in a storage position corresponding to invalid management record information in the second target rollback management page according to the second bitmap information.
The starting device, the computer device and the storage medium of the database provided in the above embodiments can execute the starting method of the database provided in any embodiment of the present application, and have corresponding functional modules and beneficial effects for executing the method. For technical details that are not described in detail in the above embodiments, reference may be made to a database booting method provided in any embodiment of the present application.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A method for starting a database, comprising:
when a starting instruction of the database is detected, scanning each allocated rollback management page to obtain management record information corresponding to each transaction existing when the database is abnormally closed, wherein at least one rollback management page stores the management record information corresponding to a plurality of different transactions, and each management record information comprises a transaction identifier, transaction state information, a first rollback page address and a last rollback page address of a corresponding first target transaction;
classifying the first target transaction corresponding to the transaction identifier according to the transaction state information aiming at each piece of management record information to obtain an active transaction and a submitted transaction in all transactions;
and respectively executing the rollback operation of each active transaction according to the last rollback page address of each active transaction, and respectively executing the clearing operation of each committed transaction according to the first rollback page address of each committed transaction.
2. The method according to claim 1, wherein when detecting a start instruction of the database, scanning each allocated rollback management page to obtain management record information corresponding to each existing transaction when the database is abnormally closed comprises:
when a starting instruction of a database is detected, scanning first bitmap information in a first target rollback management page aiming at each allocated rollback management page, and reading effective management record information stored in the first target rollback management page according to the first bitmap information to obtain management record information corresponding to each transaction existing when the database is abnormally closed, wherein the first bitmap information is used for indicating whether each management record information stored in the first target rollback management page is effective or not.
3. The method of claim 2, further comprising:
when the starting of a second target transaction is detected, taking the address of a first rollback page allocated to the second target transaction for the first time as a target first rollback page address and a target last rollback page address of the second target transaction;
generating first management record information corresponding to the second target transaction according to the transaction identifier of the second target transaction, the target first rollback page address, the target last rollback page address and the current state of the second target transaction, wherein the current state is an active state;
storing the first management record information in a second target rollback management page.
4. The method of claim 3, further comprising:
when detecting that a second rollback page is allocated to the second target transaction, updating the target last rollback page address by using the address of the second rollback page, wherein the address of the second rollback page is different from the address of the first rollback page.
5. The method of claim 3 or 4, further comprising:
when the second target transaction is detected to be submitted, the current state is modified from an active state to a submitted state;
and when the clearing operation of the second target transaction is detected, deleting the first management record information from the second target rollback management page after the clearing operation is finished.
6. The method of claim 3 or 4, further comprising:
and when the rollback operation of the second target transaction is detected, deleting the first management record information from the second target rollback management page after the rollback operation is finished.
7. The method according to claim 3, wherein said storing the first management record information in a second target rollback management page comprises:
acquiring second bitmap information in the second target rollback management page;
and storing the first management record information in a storage position corresponding to invalid management record information in the second target rollback management page according to the second bitmap information.
8. An apparatus for initiating a database, comprising:
the management record information acquisition module is used for scanning each allocated rollback management page when a starting instruction of the database is detected, and obtaining management record information corresponding to each transaction existing when the database is abnormally closed, wherein at least one rollback management page stores the management record information corresponding to a plurality of different transactions, and each management record information comprises a transaction identifier, transaction state information, a first rollback page address and a last rollback page address of a corresponding first target transaction;
the transaction classification module is used for classifying a first target transaction corresponding to the transaction identifier according to the transaction state information aiming at each piece of management record information so as to obtain an active transaction and a submitted transaction in all transactions;
and the operation execution module is used for respectively executing the rollback operation of each active transaction according to the last rollback page address of each active transaction and respectively executing the clearing operation of each committed transaction according to the first rollback page address of each committed transaction.
9. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the steps of the method of any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
CN202010119144.4A 2020-02-26 2020-02-26 Database starting method, device, equipment and storage medium Active CN111367718B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010119144.4A CN111367718B (en) 2020-02-26 2020-02-26 Database starting method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010119144.4A CN111367718B (en) 2020-02-26 2020-02-26 Database starting method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111367718A true CN111367718A (en) 2020-07-03
CN111367718B CN111367718B (en) 2023-05-02

Family

ID=71208245

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010119144.4A Active CN111367718B (en) 2020-02-26 2020-02-26 Database starting method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111367718B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116594808A (en) * 2023-04-26 2023-08-15 深圳计算科学研究院 Database rollback resource processing method, device, computer equipment and medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6651073B1 (en) * 2000-05-23 2003-11-18 International Business Machines Corporation Method and apparatus for insuring database data integrity without data recovery logging
CN101127045A (en) * 2007-09-25 2008-02-20 中兴通讯股份有限公司 Database repeatable reading implement method, device and database management system
CN110008224A (en) * 2019-03-08 2019-07-12 阿里巴巴集团控股有限公司 A kind of db transaction processing method and processing device
CN110096389A (en) * 2019-04-30 2019-08-06 上海达梦数据库有限公司 A kind of starting method, apparatus, equipment and the storage medium of database
CN110781214A (en) * 2019-09-26 2020-02-11 金蝶软件(中国)有限公司 Database reading and writing method and device, computer equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6651073B1 (en) * 2000-05-23 2003-11-18 International Business Machines Corporation Method and apparatus for insuring database data integrity without data recovery logging
CN101127045A (en) * 2007-09-25 2008-02-20 中兴通讯股份有限公司 Database repeatable reading implement method, device and database management system
CN110008224A (en) * 2019-03-08 2019-07-12 阿里巴巴集团控股有限公司 A kind of db transaction processing method and processing device
CN110096389A (en) * 2019-04-30 2019-08-06 上海达梦数据库有限公司 A kind of starting method, apparatus, equipment and the storage medium of database
CN110781214A (en) * 2019-09-26 2020-02-11 金蝶软件(中国)有限公司 Database reading and writing method and device, computer equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
范玉雷;孟小峰;: "基于相变存储器和闪存的数据库事务恢复模型" *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116594808A (en) * 2023-04-26 2023-08-15 深圳计算科学研究院 Database rollback resource processing method, device, computer equipment and medium

Also Published As

Publication number Publication date
CN111367718B (en) 2023-05-02

Similar Documents

Publication Publication Date Title
US8171257B2 (en) Determining an end of valid log in a log of write records using a next pointer and a far ahead pointer
CN111723056B (en) Small file processing method, device, equipment and storage medium
US6615364B1 (en) Computer system and methods for acquiring dump information and system recovery
CN111125040B (en) Method, device and storage medium for managing redo log
CN114706661B (en) Disaster recovery backup method and system for virtual machine, computer equipment and storage medium
CN111367718B (en) Database starting method, device, equipment and storage medium
CN108829345B (en) Data processing method of log file and terminal equipment
US10346234B2 (en) Information processing system including physical memory, flag storage unit, recording device and saving device, information processing apparatus, information processing method, and computer-readable non-transitory storage medium
US9208080B2 (en) Persistent memory garbage collection
CN113220490A (en) Transaction persistence method and system for asynchronous write-back persistent memory
CN116701246B (en) Method, device, equipment and storage medium for improving cache bandwidth
CN110928890B (en) Data storage method and device, electronic equipment and computer readable storage medium
CN111694806A (en) Transaction log caching method, device, equipment and storage medium
CN111090542A (en) Abnormal block identification method and device based on abnormal power failure and computer equipment
CN112765126A (en) Database transaction management method and device, computer equipment and storage medium
KR20070096195A (en) Transcation processing method using a ram transaction buffer
CN110096389A (en) A kind of starting method, apparatus, equipment and the storage medium of database
CN112988610A (en) Memory recovery processing method and device, computer equipment and storage medium
US10185653B2 (en) Integrated systems and methods for the transactional management of main memory and data storage
CN115657963B (en) Sequential writing method and device based on solid state disk, electronic equipment and storage medium
CN110362500B (en) Solid state disk garbage recycling method and device, solid state disk and storage medium
CN112698785B (en) Data updating method of storage device
CN110737547B (en) Method and apparatus for restoring an in-memory database using a non-volatile memory NVM
CN110888823B (en) Page scanning efficiency improving method and device and computer equipment
CN117170753A (en) Program processing method, program processing device, vehicle, and storage medium

Legal Events

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