US20180203888A1 - Multi-Version Concurrency Control Method in Database and Database System - Google Patents

Multi-Version Concurrency Control Method in Database and Database System Download PDF

Info

Publication number
US20180203888A1
US20180203888A1 US15/919,469 US201815919469A US2018203888A1 US 20180203888 A1 US20180203888 A1 US 20180203888A1 US 201815919469 A US201815919469 A US 201815919469A US 2018203888 A1 US2018203888 A1 US 2018203888A1
Authority
US
United States
Prior art keywords
page
record
transaction
version
timestamp
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.)
Abandoned
Application number
US15/919,469
Inventor
Jijun Wen
Yuanyuan Nie
Jian Li
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.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies 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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to US15/919,469 priority Critical patent/US20180203888A1/en
Assigned to HUAWEI TECHNOLOGIES CO., LTD. reassignment HUAWEI TECHNOLOGIES CO., LTD. ASSIGNMENT OF ASSIGNORS INTEREST (SEE DOCUMENT FOR DETAILS). Assignors: LI, JIAN, NIE, Yuanyuan, WEN, Jijun
Publication of US20180203888A1 publication Critical patent/US20180203888A1/en
Abandoned legal-status Critical Current

Links

Images

Classifications

    • G06F17/30353
    • 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/23Updating
    • G06F16/2308Concurrency control
    • G06F16/2315Optimistic concurrency control
    • G06F16/2322Optimistic concurrency control using timestamps
    • 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/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • G06F11/1469Backup restoration techniques
    • 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/23Updating
    • G06F16/2308Concurrency control
    • G06F16/2315Optimistic concurrency control
    • G06F16/2329Optimistic concurrency control using versioning
    • 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/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • G06F17/30356
    • G06F17/30371
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/84Using snapshots, i.e. a logical point-in-time copy of the data

Definitions

  • the present disclosure relates to the field of database technologies, and in particular, to a multi-version concurrency control (MVCC) method in a database and a database system.
  • MVCC multi-version concurrency control
  • MVCC is a locking mechanism widely used in a database system. This mechanism is used in current mainstream business database systems such as an Oracle database (a database developed by ORACLE), a structured query language server (SQL SERVER) database, and a PostgreSQL database.
  • Oracle database a database developed by ORACLE
  • SQL SERVER structured query language server
  • PostgreSQL database a PostgreSQL database.
  • a MVCC scheme includes two implementation types, one is a page-level multi-version type, and the other is a row-level multi-version type.
  • the page-level multi-version indicates that a timestamp is recorded and modified on a page, and the page needs to be accessed according to the timestamp. If the timestamp does not meet a requirement, a proper page version needs to be constructed. In this way, a same page may correspond to a plurality of different versions in a database.
  • the row-level multi-version indicates that a new version is generated whenever a record is updated. In this way, a read operation and a write operation on a same record may access different versions of the record such that reading and writing are not blocked.
  • the inventor of the present disclosure discovers that, when a version page obtained is read, the page needs to be read according to information about all transactions on the page. If there are many transactions on the page, efficiency of reading the data page is not high, and the reading is inconvenient.
  • Embodiments of the present disclosure provide a MVCC method in a database and a database system, which facilitates queries for data on each version page in the database.
  • a first aspect of the embodiments of the present disclosure provides a MVCC method in a database, including receiving a data reading request generated by a read transaction, where the data reading request is used to request to read a page in the database and the data reading request includes a timestamp of the read transaction, reading the current version page of the page that is requested to read by the data reading request if a timestamp of a current version page of the page that is requested to read by the data reading request is less than or equal to the timestamp of the read transaction, and performing page-level rollback using a page pointer of the current version page in a data page link of the page that is requested to read in order to roll back the current version page to a version page, a timestamp of which is less than or equal to the timestamp of the read transaction if the timestamp of the current version page is greater than the timestamp of the read transaction, where the data page link includes a page pointer of each version page of the page that is requested to read, and the page pointer of each version page is
  • the method further includes performing row-level rollback according to a record pointer of the one or more records included in a record link of the page that is requested to read in order to roll back the record in the operating state to a record prior to an operation if one or more records on the version page obtained after the page-level rollback are in an operating state at a moment indicated by the timestamp of the version page obtained after the page-level rollback, where the record link includes a record pointer of a record included in each version page of the page that is requested to read, and a record pointer of a record on a version page is used to point to a previous version record of the record.
  • the method further includes receiving a data writing operation request generated by a write operation transaction, where the data writing operation request is used to request to perform a write operation on a page in the database and the data writing operation request includes a timestamp of the write operation transaction, reading a first version page of the page requested by the data writing operation request, and performing a write operation on the first version page according to the data writing operation request to obtain a second version page, where the first version page is a latest version page of the page that is requested by the data writing operation request and stored in the database before the write operation is performed, setting a timestamp of the second version page according to the timestamp of the write operation transaction, updating a transaction link in the database such that the transaction link includes an operation transaction pointer of the write operation transaction, where the transaction link includes a plurality of operation transaction pointers of a record on the page in the database
  • performing a write operation on the first version page according to the data writing operation request to obtain a second version page further includes inserting, on the first version page, the record that is requested to insert by the data writing operation request to obtain the second version page when the data writing operation request is a data writing operation request that requests to insert a record, and storing the first version page and the second version page.
  • Setting rollback information of the second version page further includes setting a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, and setting a record pointer of the second version page such that a record pointer of the inserted record on the second version page is used to point to a rollback record corresponding to the inserted record, where the rollback record includes information that the record that is requested to insert by the data writing operation request has been deleted from the first version page, and updating a transaction link of the database further includes setting a transaction identifier of the write operation transaction of inserting the record on the first version page, and setting an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of inserting the record on the first version page.
  • performing a write operation on the first version page according to the data writing operation request to obtain a second version page further includes marking, on the first version page, the record that is requested to delete by the data writing operation request as deleted to obtain the second version page when the data writing operation request is a data writing operation request that requests to delete a record, and storing the first version page and the second version page.
  • Setting rollback information of the second version page further includes setting a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, and setting a record pointer of the second version page such that a record pointer of a record marked as deleted on the second version page is used to point to the record that is requested to delete by the data writing operation request from the first version page, and updating a transaction link of the database further includes setting a transaction identifier corresponding to the write operation transaction of deleting the record, and setting an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer points to a transaction identifier of a previous operation of the write operation transaction of deleting the record.
  • performing a write operation on the first version page according to the data writing operation request to obtain a second version page further includes updating the corresponding record on the first version page according to an indication of the data writing operation request to obtain the second version page when the data writing operation request is a data writing operation request that requests to update a record, and storing the first version page and the second version page
  • the setting a timestamp of the second version page according to the timestamp of the write operation transaction further includes setting the timestamp of the second version page to the timestamp of the write operation transaction.
  • Setting rollback information of the second version page further includes setting a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, and setting a record pointer of the second version page such that a record pointer of an updated record on the second version page is used to point to the record prior to the update on the first version page, and updating a transaction link of the database further includes setting a transaction identifier corresponding to the write operation transaction of updating the record, and setting an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of updating the record.
  • setting a timestamp of the second version page according to the timestamp of the write operation transaction further includes using the timestamp of the first version page as the timestamp of the second version page if a timestamp of the first version page is greater than the timestamp of the write operation transaction, and setting the timestamp of the second version page to the timestamp of the write operation transaction if the timestamp of the first version page is less than the timestamp of the write operation transaction.
  • a second aspect of the embodiments of the present disclosure provides a database system, including a read receiving unit configured to receive a data reading request generated by a read transaction, where the data reading request is used to request to read a page in the database and the data reading request includes a timestamp of the read transaction, a reading unit configured to read the current version page of the page that is requested to read by the data reading request if a timestamp of a current version page of the page that is requested to read by the data reading request received by the read receiving unit is less than or equal to the timestamp of the read transaction, and a page-level rollback unit configured to perform page-level rollback using a page pointer of the current version page in a data page link of the page that is requested to read in order to roll back the current version page to a version page, a timestamp of which is less than or equal to the timestamp of the read transaction if the timestamp of the current version page is greater than the timestamp of the read transaction, where the data page link includes a page pointer
  • the database system further includes a row-level rollback unit configured to perform row-level rollback according to a record pointer of the one or more records included in a record link of the page that is requested to read in order to roll back the record in the operating state to a record prior to an operation if one or more records on the version page obtained after the page-level rollback unit performs the page-level rollback are in an operating state at a moment indicated by the timestamp of the version page obtained after the page-level rollback, where the record link includes a record pointer of a record included in each version page of the page that is requested to read, and a record pointer of a record on a version page is used to point to a previous version record of the record.
  • the database system further includes a write operation receiving unit configured to receive a data writing operation request generated by a write operation transaction, where the data writing operation request is used to request to perform a write operation on a page in the database and the data writing operation request includes a timestamp of the write operation transaction, a write operation unit configured to read a first version page corresponding to the data writing operation request, and perform the write operation on the first version page according to the data writing operation request to obtain a second version page, where the first version page is a latest version page of the page that is requested by the data writing operation request and stored in the database before the write operation is performed, a timestamp setting unit configured to set a timestamp of the second version page according to the timestamp of the write operation transaction, and a rollback setting unit configured to update a transaction link in the database such that the transaction link includes an operation transaction point
  • the write operation unit is further configured to insert, on the first version page, the record that is requested to insert by the data writing operation request to obtain the second version page when the data writing operation request received by the write operation receiving unit is a data writing operation request that requests to insert a record on the first version page, and store the first version page and the second version page
  • the rollback setting unit further includes a data page link setting unit configured to set a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, a record link setting unit configured to set a record pointer of the second version page such that a record pointer of the inserted record on the second version page is used to point to a rollback record corresponding to the inserted record, where the rollback record includes information that the record that is requested to insert by the data writing operation request has been deleted from the first version page, and
  • the write operation unit is further configured to mark, on the first version page, the record that is requested to delete by the data writing operation request as deleted to obtain the second version page when the data writing operation request received by the write operation receiving unit is a data writing operation request that requests to delete a record from the first version page, and store the first version page and the second version page, and the data page link setting unit is further configured to set a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page.
  • the record link setting unit is further configured to set a record pointer of the second version page such that a record pointer of a record marked as deleted on the second version page is used to point to the record that is requested to delete by the data writing operation request from the first version page
  • the transaction link setting unit is further configured to set a transaction identifier corresponding to the write operation transaction of deleting the record, and set an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of deleting the record.
  • the write operation unit is further configured to update the corresponding record on the first version page according to an indication of the data writing operation request to obtain the second version page when the data writing operation request received by the write operation receiving unit is a data writing operation request that requests to update a record on the first version page, and store the first version page and the second version page
  • the data page link setting unit is further configured to set a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page
  • the record link setting unit is further configured to set a record pointer of the second version page such that a record pointer of an updated record on the second version page is used to point to the record prior to the update on the first version page
  • the transaction link setting unit is further configured to set a transaction identifier corresponding to the write operation transaction of updating the record, and set an operation transaction pointer corresponding to the
  • the timestamp setting unit is further configured to use the timestamp of the first version page as the timestamp of the second version page if a timestamp of the first version page is greater than the timestamp of the write operation transaction, and set the timestamp of the second version page to the timestamp of the write operation transaction if the timestamp of the first version page is less than the timestamp of the write operation transaction.
  • a database system sets a data page link of a page, where the data page link includes a page pointer of each version page of the page, and a page pointer of a version page is used to point to another version page prior to a last operation on the version page, that is, a previous version page.
  • page-level rollback may be performed directly according to a data page link of the page that is requested to read to roll back to a version page that needs to be read, which helps a user to know a page in the database at any time, that is, which facilitates queries for data on each version page in the database.
  • the database system may further roll back, in combination with a record link, a record in an operating state on a version page obtained after the page-level rollback to a record prior to modification such that the record rollback can be implemented efficiently by combining the data page link and the record link, thereby realizing consistent reading.
  • FIG. 1 is a flowchart of a MVCC method in a database according to an embodiment of the present disclosure
  • FIG. 2 is a flowchart of another MVCC method in a database according to an embodiment of the present disclosure
  • FIG. 3 is a flowchart of another MVCC method in a database according to an embodiment of the present disclosure
  • FIG. 4 is a schematic diagram of reading a page by a database system according to an embodiment of the present disclosure
  • FIG. 5 is a schematic diagram of inserting a record on a page by a database system according to an embodiment of the present disclosure
  • FIG. 6 is a schematic diagram of deleting a record from a page by a database system according to an embodiment of the present disclosure
  • FIG. 7 is a schematic structural diagram of a database system according to an embodiment of the present disclosure.
  • FIG. 8 is a schematic structural diagram of another database system according to an embodiment of the present disclosure.
  • FIG. 9 is a schematic structural diagram of another database system according to an embodiment of the present disclosure.
  • FIG. 10 is a schematic structural diagram of another database system according to an embodiment of the present disclosure.
  • An embodiment of the present disclosure provides a MVCC method in a database, where the method is mainly executed by a database system, for example, a distributed magnetic disk database system, a cluster database system, or a massively parallel processing (MPP) database system.
  • a database system for example, a distributed magnetic disk database system, a cluster database system, or a massively parallel processing (MPP) database system.
  • MPP massively parallel processing
  • Step 101 Receive a data reading request generated by a read transaction, where the data reading request is used to request to read a page in a database and the data reading request includes a timestamp of the read transaction.
  • the database system provides a user interface such that a user can trigger, on the user interface, a write operation (for example, deleting, inserting or updating a record in the database) on data in the database or trigger a process of reading data in the database. If the user sends a data reading process on the user interface, the database system performs step 102 to step 104 after receiving a data reading request on the user interface.
  • a write operation for example, deleting, inserting or updating a record in the database
  • the data reading request may include a timestamp of a read transaction, and may further include information such as an identifier of a page that needs to be read.
  • An operation that the user performs on the data in the database is called a transaction.
  • the operation is a read operation, and therefore the corresponding transaction is a read transaction.
  • the database system stores corresponding information about the write operation accordingly, for example, a system control number (SCN) and a timestamp used to uniquely identify an operation, where the timestamp may be further represented by a system logical timestamp (SLT).
  • SCN system control number
  • SLT system logical timestamp
  • Step 102 Determine whether a timestamp of a current version page of a page that is requested to read by the data reading request is greater than the timestamp of the read transaction, if yes, it indicates that the page that needs to be read by a user is not a version page obtained after the user performs a latest write operation, and perform step 104 , it may be understood that if the timestamp of the current version page of the page that is requested to read by the data reading request is less than or equal to the timestamp of the read transaction, perform step 103 .
  • Step 103 Read a current version page of the page that is requested to read by the foregoing data reading request.
  • the user may perform multiple write operations on a page, and after each write operation is performed, the database system stores a version page obtained prior to the write operation and a version page obtained after the write operation.
  • the database system may further set corresponding rollback information for each version page, which facilitates subsequent queries and rollback of the database by the user.
  • the rollback herein refers to retrieving information before the user performs one or multiple write operations on the page.
  • the current version page read refers to a version page obtained after the user performs the latest write operation on the page and stored in the database after the latest write operation.
  • the rollback information of a version page may include a page pointer, a record pointer, and the like, where a page pointer of a version page is used to point to another version page prior to a last operation on the version page, that is, a previous version page, and page pointers of all version pages of a page may be collected to form a data page link of the page.
  • a record pointer that is of a record and included in a version page is used to point to another version record prior to a last operation on the record, that is, a previous version record, and record pointers of records included in all version pages of a page may be collected to form a record link of the page.
  • a data page may include multiple rows of data, and each row of data is stored according to a rule. In this case, a row of data may be called a record.
  • Step 104 Perform page-level rollback according to a page pointer of the foregoing current version page in a data page link of the page that is requested to read by the foregoing data reading request, so as to roll back the current version page to a version page, a timestamp of which is less than or equal to the timestamp of the read transaction, where the data page link includes a page pointer of each version page of the page that is requested to read. Further, the database system may roll back to a previous version page first according to the page pointer of the current version page. If a timestamp of the previous version page is still greater than the timestamp of the foregoing read transaction, the database system further performs page-level rollback according to the page pointer of the previous version page.
  • the database system performs the operation in a cyclic manner until it rolls back to a version page, a timestamp of which is less than or equal to the timestamp of the read transaction.
  • the page pointer of the current version page herein is used to point to another version page prior to a last operation on the current version page, that is, a previous version page, and the page-level rollback refers to retrieving, by page, information before the user performs one or multiple write operations on the page.
  • the database system obtains a version page corresponding to the data reading request after performing the foregoing step 104 . If all records on the version page are in a non-operating state at that time, that is, the records are not operated by the database system at that time, the process ends. However, if some records on the version page are in an operating state at that time, the database system further needs to perform row-level rollback.
  • the row-level rollback herein refers to retrieving, by row of data on the page, information before the user performs one or multiple write operations on one row or several rows of data. Further, the database system may perform the following steps. A flowchart is shown in FIG. 2 .
  • Step 105 Determine whether one or more records on the version page obtained after the page-level rollback are in an operating state at a moment indicated by the timestamp of the version page obtained after the page-level rollback, that is, whether the records are being operated by the database system. If the records are in the operating state, perform step 106 , if the records are in a non-operating state, use the version page obtained after the page-level rollback as a final result of the foregoing data reading request.
  • the version page obtained after the page-level rollback correspondingly has a timestamp and rollback information.
  • the database system traverses all records on the version page to determine whether a record is in the operating state. If a record on the version page obtained after the page-level rollback includes a transaction identifier of a write operation transaction performed on the record, it indicates that the database system is performing the write operation on some records on the version page obtained after the page-level rollback at that time, and the records are in the operating state.
  • Step 106 Perform row-level rollback according to a record pointer of the foregoing records (one or more records) in a record link of a record on the page that is requested to read by the foregoing data reading request, and roll back the records in the operating state to records prior to an operation, where the record link includes a record pointer of a record included in each version page of the page that is requested to read.
  • a record of the row-level rollback record herein is similar to a record of the foregoing page-level rollback. A difference is that the row-level rollback in this step does not require timestamp comparison.
  • the database system may further perform an operation, which is similar to the foregoing step 105 and step 106 , on the current version page. That is, if some records on the current version page are in the operating state, the database system needs to perform the row-level rollback on the records, to roll back the records in the operating state to records prior to an operation, which is not further described herein.
  • a database system sets a data page link of a page, where the data page link includes a page pointer of each version page of the page, and a page pointer of a version page is used to point to another version page prior to a last operation on the version page, that is, a previous version page.
  • page-level rollback may be performed directly according to a data page link of the page that is requested to read to roll back to a version page that needs to be read, which helps a user to know a page in the database at any time, that is, which facilitates queries for data on each version page in the database.
  • the database system may roll back, in combination with a record link, a record in an operating state on a version page obtained after the page-level rollback to a record prior to modification such that the record rollback can be implemented efficiently by combining the data page link and the record link, thereby realizing consistent reading.
  • steps 101 to 106 describe an operation process of reading the data in the database by the database system.
  • the database system may perform a write operation on the data in the database according to the following steps.
  • a flowchart is shown in FIG. 3 .
  • Step 201 Receive a data writing operation request generated by a write operation transaction, where the data writing operation request is used to request to perform a write operation on a page in a database and the data writing operation request includes a timestamp of the write operation transaction, and the write operation herein may include an operation of inserting a record, deleting a record or updating a record.
  • Step 202 Read a first version page of the page requested by the data writing operation request, and perform the write operation on the first version page according to the data writing operation request to obtain a second version page, where the first version page is a latest version page of the page that is requested by the data writing operation request and stored in the database before the foregoing write operation is performed, and the second version page is a latest version page of the page that is requested by the data writing operation request and stored in the database after the foregoing write operation is performed.
  • Step 203 Set a timestamp of the second version page according to the timestamp of the write operation transaction. Furthermore, if a timestamp of the first version page is greater than the timestamp of the write operation transaction, it indicates that another user performs a write operation on the page, which results in the larger timestamp of the first version page, and the database system needs to continue performing the operation on the first version page. In this case, the timestamp of the first version page is not modified, but the timestamp of the first version page is used as the timestamp of the second version page. If the timestamp of the first version page is less than or equal to the timestamp of the operation transaction, the timestamp of the second version page is directly set to the timestamp of the operation transaction.
  • Step 204 Set rollback information of the second version page, where the rollback information includes a page pointer and a record pointer.
  • Update a transaction link in the database such that the transaction link includes an operation transaction pointer of the foregoing write operation transaction, where the transaction link includes a plurality of operation transaction pointers of a record on the page in the database, each operation transaction pointer is used to point to a previous operation transaction on the record on the page in the database, and one operation transaction may be used to operate at least one record on a page, and may also be used to operate a record on multiple pages.
  • the write operation may further include the following several manners.
  • the writing operation request is a writing operation request that requests to insert a record on the first version page
  • the database system inserts, on the first version page, the record that is requested to insert by the data writing operation request to obtain the second version page, and stores the first version page and the second version page.
  • the database system sets a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, and sets a record pointer of the second version page such that a record pointer of the inserted record on the second version page is used to point to a rollback record corresponding to the inserted record
  • the database system when updating the transaction link in the database, the database system mainly sets a transaction identifier of the write operation transaction of inserting the record on the first version page, and sets an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of inserting the record on the first version page.
  • the rollback record corresponding to the inserted record is recorded in the database system, which may further include information that the record that is requested to insert by the data reading request has been deleted from the first version page.
  • the data writing operation request is a data writing operation request that requests to delete a record from the first version page
  • the database system marks, on the first version page, the record that is requested to delete by the data writing operation request as deleted to obtain the second version page, and stores the first version page and the second version page.
  • the database system sets a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, and sets a record pointer of the second version page such that a record pointer of a record marked as deleted on the second version page is used to point to the record that is requested to delete by the data writing operation request from the first version page.
  • the database system sets a transaction identifier corresponding the write operation transaction of deleting the record, and sets an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of deleting the record.
  • the data writing operation request is a data writing operation request that requests to update a record on the first version page
  • the database system updates the corresponding record on the first version page according to an indication of the data writing operation request to obtain the second version page, and stores the first version page and the second version page.
  • the database system sets a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, and sets a record pointer of the second version page such that a record pointer of an updated record on the second version page is used to point to a record prior to the update on the first version page.
  • the database system may set a transaction identifier corresponding to the write operation transaction of updating the record, and sets an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of updating the record.
  • first version page and second version page do not indicate a sequential relationship, but are used to describe pages of different versions.
  • steps 203 and 204 do not have an absolute sequential relationship, may be performed concurrently, and may also be performed in a sequence.
  • FIG. 3 illustrates only a specific implementation method.
  • the database system further records a transaction link such that transaction rollback may be performed, that is, an operation of the user is rolled back to a state prior to the operation.
  • a transaction link may include an operation transaction pointer of a record on a page in the database, where an operation transaction pointer of one transaction identifier is used to point to an operation transaction of another transaction identifier.
  • rollback information corresponding to a version page may include a page pointer and a record pointer, and a database system further stores a transaction link, where the transaction link includes an operation transaction pointer, and all old version pages of a page are stored in a corresponding rollback segment.
  • the database system performs an operation on the database mainly in the following several manners.
  • the database system receives a data reading request, where the data reading request is used to request to read the page a, and includes a read transaction, an SLT of which is 1001 .
  • the database system compares the SLT of the read transaction with an SLT ( 1020 ) of a current version page a, and finds that the SLT of the read transaction is less than the SLT of the current version page a. In this case, a page-level rollback operation needs to be performed first.
  • the database system finds, along a page pointer set at a page header of the current version page a and in the rollback segment 1 corresponding to the current version page a, another version page prior to a last operation on the current version page a, that is, a version 4 . Then, the database system rolls back, along a page pointer set at a page header of the version 4 , to the page a of a version 2 .
  • the database system performs the operation in a cyclic manner until it rolls back to a version page corresponding to an SLT that is equal to or slightly less than the SLT of the read transaction. In this embodiment, the database system rolls back to the page a of a version n, an SLT of which is 990 .
  • a relatively thin solid-line arrow is used to represent a data page link.
  • the database system traverses each record on the page a of the version n, and finds that at a time point corresponding to the SLT 990 , the 1st row of record is in an operating state, that is, it is being operated by the database system, and a transaction identifier is T 2 .
  • the database system needs to perform row-level rollback according to a record pointer corresponding to the 1st row, and rolls back to a record in a version n 2 of the page a.
  • the database system performs row-level rollback according to a record pointer of the record in the version n 2 until it rolls back to a record prior to an operation, a transaction identifier of which is T 2 .
  • a relatively thick solid-line arrow is used to represent a transaction link
  • a dashed-line arrow is used to represent a record link.
  • a data writing operation request received by the database system is a write operation of inserting the record 1 on the page b and the operation request includes a write operation transaction, an SLT of which is 1008 .
  • a current version of the page b stored in the database system is a version 3
  • a data page link of the page b includes the page b of the version 3 ⁇ the page b of a version 2 in the corresponding rollback segment 2 ⁇ the page b of another version.
  • the database system Before the operation is performed on the page b according to the data writing operation request, the database system first inserts the record 1 on the page b of the version 3 to form the current version page b, and then stores the current version page b, and stores the page b of the version 3 in the rollback segment 2 .
  • the database system sets an SLT of the current version page b to the SLT of the write operation transaction, that is, 1008 .
  • the database system sets a page pointer of the current version page b such that the page pointer of the current version page b is used to point to the page b of the version 3 .
  • the data page link of the page b includes the current version page b ⁇ the page b of the version 3 ⁇ the page b of the version 2 ⁇ the page b of another version.
  • the database system sets a record pointer of the record 1 on the current version page b such that the record pointer of the record 1 on the current version page b is used to point to a rollback record corresponding to the record 1 inserted into the rollback segment 2 , where the rollback record includes information that the inserted record 1 is deleted from the page b of the version 3 .
  • the database system may set a transaction identifier of the inserted record 1 to T 3 , and set an operation transaction pointer of the transaction identifier T 3 such that the operation transaction pointer of the T 3 is used to point to a transaction identifier T 2 of a previous operation (that is, an operation on the page b of a version 1 , or the like).
  • a relatively thin sold-line arrow is used to represent a data page link
  • a relatively thick sold-line arrow is used to represent a transaction link
  • a dashed-line arrow is used to represent a record link.
  • a data writing operation request received by the database system is a data write operation request of deleting the record 2 inserted on the page c and the operation request includes a write operation transaction, an SLT of which is 1117 .
  • a current version of the page c stored in the database system is a version 4
  • a data page link of the page c of the version 4 includes the page c of the version 4 ⁇ the page c of a version 3 in the corresponding rollback segment 3 ⁇ the page c of another version.
  • a record link of the record 2 on the page c of the version 4 includes the record 2 on the page c of the version 4 ⁇ a record on the page c of the version 3 ⁇ a record on the page c of another version.
  • the database system When the operation is performed on the page c according to the data writing operation request, the database system first marks a record header of the record 2 on the page c of the version 4 as deleted to form the current version page c, and then stores the current version page c and stores the page c of the version 4 in the rollback segment 3 . Because an SLT ( 1117 ) of the page c of the version 4 is greater than the SLT of the write operation transaction, the database system directly uses the SLT of the page c of the version 4 as the SLT of the current version c. The database system sets a page pointer of the current version page c such that the page pointer of the current version page c is used to point to the page c of the version 4 .
  • the data page link of the page c includes the current version page c ⁇ the page c of the version 4 ⁇ the page c of the version 2 ⁇ the page c of another version.
  • the database system sets a record pointer of the record 2 on the current version page c such that the record pointer of the record 2 marked as deleted on the current version page c is used to point to the record on the page c of the version 4 .
  • the record link of the record 2 on the page c includes the record 2 marked as deleted on the current version page c ⁇ a record on the page c of the version 4 ⁇ a record on the page c of the version 3 ⁇ a record on the page c of another version.
  • the database system may set a transaction identifier of the deleted record 2 to T 3 , and set an operation transaction pointer of the transaction identifier T 3 such that the operation transaction pointer of the T 3 is used to point to a transaction identifier T 2 of a previous operation (that is, an operation on the page c of a version 1 , or the like).
  • a relatively thin sold-line arrow is used to represent a data page link
  • a relatively thick sold-line arrow is used to represent a transaction link
  • a dashed-line arrow is used to represent a record link.
  • a write operation of updating a record is similar to the foregoing write operation of inserting a record. A difference is that when an operation is performed on a page according to a data writing operation request, a record on the page is changed to a record corresponding to the data writing operation request.
  • An embodiment of the present disclosure further provides a database system.
  • a schematic structural diagram of the database system is shown in FIG. 7 , including a read receiving unit 10 configured to receive a data reading request generated by a read transaction, where the data reading request is used to request to read a page in the database and the data reading request includes a timestamp of the read transaction, a reading unit 11 configured to read the current version page of the page that is requested to read by the data reading request if a timestamp of a current version page of the page that is requested to read by the data reading request received by the read receiving unit 10 is less than or equal to the timestamp of the read transaction, and a page-level rollback unit 12 configured to perform page-level rollback using a page pointer of the current version page in a data page link of the page that is requested to read by the request in order to roll back the current version page to a version page, a timestamp of which is less than or equal to the timestamp of the read transaction if the timestamp of the current version page is greater
  • a data page link of a page is set in the database, where the data page link includes a page pointer of each version page of the page, and a page pointer of a version page is used to point to another version page prior to a last operation on the version page, that is, a previous version page.
  • a page-level rollback unit 12 may directly perform page-level rollback according to a data page link of the page that is requested to read to roll back to a page that needs to be read, which helps a user to know a page in the database at any time, that is, which facilitates queries for data on each version page in the database.
  • the database system may further include a row-level rollback unit 13 , a write operation receiving unit 14 , a write operation unit 15 , a timestamp setting unit 16 , and a rollback setting unit 17 , where the row-level rollback unit 13 is configured to perform row-level rollback according to a record pointer of the one or more records included in a record link of the page that is requested to read in order to roll back the record in the operating state to a record prior to an operation, where the record link includes a record pointer of a record included in each version page of the page that is requested to read if one or more records on the version page obtained after the page-level rollback unit 12 performs the page-level rollback are in an operating state at a moment indicated by the timestamp of the version page obtained after the page-level rollback, and a record pointer of a record on a version page is used to point to another version record prior to a
  • the row-level rollback unit 13 may further perform the foregoing operation on the current version page read by the foregoing reading unit 11 , that is, roll back a record in the operating state on the current version page to a record prior to an operation in order to realize consistent reading.
  • the row-level rollback unit 13 and the page-level rollback unit 12 in the database system may roll back, by combining the data page link and the record link, a record in an operating state on a version page obtained after page-level rollback to a record prior to modification such that the record rollback can be implemented efficiently by combining the data page link and the record link.
  • the write operation receiving unit 14 is configured to receive a data writing operation request generated by a write operation transaction, where the data writing operation request is used to request to perform a write operation on a page in the database and the data writing operation request includes a timestamp of the write operation transaction.
  • the write operation unit 15 is configured to read a first version page corresponding to the data writing operation request received by the write operation receiving unit 14 , and perform the write operation on the first version page according to the data writing operation request received by the write operation receiving unit 14 to obtain a second version page, where the first version page is a latest version page of the page that is requested by the data writing operation request and stored in the database before the write operation is performed, and the second version page is a latest version page of the page that is requested by the data writing operation request and stored in the database after the write operation is performed.
  • the timestamp setting unit 16 is configured to set a timestamp of the second version page according to the timestamp of the write operation transaction included in the data writing operation request received by the write operation receiving unit 14 .
  • the timestamp setting unit 16 is further configured to use the timestamp of the first version page as the timestamp of the second version page if a timestamp of the first version page is greater than the timestamp of the write operation transaction in the data writing operation request received by the write operation receiving unit 14 , and set the timestamp of the second version page to the timestamp of the write operation transaction in the data writing operation request received by the write operation receiving unit 14 if the timestamp of the first version page is less than the timestamp of the write operation transaction in the data writing operation request received by the write operation receiving unit 14 .
  • the rollback setting unit 17 is configured to update a transaction link in the database such that the transaction link includes an operation transaction pointer of the write operation transaction, where the transaction link includes a plurality of operation transaction pointers of a record on the page in the database, and each operation transaction pointer is used to point to a previous operation transaction on the record on the page in the database, and set rollback information of the second version page, where the rollback information includes a page pointer and a record pointer.
  • the rollback setting unit 17 may be further implemented by a data page link setting unit 170 , a record link setting unit 171 , and a transaction link setting unit 172 .
  • the write operation on the database may include the following several manners.
  • the write operation unit 15 is further configured to insert, on the first version page, the record that is requested to insert by the data writing operation request to obtain the second version page, and store the first version page and the second version page.
  • the data page link setting unit 170 in the rollback setting unit 17 is configured to set a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page.
  • the record link setting unit 171 is configured to set a record pointer of the second version page such that a record pointer of the inserted record on the second version page is used to point to a rollback record corresponding to the inserted record, where the rollback record includes information that the inserted record has been deleted from the first version page, and when updating the transaction link in the database, the transaction link setting unit 172 sets a transaction identifier corresponding to the write operation transaction of inserting the record on the first version page, and sets an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of inserting the record on the first version page.
  • the write operation unit 15 is further configured to mark, on the first version page, the record that is requested to delete by the data writing operation request as deleted to obtain the second version page, and store the first version page and the second version page.
  • the data page link setting unit 170 in the rollback setting unit 17 is further configured to set a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page.
  • the record link setting unit 171 is further configured to set a record pointer of the second version page such that a record pointer of a record marked as deleted on the second version page is used to point to the record that is requested to delete by the data writing operation request from the first version page, and when updating the transaction link, the transaction link setting unit 172 may set a transaction identifier corresponding to the write operation transaction of deleting the record, and set an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of deleting the record.
  • the write operation unit 15 is further configured to update the corresponding record on the first version page according to an indication of the data writing operation request to obtain the second version page, and store the first version page and the second version page.
  • the data page link setting unit 170 in the rollback setting unit 17 is further configured to set a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page.
  • the record link setting unit 171 is further configured to set a record pointer of the second version page such that a record pointer of an updated record on the second version page is used to point to the record prior to the update on the first version page, and when updating the transaction link, the transaction link setting unit 172 sets a transaction identifier corresponding to the write operation transaction of updating the record, and sets an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of updating the record.
  • An embodiment of the present disclosure further provides another database system.
  • a schematic structural diagram of the database system is shown in FIG. 10 , including a memory 20 , a processor 21 , an input apparatus 23 , and an output apparatus 24 that are separately connected to a bus, where the memory 20 is configured to store data input by the input apparatus 23 , and may further store information such as a necessary file used by the processor 21 to process data.
  • the memory 20 stores data in the form of a database, that is, a database is stored in the memory 20 .
  • the input apparatus 23 and the output apparatus 24 include an external device of the database system, for example, a display, a keyboard, a mouse, and a printer, and may further include an interface for communication between the database and another device.
  • the output apparatus 24 may output a user interface of the database system such that a user may perform a read operation on data in the database system using the user interface.
  • a data reading request is transmitted to the processor 21 .
  • the processor 21 is configured to receive a data reading request generated by a read transaction, where the data reading request is used to request to read a page in the database, and the data reading request includes a timestamp of the read transaction, read the current version page of the page that is requested to read by the data reading request if a timestamp of a current version page of the page that is requested to read by the data reading request is less than or equal to the timestamp of the read transaction, and perform page-level rollback according to a page pointer of the current version page in a data page link of the page that is requested to read in order to roll back the current version page to a version page, a timestamp of which is less than or equal to the timestamp of the read transaction if the timestamp of the current version page is greater than the timestamp of the read transaction, where the data page link of the page that is requested to read includes a page pointer of each version page of the page that is requested to read, and the page pointer of each version page is used to point to another version page prior
  • the processor 21 is further configured to perform row-level rollback according to a record pointer of the one or more records included in a record link of the page that is requested to read in order to roll back the record in the operating state to a record prior to an operation if one or more records on the version page obtained after the page-level rollback are in an operating state at a moment indicated by the timestamp of the version page obtained after the page-level rollback, where the record link includes a record pointer of a record included in each version page of the page that is requested to read, and a record pointer of a record on a version page is used to point to another version record prior to a last operation on the record, that is, a previous version record.
  • a data page link of a page is set in the database, where the data page link includes a page pointer of each version page of the page, and a page pointer of a version page is used to point to another version page prior to a last operation on the version page, that is, a previous version page.
  • the processor 21 may directly perform page-level rollback according to a data page link of the page that is requested to read to roll back to a version page that needs to be read, which helps a user to know a page in the database at any time, that is, which facilitates queries for data on each version page in the database.
  • the processor 21 may roll back, in combination with a record link, a record in an operating state on the version page obtained after the page-level rollback to a record prior to modification such that the record rollback can be implemented efficiently by combining the data page link and the record link, thereby realizing consistent reading.
  • the user may perform a write operation on data in the database using the user interface of the database system, which is output by the output apparatus 24 .
  • a data writing operation request is transmitted to the processor 21 .
  • the processor 21 is further configured to perform a write operation on a page in the database.
  • the processor 21 receives a data writing operation request generated by a write operation transaction, where the data writing operation request is used to request to perform a write operation on a first version page in the database, and the data writing operation request includes a timestamp of the write operation transaction, reads the first version page corresponding to the data writing operation request, and performs the write operation on the first version page according to the data writing operation request to obtain a second version page, sets a timestamp of the second version page according to the timestamp of the write operation transaction, updates a transaction link in the database such that the transaction link includes an operation transaction pointer of the write operation transaction, where the transaction link includes a plurality of operation transaction pointers of a record on the page in the database, and each operation transaction pointer is used to point to a previous operation transaction on the record on the page in the database, and sets rollback information of the second version page, where the rollback information includes a page pointer and a record pointer.
  • the first version page is a latest version page of the page that is requested by the data writing operation request and stored in the database before the write operation is performed
  • the second version page is a latest version page of the page that is requested by the data writing operation request and stored in the database after the write operation is performed.
  • the processor 21 when setting the timestamp of the second version page, is further configured to use the timestamp of the first version page as the timestamp of the second version page if a timestamp of the first version page is greater than the timestamp of the write operation transaction, and set the timestamp of the second version page to the timestamp of the write operation transaction in the data writing operation request if the timestamp of the first version page is less than the timestamp of the write operation transaction.
  • the write operation performed by the processor 21 in the database system on the database may include the following several manners.
  • the processor 21 is further configured to insert, on the first version page, the record that is requested to insert by the data writing operation request to obtain the second version page, and store the first version page and the second version page, set a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, set a record pointer of the second version page such that a record pointer of the inserted record on the second version page is used to point to a rollback record corresponding to the inserted record, where the rollback record includes information that the record that is requested to insert by the data writing operation request has been deleted from the first version page, and set a transaction identifier corresponding to the write operation transaction of inserting the record on the first page when updating the transaction link, and set an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation
  • the processor 21 is further configured to mark, on the first version page, the record that is requested to delete by the data writing operation request as deleted to obtain the second version page, and store the first version page and the second version page, set a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, set a record pointer of the second version page such that a record pointer of a record marked as deleted on the second version page is used to point to the record that is requested to delete by the data writing operation request from the first version page, and set a transaction identifier corresponding to the write operation transaction of deleting the record when updating the transaction link, and set an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of deleting the record.
  • the processor 21 is further configured to update the corresponding record on the first version page according to an indication of the data writing operation request to obtain the second version page, and store the first version page and the second version page, set a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, set a record pointer of the second version page such that a record pointer of an updated record on the second version page is used to point to the record prior to the update on the first version page, and set a transaction identifier corresponding to the write operation transaction of updating the record when updating the transaction link, and set an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of updating the record on the first version page.
  • the program may be stored in a computer-readable storage medium.
  • the storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc.

Landscapes

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

Abstract

A multi-version concurrency control method in a database and a database system is presented. The database system sets a data page link of a page, where the data page link includes a page pointer, and a page pointer is used to point to another version page prior to a last operation on the version page. In this way, when a page in the database is read, if a timestamp of a current version page is greater than a timestamp of a read transaction, page-level rollback may be directly performed according to a data page link of the page that is requested to read to roll back to a page that needs to be read, which facilitates queries for data on each version page in the database. Further, the database system may implement record rollback efficiently.

Description

    CROSS-REFERENCE TO RELATED APPLICATIONS
  • This application is a continuation of U.S. patent application Ser. No. 15/199,181, filed on Jun. 30, 2016, which is a continuation of International Application No. PCT/CN2014/082794, filed on Jul. 23, 2014, which claims priority to Chinese Patent Application No. 201310750940.8, filed on Dec. 31, 2013. All of the afore-mentioned patent applications are hereby incorporated by reference in their entireties.
  • TECHNICAL FIELD
  • The present disclosure relates to the field of database technologies, and in particular, to a multi-version concurrency control (MVCC) method in a database and a database system.
  • BACKGROUND
  • MVCC is a locking mechanism widely used in a database system. This mechanism is used in current mainstream business database systems such as an Oracle database (a database developed by ORACLE), a structured query language server (SQL SERVER) database, and a PostgreSQL database.
  • Generally, a MVCC scheme includes two implementation types, one is a page-level multi-version type, and the other is a row-level multi-version type. The page-level multi-version indicates that a timestamp is recorded and modified on a page, and the page needs to be accessed according to the timestamp. If the timestamp does not meet a requirement, a proper page version needs to be constructed. In this way, a same page may correspond to a plurality of different versions in a database. The row-level multi-version indicates that a new version is generated whenever a record is updated. In this way, a read operation and a write operation on a same record may access different versions of the record such that reading and writing are not blocked.
  • During study and practice of the prior art, the inventor of the present disclosure discovers that, when a version page obtained is read, the page needs to be read according to information about all transactions on the page. If there are many transactions on the page, efficiency of reading the data page is not high, and the reading is inconvenient.
  • SUMMARY
  • Embodiments of the present disclosure provide a MVCC method in a database and a database system, which facilitates queries for data on each version page in the database.
  • A first aspect of the embodiments of the present disclosure provides a MVCC method in a database, including receiving a data reading request generated by a read transaction, where the data reading request is used to request to read a page in the database and the data reading request includes a timestamp of the read transaction, reading the current version page of the page that is requested to read by the data reading request if a timestamp of a current version page of the page that is requested to read by the data reading request is less than or equal to the timestamp of the read transaction, and performing page-level rollback using a page pointer of the current version page in a data page link of the page that is requested to read in order to roll back the current version page to a version page, a timestamp of which is less than or equal to the timestamp of the read transaction if the timestamp of the current version page is greater than the timestamp of the read transaction, where the data page link includes a page pointer of each version page of the page that is requested to read, and the page pointer of each version page is used to point to a previous version page of the version page.
  • In a first possible implementation manner of the first aspect of the embodiments of the present disclosure, the method further includes performing row-level rollback according to a record pointer of the one or more records included in a record link of the page that is requested to read in order to roll back the record in the operating state to a record prior to an operation if one or more records on the version page obtained after the page-level rollback are in an operating state at a moment indicated by the timestamp of the version page obtained after the page-level rollback, where the record link includes a record pointer of a record included in each version page of the page that is requested to read, and a record pointer of a record on a version page is used to point to a previous version record of the record.
  • With reference to the first aspect of the embodiments of the present disclosure or the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect of the embodiments of the present disclosure, the method further includes receiving a data writing operation request generated by a write operation transaction, where the data writing operation request is used to request to perform a write operation on a page in the database and the data writing operation request includes a timestamp of the write operation transaction, reading a first version page of the page requested by the data writing operation request, and performing a write operation on the first version page according to the data writing operation request to obtain a second version page, where the first version page is a latest version page of the page that is requested by the data writing operation request and stored in the database before the write operation is performed, setting a timestamp of the second version page according to the timestamp of the write operation transaction, updating a transaction link in the database such that the transaction link includes an operation transaction pointer of the write operation transaction, where the transaction link includes a plurality of operation transaction pointers of a record on the page in the database, and each operation transaction pointer is used to point to a previous operation transaction on the record on the page in the database, and setting rollback information of the second version page, where the rollback information includes a page pointer and a record pointer.
  • With reference to the second possible implementation manner of the first aspect of the embodiments of the present disclosure, in a third possible implementation manner of the first aspect of the embodiments of the present disclosure, performing a write operation on the first version page according to the data writing operation request to obtain a second version page further includes inserting, on the first version page, the record that is requested to insert by the data writing operation request to obtain the second version page when the data writing operation request is a data writing operation request that requests to insert a record, and storing the first version page and the second version page. Setting rollback information of the second version page further includes setting a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, and setting a record pointer of the second version page such that a record pointer of the inserted record on the second version page is used to point to a rollback record corresponding to the inserted record, where the rollback record includes information that the record that is requested to insert by the data writing operation request has been deleted from the first version page, and updating a transaction link of the database further includes setting a transaction identifier of the write operation transaction of inserting the record on the first version page, and setting an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of inserting the record on the first version page.
  • With reference to the second possible implementation manner of the first aspect of the embodiments of the present disclosure, in a fourth possible implementation manner of the first aspect of the embodiments of the present disclosure, performing a write operation on the first version page according to the data writing operation request to obtain a second version page further includes marking, on the first version page, the record that is requested to delete by the data writing operation request as deleted to obtain the second version page when the data writing operation request is a data writing operation request that requests to delete a record, and storing the first version page and the second version page. Setting rollback information of the second version page further includes setting a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, and setting a record pointer of the second version page such that a record pointer of a record marked as deleted on the second version page is used to point to the record that is requested to delete by the data writing operation request from the first version page, and updating a transaction link of the database further includes setting a transaction identifier corresponding to the write operation transaction of deleting the record, and setting an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer points to a transaction identifier of a previous operation of the write operation transaction of deleting the record.
  • With reference to the second possible implementation manner of the first aspect of the embodiments of the present disclosure, in a fifth possible implementation manner of the first aspect of the embodiments of the present disclosure, performing a write operation on the first version page according to the data writing operation request to obtain a second version page further includes updating the corresponding record on the first version page according to an indication of the data writing operation request to obtain the second version page when the data writing operation request is a data writing operation request that requests to update a record, and storing the first version page and the second version page, the setting a timestamp of the second version page according to the timestamp of the write operation transaction further includes setting the timestamp of the second version page to the timestamp of the write operation transaction. Setting rollback information of the second version page further includes setting a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, and setting a record pointer of the second version page such that a record pointer of an updated record on the second version page is used to point to the record prior to the update on the first version page, and updating a transaction link of the database further includes setting a transaction identifier corresponding to the write operation transaction of updating the record, and setting an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of updating the record.
  • With reference to any one possible implementation manner of the second possible implementation manner to the fifth possible implementation manner of the first aspect of the embodiments of the present disclosure, in a sixth possible implementation manner of the first aspect of the embodiments of the present disclosure, setting a timestamp of the second version page according to the timestamp of the write operation transaction further includes using the timestamp of the first version page as the timestamp of the second version page if a timestamp of the first version page is greater than the timestamp of the write operation transaction, and setting the timestamp of the second version page to the timestamp of the write operation transaction if the timestamp of the first version page is less than the timestamp of the write operation transaction.
  • A second aspect of the embodiments of the present disclosure provides a database system, including a read receiving unit configured to receive a data reading request generated by a read transaction, where the data reading request is used to request to read a page in the database and the data reading request includes a timestamp of the read transaction, a reading unit configured to read the current version page of the page that is requested to read by the data reading request if a timestamp of a current version page of the page that is requested to read by the data reading request received by the read receiving unit is less than or equal to the timestamp of the read transaction, and a page-level rollback unit configured to perform page-level rollback using a page pointer of the current version page in a data page link of the page that is requested to read in order to roll back the current version page to a version page, a timestamp of which is less than or equal to the timestamp of the read transaction if the timestamp of the current version page is greater than the timestamp of the read transaction, where the data page link includes a page pointer of each version page of the page that is requested to read, and the page pointer of each version page is used to point to a previous version page of the version page.
  • In a first possible implementation manner of the second aspect of the embodiments of the present disclosure, the database system further includes a row-level rollback unit configured to perform row-level rollback according to a record pointer of the one or more records included in a record link of the page that is requested to read in order to roll back the record in the operating state to a record prior to an operation if one or more records on the version page obtained after the page-level rollback unit performs the page-level rollback are in an operating state at a moment indicated by the timestamp of the version page obtained after the page-level rollback, where the record link includes a record pointer of a record included in each version page of the page that is requested to read, and a record pointer of a record on a version page is used to point to a previous version record of the record.
  • With reference to the second aspect of the embodiments of the present disclosure or the first possible implementation manner of the second aspect, in a second possible implementation manner of the second aspect of the embodiments of the present disclosure, the database system further includes a write operation receiving unit configured to receive a data writing operation request generated by a write operation transaction, where the data writing operation request is used to request to perform a write operation on a page in the database and the data writing operation request includes a timestamp of the write operation transaction, a write operation unit configured to read a first version page corresponding to the data writing operation request, and perform the write operation on the first version page according to the data writing operation request to obtain a second version page, where the first version page is a latest version page of the page that is requested by the data writing operation request and stored in the database before the write operation is performed, a timestamp setting unit configured to set a timestamp of the second version page according to the timestamp of the write operation transaction, and a rollback setting unit configured to update a transaction link in the database such that the transaction link includes an operation transaction pointer of the write operation transaction, where the transaction link includes a plurality of operation transaction pointers of a record on the page in the database, and each operation transaction pointer is used to point to a previous operation transaction on the record on the page in the database, and set rollback information of the second version page, where the rollback information includes a page pointer and a record pointer.
  • With reference to the second possible implementation manner of the second aspect of the embodiments of the present disclosure, in a third possible implementation manner of the second aspect of the embodiments of the present disclosure the write operation unit is further configured to insert, on the first version page, the record that is requested to insert by the data writing operation request to obtain the second version page when the data writing operation request received by the write operation receiving unit is a data writing operation request that requests to insert a record on the first version page, and store the first version page and the second version page, and the rollback setting unit further includes a data page link setting unit configured to set a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, a record link setting unit configured to set a record pointer of the second version page such that a record pointer of the inserted record on the second version page is used to point to a rollback record corresponding to the inserted record, where the rollback record includes information that the record that is requested to insert by the data writing operation request has been deleted from the first version page, and a transaction link setting unit configured to set a transaction identifier corresponding to the write operation transaction of inserting the record on the first version page, and set an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of inserting the record on the first version page.
  • With reference to the second possible implementation manner of the second aspect of the embodiments of the present disclosure, in a fourth possible implementation manner of the second aspect of the embodiments of the present disclosure the write operation unit is further configured to mark, on the first version page, the record that is requested to delete by the data writing operation request as deleted to obtain the second version page when the data writing operation request received by the write operation receiving unit is a data writing operation request that requests to delete a record from the first version page, and store the first version page and the second version page, and the data page link setting unit is further configured to set a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page. The record link setting unit is further configured to set a record pointer of the second version page such that a record pointer of a record marked as deleted on the second version page is used to point to the record that is requested to delete by the data writing operation request from the first version page, and the transaction link setting unit is further configured to set a transaction identifier corresponding to the write operation transaction of deleting the record, and set an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of deleting the record.
  • With reference to the second possible implementation manner of the second aspect of the embodiments of the present disclosure, in a fifth possible implementation manner of the second aspect of the embodiments of the present disclosure the write operation unit is further configured to update the corresponding record on the first version page according to an indication of the data writing operation request to obtain the second version page when the data writing operation request received by the write operation receiving unit is a data writing operation request that requests to update a record on the first version page, and store the first version page and the second version page, and the data page link setting unit is further configured to set a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, the record link setting unit is further configured to set a record pointer of the second version page such that a record pointer of an updated record on the second version page is used to point to the record prior to the update on the first version page, and the transaction link setting unit is further configured to set a transaction identifier corresponding to the write operation transaction of updating the record, and set an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of updating the record.
  • With reference to any one possible implementation manner of the second possible implementation manner to the fifth possible implementation manner of the second aspect of the embodiments of the present disclosure, in a sixth possible implementation manner of the second aspect of the embodiments of the present disclosure the timestamp setting unit is further configured to use the timestamp of the first version page as the timestamp of the second version page if a timestamp of the first version page is greater than the timestamp of the write operation transaction, and set the timestamp of the second version page to the timestamp of the write operation transaction if the timestamp of the first version page is less than the timestamp of the write operation transaction.
  • In the embodiments, a database system sets a data page link of a page, where the data page link includes a page pointer of each version page of the page, and a page pointer of a version page is used to point to another version page prior to a last operation on the version page, that is, a previous version page. In this way, when a page in the database is read, if a timestamp of a current version page is greater than a timestamp of a corresponding read transaction included in a data reading request, page-level rollback may be performed directly according to a data page link of the page that is requested to read to roll back to a version page that needs to be read, which helps a user to know a page in the database at any time, that is, which facilitates queries for data on each version page in the database. In addition, the database system may further roll back, in combination with a record link, a record in an operating state on a version page obtained after the page-level rollback to a record prior to modification such that the record rollback can be implemented efficiently by combining the data page link and the record link, thereby realizing consistent reading.
  • BRIEF DESCRIPTION OF DRAWINGS
  • To describe the technical solutions in the embodiments of the present disclosure more clearly, the following briefly introduces the accompanying drawings required for describing the embodiments. The accompanying drawings in the following description show merely some embodiments of the present disclosure, and a person skilled in the art may still derive other drawings from these accompanying drawings without creative efforts.
  • FIG. 1 is a flowchart of a MVCC method in a database according to an embodiment of the present disclosure;
  • FIG. 2 is a flowchart of another MVCC method in a database according to an embodiment of the present disclosure;
  • FIG. 3 is a flowchart of another MVCC method in a database according to an embodiment of the present disclosure;
  • FIG. 4 is a schematic diagram of reading a page by a database system according to an embodiment of the present disclosure;
  • FIG. 5 is a schematic diagram of inserting a record on a page by a database system according to an embodiment of the present disclosure;
  • FIG. 6 is a schematic diagram of deleting a record from a page by a database system according to an embodiment of the present disclosure;
  • FIG. 7 is a schematic structural diagram of a database system according to an embodiment of the present disclosure.
  • FIG. 8 is a schematic structural diagram of another database system according to an embodiment of the present disclosure;
  • FIG. 9 is a schematic structural diagram of another database system according to an embodiment of the present disclosure; and
  • FIG. 10 is a schematic structural diagram of another database system according to an embodiment of the present disclosure.
  • DESCRIPTION OF EMBODIMENTS
  • The following clearly and completely describes the technical solutions in the embodiments of the present disclosure with reference to the accompanying drawings in the embodiments of the present disclosure. The described embodiments are merely a part rather than all of the embodiments of the present disclosure. All other embodiments obtained by a person skilled in the art based on the embodiments of the present disclosure without creative efforts shall fall within the protection scope of the present disclosure.
  • An embodiment of the present disclosure provides a MVCC method in a database, where the method is mainly executed by a database system, for example, a distributed magnetic disk database system, a cluster database system, or a massively parallel processing (MPP) database system. A flowchart is shown in FIG. 1, including the following steps.
  • Step 101: Receive a data reading request generated by a read transaction, where the data reading request is used to request to read a page in a database and the data reading request includes a timestamp of the read transaction.
  • It may be understood that the database system provides a user interface such that a user can trigger, on the user interface, a write operation (for example, deleting, inserting or updating a record in the database) on data in the database or trigger a process of reading data in the database. If the user sends a data reading process on the user interface, the database system performs step 102 to step 104 after receiving a data reading request on the user interface.
  • The data reading request may include a timestamp of a read transaction, and may further include information such as an identifier of a page that needs to be read. An operation that the user performs on the data in the database is called a transaction. In this embodiment, the operation is a read operation, and therefore the corresponding transaction is a read transaction. Each time after the user performs a write operation on the database and commits the operation to the database system for storage, the database system stores corresponding information about the write operation accordingly, for example, a system control number (SCN) and a timestamp used to uniquely identify an operation, where the timestamp may be further represented by a system logical timestamp (SLT).
  • Step 102: Determine whether a timestamp of a current version page of a page that is requested to read by the data reading request is greater than the timestamp of the read transaction, if yes, it indicates that the page that needs to be read by a user is not a version page obtained after the user performs a latest write operation, and perform step 104, it may be understood that if the timestamp of the current version page of the page that is requested to read by the data reading request is less than or equal to the timestamp of the read transaction, perform step 103.
  • Step 103: Read a current version page of the page that is requested to read by the foregoing data reading request.
  • When the user performs the write operation on the data in the database, the user may perform multiple write operations on a page, and after each write operation is performed, the database system stores a version page obtained prior to the write operation and a version page obtained after the write operation. In addition, the database system may further set corresponding rollback information for each version page, which facilitates subsequent queries and rollback of the database by the user. The rollback herein refers to retrieving information before the user performs one or multiple write operations on the page. In this step, the current version page read refers to a version page obtained after the user performs the latest write operation on the page and stored in the database after the latest write operation.
  • The rollback information of a version page may include a page pointer, a record pointer, and the like, where a page pointer of a version page is used to point to another version page prior to a last operation on the version page, that is, a previous version page, and page pointers of all version pages of a page may be collected to form a data page link of the page. A record pointer that is of a record and included in a version page is used to point to another version record prior to a last operation on the record, that is, a previous version record, and record pointers of records included in all version pages of a page may be collected to form a record link of the page. It should be noted that when data is stored in the database, the data is stored by page, a data page may include multiple rows of data, and each row of data is stored according to a rule. In this case, a row of data may be called a record.
  • Step 104: Perform page-level rollback according to a page pointer of the foregoing current version page in a data page link of the page that is requested to read by the foregoing data reading request, so as to roll back the current version page to a version page, a timestamp of which is less than or equal to the timestamp of the read transaction, where the data page link includes a page pointer of each version page of the page that is requested to read. Further, the database system may roll back to a previous version page first according to the page pointer of the current version page. If a timestamp of the previous version page is still greater than the timestamp of the foregoing read transaction, the database system further performs page-level rollback according to the page pointer of the previous version page. The database system performs the operation in a cyclic manner until it rolls back to a version page, a timestamp of which is less than or equal to the timestamp of the read transaction. The page pointer of the current version page herein is used to point to another version page prior to a last operation on the current version page, that is, a previous version page, and the page-level rollback refers to retrieving, by page, information before the user performs one or multiple write operations on the page.
  • It should be noted that the database system obtains a version page corresponding to the data reading request after performing the foregoing step 104. If all records on the version page are in a non-operating state at that time, that is, the records are not operated by the database system at that time, the process ends. However, if some records on the version page are in an operating state at that time, the database system further needs to perform row-level rollback. The row-level rollback herein refers to retrieving, by row of data on the page, information before the user performs one or multiple write operations on one row or several rows of data. Further, the database system may perform the following steps. A flowchart is shown in FIG. 2.
  • Step 105: Determine whether one or more records on the version page obtained after the page-level rollback are in an operating state at a moment indicated by the timestamp of the version page obtained after the page-level rollback, that is, whether the records are being operated by the database system. If the records are in the operating state, perform step 106, if the records are in a non-operating state, use the version page obtained after the page-level rollback as a final result of the foregoing data reading request.
  • The version page obtained after the page-level rollback correspondingly has a timestamp and rollback information. In this embodiment, the database system traverses all records on the version page to determine whether a record is in the operating state. If a record on the version page obtained after the page-level rollback includes a transaction identifier of a write operation transaction performed on the record, it indicates that the database system is performing the write operation on some records on the version page obtained after the page-level rollback at that time, and the records are in the operating state.
  • Step 106: Perform row-level rollback according to a record pointer of the foregoing records (one or more records) in a record link of a record on the page that is requested to read by the foregoing data reading request, and roll back the records in the operating state to records prior to an operation, where the record link includes a record pointer of a record included in each version page of the page that is requested to read. A record of the row-level rollback record herein is similar to a record of the foregoing page-level rollback. A difference is that the row-level rollback in this step does not require timestamp comparison.
  • In addition, it should be noted that after the database system performs the operation of reading the current version page in the foregoing step 103, the database system may further perform an operation, which is similar to the foregoing step 105 and step 106, on the current version page. That is, if some records on the current version page are in the operating state, the database system needs to perform the row-level rollback on the records, to roll back the records in the operating state to records prior to an operation, which is not further described herein.
  • It can be seen that in this embodiment, a database system sets a data page link of a page, where the data page link includes a page pointer of each version page of the page, and a page pointer of a version page is used to point to another version page prior to a last operation on the version page, that is, a previous version page. In this way, when a page in the database is read, if a timestamp of a current version page is greater than a timestamp of a corresponding read transaction included in a data reading request, page-level rollback may be performed directly according to a data page link of the page that is requested to read to roll back to a version page that needs to be read, which helps a user to know a page in the database at any time, that is, which facilitates queries for data on each version page in the database. In addition, the database system may roll back, in combination with a record link, a record in an operating state on a version page obtained after the page-level rollback to a record prior to modification such that the record rollback can be implemented efficiently by combining the data page link and the record link, thereby realizing consistent reading.
  • The foregoing steps 101 to 106 describe an operation process of reading the data in the database by the database system. During a specific implementation, the database system may perform a write operation on the data in the database according to the following steps. A flowchart is shown in FIG. 3.
  • Step 201: Receive a data writing operation request generated by a write operation transaction, where the data writing operation request is used to request to perform a write operation on a page in a database and the data writing operation request includes a timestamp of the write operation transaction, and the write operation herein may include an operation of inserting a record, deleting a record or updating a record.
  • Step 202: Read a first version page of the page requested by the data writing operation request, and perform the write operation on the first version page according to the data writing operation request to obtain a second version page, where the first version page is a latest version page of the page that is requested by the data writing operation request and stored in the database before the foregoing write operation is performed, and the second version page is a latest version page of the page that is requested by the data writing operation request and stored in the database after the foregoing write operation is performed.
  • It may be understood that when a user initiates, on a user interface provided by the database system, a data writing operation request to the database, and when the database system receives the data writing operation request on the user interface, the database system reads a corresponding first version page first, and then performs a write operation on the first version page.
  • Step 203: Set a timestamp of the second version page according to the timestamp of the write operation transaction. Furthermore, if a timestamp of the first version page is greater than the timestamp of the write operation transaction, it indicates that another user performs a write operation on the page, which results in the larger timestamp of the first version page, and the database system needs to continue performing the operation on the first version page. In this case, the timestamp of the first version page is not modified, but the timestamp of the first version page is used as the timestamp of the second version page. If the timestamp of the first version page is less than or equal to the timestamp of the operation transaction, the timestamp of the second version page is directly set to the timestamp of the operation transaction.
  • Step 204: Set rollback information of the second version page, where the rollback information includes a page pointer and a record pointer. Update a transaction link in the database such that the transaction link includes an operation transaction pointer of the foregoing write operation transaction, where the transaction link includes a plurality of operation transaction pointers of a record on the page in the database, each operation transaction pointer is used to point to a previous operation transaction on the record on the page in the database, and one operation transaction may be used to operate at least one record on a page, and may also be used to operate a record on multiple pages.
  • In this embodiment, the write operation may further include the following several manners.
  • (1) If the writing operation request is a writing operation request that requests to insert a record on the first version page, when the database system performs step 202, the database system inserts, on the first version page, the record that is requested to insert by the data writing operation request to obtain the second version page, and stores the first version page and the second version page.
  • When performing step 204, the database system sets a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, and sets a record pointer of the second version page such that a record pointer of the inserted record on the second version page is used to point to a rollback record corresponding to the inserted record, when updating the transaction link in the database, the database system mainly sets a transaction identifier of the write operation transaction of inserting the record on the first version page, and sets an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of inserting the record on the first version page. The rollback record corresponding to the inserted record is recorded in the database system, which may further include information that the record that is requested to insert by the data reading request has been deleted from the first version page.
  • (2) If the data writing operation request is a data writing operation request that requests to delete a record from the first version page, when the database system performs step 202, the database system marks, on the first version page, the record that is requested to delete by the data writing operation request as deleted to obtain the second version page, and stores the first version page and the second version page.
  • When performing step 204, the database system sets a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, and sets a record pointer of the second version page such that a record pointer of a record marked as deleted on the second version page is used to point to the record that is requested to delete by the data writing operation request from the first version page. When updating the transaction link in the database, the database system sets a transaction identifier corresponding the write operation transaction of deleting the record, and sets an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of deleting the record.
  • (3) If the data writing operation request is a data writing operation request that requests to update a record on the first version page, when the database system performs step 202, the database system updates the corresponding record on the first version page according to an indication of the data writing operation request to obtain the second version page, and stores the first version page and the second version page.
  • When performing step 204, the database system sets a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, and sets a record pointer of the second version page such that a record pointer of an updated record on the second version page is used to point to a record prior to the update on the first version page. When updating the transaction link in the database, the database system may set a transaction identifier corresponding to the write operation transaction of updating the record, and sets an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of updating the record.
  • It should be noted that the foregoing first version page and second version page do not indicate a sequential relationship, but are used to describe pages of different versions. In addition, the foregoing steps 203 and 204 do not have an absolute sequential relationship, may be performed concurrently, and may also be performed in a sequence. FIG. 3 illustrates only a specific implementation method.
  • In addition, it should be noted that in the embodiment of the present disclosure, the database system further records a transaction link such that transaction rollback may be performed, that is, an operation of the user is rolled back to a state prior to the operation. Because an operation may correspond to at least one record on at least one page, that is, a transaction identifier may be associated with an operation on at least one record one at least one page, the transaction link may include an operation transaction pointer of a record on a page in the database, where an operation transaction pointer of one transaction identifier is used to point to an operation transaction of another transaction identifier.
  • The following describes an MVCC method in a database according to the present disclosure using a specific embodiment. In this embodiment, rollback information corresponding to a version page may include a page pointer and a record pointer, and a database system further stores a transaction link, where the transaction link includes an operation transaction pointer, and all old version pages of a page are stored in a corresponding rollback segment. The database system performs an operation on the database mainly in the following several manners.
  • (1) Read a page a in the database, where multiple old version pages of the page a are stored in a rollback segment 1 of the database system.
  • As shown in FIG. 4, square frames overlapped after a page represent multiple pages, and square frames overlapped after a rollback segment represent rollback segments corresponding to the multiple pages. In this embodiment, the database system receives a data reading request, where the data reading request is used to request to read the page a, and includes a read transaction, an SLT of which is 1001. In this way, the database system compares the SLT of the read transaction with an SLT (1020) of a current version page a, and finds that the SLT of the read transaction is less than the SLT of the current version page a. In this case, a page-level rollback operation needs to be performed first.
  • When performing the page-level rollback, the database system finds, along a page pointer set at a page header of the current version page a and in the rollback segment 1 corresponding to the current version page a, another version page prior to a last operation on the current version page a, that is, a version 4. Then, the database system rolls back, along a page pointer set at a page header of the version 4, to the page a of a version 2. The database system performs the operation in a cyclic manner until it rolls back to a version page corresponding to an SLT that is equal to or slightly less than the SLT of the read transaction. In this embodiment, the database system rolls back to the page a of a version n, an SLT of which is 990. In FIG. 4, a relatively thin solid-line arrow is used to represent a data page link.
  • The database system traverses each record on the page a of the version n, and finds that at a time point corresponding to the SLT 990, the 1st row of record is in an operating state, that is, it is being operated by the database system, and a transaction identifier is T2. In this case, the database system needs to perform row-level rollback according to a record pointer corresponding to the 1st row, and rolls back to a record in a version n2 of the page a. Then, the database system performs row-level rollback according to a record pointer of the record in the version n2 until it rolls back to a record prior to an operation, a transaction identifier of which is T2. In FIG. 4, a relatively thick solid-line arrow is used to represent a transaction link, and a dashed-line arrow is used to represent a record link.
  • (2) Perform a write operation of inserting a record 1 on a page b, where multiple old version pages of the page b are stored in a rollback segment 2 of the database system.
  • As shown in FIG. 5, square frames overlapped after a page represent multiple pages, and square frames overlapped after a rollback segment represent rollback segments corresponding to the multiple pages. A data writing operation request received by the database system is a write operation of inserting the record 1 on the page b and the operation request includes a write operation transaction, an SLT of which is 1008.
  • Before the operation is performed on the page b according to the data writing operation request, a current version of the page b stored in the database system is a version 3, and a data page link of the page b includes the page b of the version 3→the page b of a version 2 in the corresponding rollback segment 2→the page b of another version.
  • Before the operation is performed on the page b according to the data writing operation request, the database system first inserts the record 1 on the page b of the version 3 to form the current version page b, and then stores the current version page b, and stores the page b of the version 3 in the rollback segment 2. The database system sets an SLT of the current version page b to the SLT of the write operation transaction, that is, 1008. The database system sets a page pointer of the current version page b such that the page pointer of the current version page b is used to point to the page b of the version 3. In this case, the data page link of the page b includes the current version page b→the page b of the version 3→the page b of the version 2→the page b of another version. The database system sets a record pointer of the record 1 on the current version page b such that the record pointer of the record 1 on the current version page b is used to point to a rollback record corresponding to the record 1 inserted into the rollback segment 2, where the rollback record includes information that the inserted record 1 is deleted from the page b of the version 3. When updating a transaction link, the database system may set a transaction identifier of the inserted record 1 to T3, and set an operation transaction pointer of the transaction identifier T3 such that the operation transaction pointer of the T3 is used to point to a transaction identifier T2 of a previous operation (that is, an operation on the page b of a version 1, or the like).
  • In FIG. 5, a relatively thin sold-line arrow is used to represent a data page link, a relatively thick sold-line arrow is used to represent a transaction link, and a dashed-line arrow is used to represent a record link.
  • (3) Perform a write operation of deleting a record 2 from a page c, where multiple old version pages of the page c are stored in a rollback segment 3 of the database system.
  • As shown in FIG. 6, square frames overlapped after a page represent multiple pages, and square frames overlapped after a rollback segment represent rollback segments corresponding to the multiple pages. A data writing operation request received by the database system is a data write operation request of deleting the record 2 inserted on the page c and the operation request includes a write operation transaction, an SLT of which is 1117.
  • Before the operation is performed on the page c according to the data writing operation request, a current version of the page c stored in the database system is a version 4, and a data page link of the page c of the version 4 includes the page c of the version 4→the page c of a version 3 in the corresponding rollback segment 3→the page c of another version. A record link of the record 2 on the page c of the version 4 includes the record 2 on the page c of the version 4→a record on the page c of the version 3→a record on the page c of another version.
  • When the operation is performed on the page c according to the data writing operation request, the database system first marks a record header of the record 2 on the page c of the version 4 as deleted to form the current version page c, and then stores the current version page c and stores the page c of the version 4 in the rollback segment 3. Because an SLT (1117) of the page c of the version 4 is greater than the SLT of the write operation transaction, the database system directly uses the SLT of the page c of the version 4 as the SLT of the current version c. The database system sets a page pointer of the current version page c such that the page pointer of the current version page c is used to point to the page c of the version 4. In this case, the data page link of the page c includes the current version page c→the page c of the version 4→the page c of the version 2→the page c of another version. The database system sets a record pointer of the record 2 on the current version page c such that the record pointer of the record 2 marked as deleted on the current version page c is used to point to the record on the page c of the version 4. In this case, the record link of the record 2 on the page c includes the record 2 marked as deleted on the current version page c→a record on the page c of the version 4→a record on the page c of the version 3→a record on the page c of another version. When updating a transaction link, the database system may set a transaction identifier of the deleted record 2 to T3, and set an operation transaction pointer of the transaction identifier T3 such that the operation transaction pointer of the T3 is used to point to a transaction identifier T2 of a previous operation (that is, an operation on the page c of a version 1, or the like).
  • In FIG. 6, a relatively thin sold-line arrow is used to represent a data page link, a relatively thick sold-line arrow is used to represent a transaction link, and a dashed-line arrow is used to represent a record link.
  • (4) A write operation of updating a record is similar to the foregoing write operation of inserting a record. A difference is that when an operation is performed on a page according to a data writing operation request, a record on the page is changed to a record corresponding to the data writing operation request.
  • An embodiment of the present disclosure further provides a database system. A schematic structural diagram of the database system is shown in FIG. 7, including a read receiving unit 10 configured to receive a data reading request generated by a read transaction, where the data reading request is used to request to read a page in the database and the data reading request includes a timestamp of the read transaction, a reading unit 11 configured to read the current version page of the page that is requested to read by the data reading request if a timestamp of a current version page of the page that is requested to read by the data reading request received by the read receiving unit 10 is less than or equal to the timestamp of the read transaction, and a page-level rollback unit 12 configured to perform page-level rollback using a page pointer of the current version page in a data page link of the page that is requested to read by the request in order to roll back the current version page to a version page, a timestamp of which is less than or equal to the timestamp of the read transaction if the timestamp of the current version page is greater than the timestamp of the read transaction included in the data reading request received by the read receiving unit 10, where the data page link of the page that is requested to read includes a page pointer of each version page of the page that is requested to read, and the page pointer of each version page is used to point to another version page prior to a last operation on the version page, that is, a previous version page.
  • It can be seen that, a data page link of a page is set in the database, where the data page link includes a page pointer of each version page of the page, and a page pointer of a version page is used to point to another version page prior to a last operation on the version page, that is, a previous version page. When the database system in this embodiment reads a version page in the database, if a timestamp of a current version page is greater than a timestamp of a corresponding read transaction included in a data reading request, a page-level rollback unit 12 may directly perform page-level rollback according to a data page link of the page that is requested to read to roll back to a page that needs to be read, which helps a user to know a page in the database at any time, that is, which facilitates queries for data on each version page in the database.
  • As shown in FIG. 8, in a specific embodiment, in addition to the structure shown in FIG. 7, the database system may further include a row-level rollback unit 13, a write operation receiving unit 14, a write operation unit 15, a timestamp setting unit 16, and a rollback setting unit 17, where the row-level rollback unit 13 is configured to perform row-level rollback according to a record pointer of the one or more records included in a record link of the page that is requested to read in order to roll back the record in the operating state to a record prior to an operation, where the record link includes a record pointer of a record included in each version page of the page that is requested to read if one or more records on the version page obtained after the page-level rollback unit 12 performs the page-level rollback are in an operating state at a moment indicated by the timestamp of the version page obtained after the page-level rollback, and a record pointer of a record on a version page is used to point to another version record prior to a last operation on the version record, that is, a previous version record. The row-level rollback unit 13 may further perform the foregoing operation on the current version page read by the foregoing reading unit 11, that is, roll back a record in the operating state on the current version page to a record prior to an operation in order to realize consistent reading.
  • In this way, the row-level rollback unit 13 and the page-level rollback unit 12 in the database system may roll back, by combining the data page link and the record link, a record in an operating state on a version page obtained after page-level rollback to a record prior to modification such that the record rollback can be implemented efficiently by combining the data page link and the record link.
  • The write operation receiving unit 14 is configured to receive a data writing operation request generated by a write operation transaction, where the data writing operation request is used to request to perform a write operation on a page in the database and the data writing operation request includes a timestamp of the write operation transaction.
  • The write operation unit 15 is configured to read a first version page corresponding to the data writing operation request received by the write operation receiving unit 14, and perform the write operation on the first version page according to the data writing operation request received by the write operation receiving unit 14 to obtain a second version page, where the first version page is a latest version page of the page that is requested by the data writing operation request and stored in the database before the write operation is performed, and the second version page is a latest version page of the page that is requested by the data writing operation request and stored in the database after the write operation is performed.
  • The timestamp setting unit 16 is configured to set a timestamp of the second version page according to the timestamp of the write operation transaction included in the data writing operation request received by the write operation receiving unit 14. The timestamp setting unit 16 is further configured to use the timestamp of the first version page as the timestamp of the second version page if a timestamp of the first version page is greater than the timestamp of the write operation transaction in the data writing operation request received by the write operation receiving unit 14, and set the timestamp of the second version page to the timestamp of the write operation transaction in the data writing operation request received by the write operation receiving unit 14 if the timestamp of the first version page is less than the timestamp of the write operation transaction in the data writing operation request received by the write operation receiving unit 14.
  • The rollback setting unit 17 is configured to update a transaction link in the database such that the transaction link includes an operation transaction pointer of the write operation transaction, where the transaction link includes a plurality of operation transaction pointers of a record on the page in the database, and each operation transaction pointer is used to point to a previous operation transaction on the record on the page in the database, and set rollback information of the second version page, where the rollback information includes a page pointer and a record pointer. In a specific embodiment, as shown in FIG. 9, the rollback setting unit 17 may be further implemented by a data page link setting unit 170, a record link setting unit 171, and a transaction link setting unit 172.
  • In this embodiment, in the database system, the write operation on the database may include the following several manners.
  • (1) When the data writing operation request received by the write operation receiving unit 14 is a data writing operation request that requests to insert a record on the first version page, the write operation unit 15 is further configured to insert, on the first version page, the record that is requested to insert by the data writing operation request to obtain the second version page, and store the first version page and the second version page.
  • The data page link setting unit 170 in the rollback setting unit 17 is configured to set a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page. The record link setting unit 171 is configured to set a record pointer of the second version page such that a record pointer of the inserted record on the second version page is used to point to a rollback record corresponding to the inserted record, where the rollback record includes information that the inserted record has been deleted from the first version page, and when updating the transaction link in the database, the transaction link setting unit 172 sets a transaction identifier corresponding to the write operation transaction of inserting the record on the first version page, and sets an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of inserting the record on the first version page.
  • (2) When the data writing operation request received by the write operation receiving unit 14 is a data writing operation request that requests to delete a record from the first version page, the write operation unit 15 is further configured to mark, on the first version page, the record that is requested to delete by the data writing operation request as deleted to obtain the second version page, and store the first version page and the second version page.
  • The data page link setting unit 170 in the rollback setting unit 17 is further configured to set a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page. The record link setting unit 171 is further configured to set a record pointer of the second version page such that a record pointer of a record marked as deleted on the second version page is used to point to the record that is requested to delete by the data writing operation request from the first version page, and when updating the transaction link, the transaction link setting unit 172 may set a transaction identifier corresponding to the write operation transaction of deleting the record, and set an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of deleting the record.
  • (3) When the data writing operation request received by the write operation receiving unit 14 is a data writing operation request that requests to update a record on the first version page, the write operation unit 15 is further configured to update the corresponding record on the first version page according to an indication of the data writing operation request to obtain the second version page, and store the first version page and the second version page.
  • The data page link setting unit 170 in the rollback setting unit 17 is further configured to set a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page. The record link setting unit 171 is further configured to set a record pointer of the second version page such that a record pointer of an updated record on the second version page is used to point to the record prior to the update on the first version page, and when updating the transaction link, the transaction link setting unit 172 sets a transaction identifier corresponding to the write operation transaction of updating the record, and sets an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of updating the record.
  • An embodiment of the present disclosure further provides another database system. A schematic structural diagram of the database system is shown in FIG. 10, including a memory 20, a processor 21, an input apparatus 23, and an output apparatus 24 that are separately connected to a bus, where the memory 20 is configured to store data input by the input apparatus 23, and may further store information such as a necessary file used by the processor 21 to process data. In this embodiment, the memory 20 stores data in the form of a database, that is, a database is stored in the memory 20. In this embodiment, the input apparatus 23 and the output apparatus 24 include an external device of the database system, for example, a display, a keyboard, a mouse, and a printer, and may further include an interface for communication between the database and another device.
  • In the database system in this embodiment, the output apparatus 24 may output a user interface of the database system such that a user may perform a read operation on data in the database system using the user interface. When the user initiates a data reading transaction using the input apparatus 23, a data reading request is transmitted to the processor 21.
  • The processor 21 is configured to receive a data reading request generated by a read transaction, where the data reading request is used to request to read a page in the database, and the data reading request includes a timestamp of the read transaction, read the current version page of the page that is requested to read by the data reading request if a timestamp of a current version page of the page that is requested to read by the data reading request is less than or equal to the timestamp of the read transaction, and perform page-level rollback according to a page pointer of the current version page in a data page link of the page that is requested to read in order to roll back the current version page to a version page, a timestamp of which is less than or equal to the timestamp of the read transaction if the timestamp of the current version page is greater than the timestamp of the read transaction, where the data page link of the page that is requested to read includes a page pointer of each version page of the page that is requested to read, and the page pointer of each version page is used to point to another version page prior to a last operation on the version page, that is, a previous version page.
  • Further, after the processor 21 performs the page-level rollback, the processor 21 is further configured to perform row-level rollback according to a record pointer of the one or more records included in a record link of the page that is requested to read in order to roll back the record in the operating state to a record prior to an operation if one or more records on the version page obtained after the page-level rollback are in an operating state at a moment indicated by the timestamp of the version page obtained after the page-level rollback, where the record link includes a record pointer of a record included in each version page of the page that is requested to read, and a record pointer of a record on a version page is used to point to another version record prior to a last operation on the record, that is, a previous version record.
  • In this way, a data page link of a page is set in the database, where the data page link includes a page pointer of each version page of the page, and a page pointer of a version page is used to point to another version page prior to a last operation on the version page, that is, a previous version page. When the database system in this embodiment reads a page in the database, if a timestamp of a current version page is greater than a timestamp of a read transaction included in a data reading request, the processor 21 may directly perform page-level rollback according to a data page link of the page that is requested to read to roll back to a version page that needs to be read, which helps a user to know a page in the database at any time, that is, which facilitates queries for data on each version page in the database. In addition, the processor 21 may roll back, in combination with a record link, a record in an operating state on the version page obtained after the page-level rollback to a record prior to modification such that the record rollback can be implemented efficiently by combining the data page link and the record link, thereby realizing consistent reading.
  • In a specific embodiment, the user may perform a write operation on data in the database using the user interface of the database system, which is output by the output apparatus 24. When the user initiates a data writing transaction using the input apparatus 23, a data writing operation request is transmitted to the processor 21. In this case, the processor 21 is further configured to perform a write operation on a page in the database. The processor 21 receives a data writing operation request generated by a write operation transaction, where the data writing operation request is used to request to perform a write operation on a first version page in the database, and the data writing operation request includes a timestamp of the write operation transaction, reads the first version page corresponding to the data writing operation request, and performs the write operation on the first version page according to the data writing operation request to obtain a second version page, sets a timestamp of the second version page according to the timestamp of the write operation transaction, updates a transaction link in the database such that the transaction link includes an operation transaction pointer of the write operation transaction, where the transaction link includes a plurality of operation transaction pointers of a record on the page in the database, and each operation transaction pointer is used to point to a previous operation transaction on the record on the page in the database, and sets rollback information of the second version page, where the rollback information includes a page pointer and a record pointer. The first version page is a latest version page of the page that is requested by the data writing operation request and stored in the database before the write operation is performed, and the second version page is a latest version page of the page that is requested by the data writing operation request and stored in the database after the write operation is performed.
  • In addition, when setting the timestamp of the second version page, the processor 21 is further configured to use the timestamp of the first version page as the timestamp of the second version page if a timestamp of the first version page is greater than the timestamp of the write operation transaction, and set the timestamp of the second version page to the timestamp of the write operation transaction in the data writing operation request if the timestamp of the first version page is less than the timestamp of the write operation transaction.
  • In a specific implementation process, the write operation performed by the processor 21 in the database system on the database may include the following several manners.
  • (1) When the data writing operation request received by the processor 21 is a data writing operation request that requests to insert a record on the first version page, the processor 21 is further configured to insert, on the first version page, the record that is requested to insert by the data writing operation request to obtain the second version page, and store the first version page and the second version page, set a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, set a record pointer of the second version page such that a record pointer of the inserted record on the second version page is used to point to a rollback record corresponding to the inserted record, where the rollback record includes information that the record that is requested to insert by the data writing operation request has been deleted from the first version page, and set a transaction identifier corresponding to the write operation transaction of inserting the record on the first page when updating the transaction link, and set an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of inserting the record on the first version page.
  • (2) When the data writing operation request received by the processor 21 is a data writing operation request that requests to delete a record from the first version page, the processor 21 is further configured to mark, on the first version page, the record that is requested to delete by the data writing operation request as deleted to obtain the second version page, and store the first version page and the second version page, set a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, set a record pointer of the second version page such that a record pointer of a record marked as deleted on the second version page is used to point to the record that is requested to delete by the data writing operation request from the first version page, and set a transaction identifier corresponding to the write operation transaction of deleting the record when updating the transaction link, and set an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of deleting the record.
  • (3) When the data writing operation request received by the processor 21 is a data writing operation request that requests to update a record on the first version page, the processor 21 is further configured to update the corresponding record on the first version page according to an indication of the data writing operation request to obtain the second version page, and store the first version page and the second version page, set a page pointer of the second version page such that the page pointer of the second version page is used to point to the first version page, set a record pointer of the second version page such that a record pointer of an updated record on the second version page is used to point to the record prior to the update on the first version page, and set a transaction identifier corresponding to the write operation transaction of updating the record when updating the transaction link, and set an operation transaction pointer corresponding to the transaction identifier such that the operation transaction pointer is used to point to a transaction identifier of a previous operation of the write operation transaction of updating the record on the first version page.
  • A person of ordinary skill in the art may understand that all or a part of the steps of the methods in the embodiments may be implemented by a program instructing related hardware. The program may be stored in a computer-readable storage medium. The storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc.
  • What has been described in detail is an MVCC method in a database and a database system provided by the embodiments of the present disclosure. Specific examples are used in this specification to describe the principle and implementation manners of the present disclosure. The descriptions of the foregoing embodiments are merely intended to help understand the method and core idea of the present disclosure. In addition, a person skilled in the art may, according to the idea of the present disclosure, make modifications with respect to the specific implementation manners and the application scope. Therefore, the content of this specification shall not be construed as a limitation on the present disclosure.

Claims (15)

What is claimed is:
1. A multi-version concurrency control method in a database, comprising:
receiving a data writing operation request generated by a write operation transaction, wherein the data writing operation request is used to request to perform a write operation, and wherein the data writing operation request comprises a timestamp of the write operation transaction;
performing the write operation on a current page, which is a latest version before the write operation is performed, to obtain a new page;
setting a timestamp of the new page according to the timestamp of the write operation transaction; and
setting rollback information of the new page, wherein the rollback information comprises a page pointer which points to the current page and a record pointer which points to a previous record, a rollback record, or a to be deleted record.
2. The method according to claim 1, wherein performing the write operation on the current page according to the data writing operation request to obtain the new page comprises updating a record on the current page according to an indication of the data writing operation request to obtain the new page when the data writing operation request requests to update the record, and wherein the record pointer of the new page is set to point to the previous record, which is the record prior to the update on the current page.
3. The method according to claim 1, wherein performing the write operation on the current page according to the data writing operation request to obtain a new page comprises inserting, on the current page, a record that is requested to be inserted by the data writing operation request to obtain the new page and storing the current page and the new page, wherein the record pointer of the new page is set to point to a rollback record corresponding to the inserted record, and wherein the rollback record comprises information that the record that is requested to be inserted by the data writing operation request has been deleted from the current page.
4. The method according to claim 1, wherein performing the write operation on the current page according to the data writing operation request to obtain the new page comprises marking, on the current page, a record that is requested to be deleted by the data writing operation request as deleted to obtain the new page when the data writing operation request requests to delete the record, and wherein the record pointer of the new page is marked as deleted and is set to point to the to be deleted record that is requested to be deleted by the data writing operation request from the current page.
5. The method according to claim 1, wherein setting the timestamp of the new page according to the timestamp of the write operation transaction comprises:
setting a timestamp of the current page as the timestamp of the new page when the timestamp of the current page is greater than the timestamp of the write operation transaction; and
setting the timestamp of the new page to the timestamp of the write operation transaction when the timestamp of the current page is less than the timestamp of the write operation transaction.
6. The method according to claim 1, further comprising updating the transaction link in the database such that the transaction link comprises an operation transaction pointer of the write operation transaction.
7. A database system having a database, comprising:
a memory storing computer readable instructions; and
a processor coupled to the memory and configured to:
receive a data writing operation request generated by a write operation transaction, wherein the data writing operation request is used to request to perform a write operation, and wherein the data writing operation request comprises a timestamp of the write operation transaction;
perform the write operation on a current page, which is a latest version before the write operation is performed, to obtain a new page;
set a timestamp of the new page according to the timestamp of the write operation transaction; and
set rollback information of the new page, wherein the rollback information comprises a page pointer which points to the current page and a record pointer which points to a previous record, a rollback record, or a to be deleted record.
8. The database system according to claim 7, wherein the processor is further configured to update a record on the current page according to an indication of the data writing operation request to obtain the new page when the data writing operation request requests to update the record, and wherein the record pointer of the new page is set to point to the previous record, which is the record prior to the update on the current page.
9. The database system according to claim 7, wherein the processor is further configured to insert, on the current page, a record that is requested to be inserted by the data writing operation request to obtain the new page and storing the current page and the new page, wherein the record pointer of the new page is set to point to a rollback record corresponding to the inserted record, and wherein the rollback record comprises information that the record that is requested to insert by the data writing operation request has been deleted from the current page.
10. The database system according to claim 7, wherein the processor is further configured to mark, on the current page, a record that is requested to be deleted by the data writing operation request as deleted to obtain the new page when the data writing operation request requests to delete the record, and wherein the record pointer of the new page is marked as deleted and is set to point to the to be deleted record that is requested to be deleted by the data writing operation request from the current page.
11. The database system according to claim 7, wherein the processor is further configured to:
set a timestamp of the current page as the timestamp of the new page when the timestamp of the current page is greater than the timestamp of the write operation transaction; and
set the timestamp of the new page to the timestamp of the write operation transaction when the timestamp of the current page is less than the timestamp of the write operation transaction.
12. A non-transitory storage medium, comprising computer readable instructions which read by one or more processors to implement:
receiving a data writing operation request generated by a write operation transaction, wherein the data writing operation request is used to request to perform a write operation, and wherein the data writing operation request comprises a timestamp of the write operation transaction;
performing the write operation on a current page, which is a latest version before the write operation is performed, to obtain a new page;
setting a timestamp of the new page according to the timestamp of the write operation transaction; and
setting rollback information of the new page, wherein the rollback information comprises a page pointer which points to the current page and a record pointer which points to a previous record, a rollback record, or a to be deleted record.
13. The non-transitory storage medium according to claim 12, wherein the one or more processors are further configured to update a record on the current page according to an indication of the data writing operation request to obtain the new page when the data writing operation request requests to update the record, and wherein the record pointer of the new page is set to point to the previous record, which is the record prior to the update on the current page.
14. The non-transitory storage medium according to claim 12, wherein the one or more processors are further configured to insert, on the current page, a record that is requested to be inserted by the data writing operation request to obtain the new page and storing the current page and the new page, wherein the record pointer of the new page is set to point to a rollback record corresponding to the inserted record, and wherein the rollback record comprises information that the record that is requested to be inserted by the data writing operation request has been deleted from the current page.
15. The non-transitory storage medium according to claim 12, wherein the one or more processors are further configured to mark, on the current page, a record that is requested to be deleted by the data writing operation request as deleted to obtain the new page when the data writing operation request requests to delete the record, and wherein the record pointer of the new page is marked as deleted and is set to point to the to be deleted record that is requested to be deleted by the data writing operation request from the current page.
US15/919,469 2013-12-31 2018-03-13 Multi-Version Concurrency Control Method in Database and Database System Abandoned US20180203888A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US15/919,469 US20180203888A1 (en) 2013-12-31 2018-03-13 Multi-Version Concurrency Control Method in Database and Database System

Applications Claiming Priority (5)

Application Number Priority Date Filing Date Title
CN201310750940.8A CN103744936B (en) 2013-12-31 2013-12-31 Multi-version concurrency control method in database and database system
CN201310750940.8 2013-12-31
PCT/CN2014/082794 WO2015101025A1 (en) 2013-12-31 2014-07-23 Multi-version concurrency control method in database, and database system
US15/199,181 US9953051B2 (en) 2013-12-31 2016-06-30 Multi-version concurrency control method in database and database system
US15/919,469 US20180203888A1 (en) 2013-12-31 2018-03-13 Multi-Version Concurrency Control Method in Database and Database System

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
US15/199,181 Continuation US9953051B2 (en) 2013-12-31 2016-06-30 Multi-version concurrency control method in database and database system

Publications (1)

Publication Number Publication Date
US20180203888A1 true US20180203888A1 (en) 2018-07-19

Family

ID=50501954

Family Applications (2)

Application Number Title Priority Date Filing Date
US15/199,181 Active US9953051B2 (en) 2013-12-31 2016-06-30 Multi-version concurrency control method in database and database system
US15/919,469 Abandoned US20180203888A1 (en) 2013-12-31 2018-03-13 Multi-Version Concurrency Control Method in Database and Database System

Family Applications Before (1)

Application Number Title Priority Date Filing Date
US15/199,181 Active US9953051B2 (en) 2013-12-31 2016-06-30 Multi-version concurrency control method in database and database system

Country Status (4)

Country Link
US (2) US9953051B2 (en)
EP (1) EP3079078B1 (en)
CN (1) CN103744936B (en)
WO (1) WO2015101025A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10623247B2 (en) 2015-03-16 2020-04-14 Canon Kabushiki Kaisha Information processing apparatus performing synchronization of data and data synchronization methods

Families Citing this family (31)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103744936B (en) * 2013-12-31 2017-02-08 华为技术有限公司 Multi-version concurrency control method in database and database system
CN105574022B (en) * 2014-10-14 2020-04-17 阿里巴巴集团控股有限公司 Method and device for processing business object based on relational database
US9928264B2 (en) * 2014-10-19 2018-03-27 Microsoft Technology Licensing, Llc High performance transactions in database management systems
CN104317944B (en) * 2014-10-31 2018-07-06 上海实方软件有限公司 A kind of timestamp dynamic adjustment concurrency control method based on formula
JP6611594B2 (en) * 2015-03-16 2019-11-27 キヤノン株式会社 Information processing apparatus for synchronizing data, data synchronization method, and program
US9892004B2 (en) * 2015-09-18 2018-02-13 Vmware, Inc. Space efficient persistence of an in-memory table
CN107451172B (en) * 2016-03-31 2021-05-28 阿里巴巴集团控股有限公司 Data synchronization method and equipment for version management system
CN107577678B (en) * 2016-06-30 2021-02-09 华为技术有限公司 Method, client and server for processing database transaction
US10346384B2 (en) * 2016-11-22 2019-07-09 Sap Se Efficient database multi-version concurrency control
US10169392B2 (en) * 2017-03-08 2019-01-01 International Business Machines Corporation Persistent data structures on a dispersed storage network memory
CN107085603B (en) * 2017-03-31 2020-04-03 北京奇艺世纪科技有限公司 Data processing method and device
US10725763B1 (en) * 2017-06-28 2020-07-28 Amazon Technologies, Inc. Update and rollback of configurations in a cloud-based architecture
US10379838B1 (en) 2017-06-28 2019-08-13 Amazon Technologies, Inc. Update and rollback of code and API versions
CN109408673B (en) * 2018-09-06 2021-07-20 北京云迹科技有限公司 Map management method and management platform
CN109947742B (en) * 2019-02-28 2021-08-03 上海交通大学 Multi-version database concurrency control method and system for two-stage lock
CN110019375A (en) * 2019-04-18 2019-07-16 哈尔滨汇拓投资中心(有限合伙) It is a kind of based on the parallel mixed processing method of multi version polymerizeing online
US11321354B2 (en) * 2019-10-01 2022-05-03 Huawei Technologies Co., Ltd. System, computing node and method for processing write requests
US11836130B2 (en) * 2019-10-10 2023-12-05 Unisys Corporation Relational database blockchain accountability
CN110825752B (en) * 2019-10-16 2020-11-10 深圳巨杉数据库软件有限公司 Database multi-version concurrency control system based on fragment-free recovery
CN111090663B (en) * 2019-12-25 2023-07-07 上海金仕达软件科技股份有限公司 Transaction concurrency control method, device, terminal equipment and medium
CN111159160B (en) * 2019-12-31 2023-06-20 卓米私人有限公司 Version rollback method and device, electronic equipment and storage medium
CN113127440A (en) * 2019-12-31 2021-07-16 阿里巴巴集团控股有限公司 Data operation method and device, electronic equipment and storage medium
CN111459920B (en) * 2020-05-15 2021-01-15 北京谷数科技股份有限公司 Multi-version concurrency control method and system based on virtual global clock synchronization
JP2022039654A (en) * 2020-08-28 2022-03-10 キオクシア株式会社 Memory system
US11714573B1 (en) 2021-03-29 2023-08-01 Amazon Technologies, Inc. Storage optimization in a distributed object store
US11709809B1 (en) 2021-03-29 2023-07-25 Amazon Technologies, Inc. Tree-based approach for transactionally consistent version sets
US11599514B1 (en) * 2021-03-29 2023-03-07 Amazon Technologies, Inc. Transactional version sets
US11886422B1 (en) 2021-03-29 2024-01-30 Amazon Technologies, Inc. Transactional protocol for snapshot isolation without synchronized clocks
CN114297217A (en) * 2021-12-31 2022-04-08 深圳市兆珑科技有限公司 Transaction concurrency control method and device, electronic equipment and readable storage medium
US20240061786A1 (en) * 2022-08-22 2024-02-22 Samsung Electronics Co., Ltd. Systems, methods, and apparatus for accessing data in versions of memory pages
US12067003B2 (en) * 2022-11-28 2024-08-20 Sap Se Performance enhancement for writing database pages

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5287496A (en) * 1991-02-25 1994-02-15 International Business Machines Corporation Dynamic, finite versioning for concurrent transaction and query processing
US6125368A (en) * 1997-02-28 2000-09-26 Oracle Corporation Fault-tolerant timestamp generation for multi-node parallel databases
US7395278B2 (en) * 2003-06-30 2008-07-01 Microsoft Corporation Transaction consistent copy-on-write database
US7146386B2 (en) * 2004-03-29 2006-12-05 Microsoft Corporation System and method for a snapshot query during database recovery
US8856083B2 (en) * 2006-06-09 2014-10-07 Oracle International Corporation Framework to optimize delete all row operations on database objects to improve throughput, query ability and flashback
US8200914B2 (en) * 2008-01-03 2012-06-12 International Business Machines Corporation Apparatus, system, and method for a read-before-write storage controller instruction
US8396831B2 (en) * 2009-12-18 2013-03-12 Microsoft Corporation Optimistic serializable snapshot isolation
US8407195B2 (en) * 2011-03-07 2013-03-26 Microsoft Corporation Efficient multi-version locking for main memory databases
CN102591993A (en) * 2012-02-16 2012-07-18 中国工商银行股份有限公司 Asynchronous processing method and device for hotlist data update
US9053003B2 (en) * 2012-06-21 2015-06-09 Microsoft Technology Licensing, Llc Memory compaction mechanism for main memory databases
CN103744936B (en) * 2013-12-31 2017-02-08 华为技术有限公司 Multi-version concurrency control method in database and database system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10623247B2 (en) 2015-03-16 2020-04-14 Canon Kabushiki Kaisha Information processing apparatus performing synchronization of data and data synchronization methods

Also Published As

Publication number Publication date
US20160314161A1 (en) 2016-10-27
EP3079078A4 (en) 2017-01-25
US9953051B2 (en) 2018-04-24
WO2015101025A1 (en) 2015-07-09
EP3079078B1 (en) 2018-11-28
CN103744936A (en) 2014-04-23
CN103744936B (en) 2017-02-08
EP3079078A1 (en) 2016-10-12

Similar Documents

Publication Publication Date Title
US9953051B2 (en) Multi-version concurrency control method in database and database system
CN105630863B (en) Transaction control block for multi-version concurrent commit status
US10706036B2 (en) Systems and methods to optimize multi-version support in indexes
CN107077495B (en) High performance transactions in a database management system
US9058351B2 (en) Apparatus and method for read optimized bulk data storage
US9881041B2 (en) Multiple RID spaces in a delta-store-based database to support long running transactions
US9639542B2 (en) Dynamic mapping of extensible datasets to relational database schemas
US9171027B2 (en) Managing a multi-version database
US9020916B2 (en) Database server apparatus, method for updating database, and recording medium for database update program
US8856083B2 (en) Framework to optimize delete all row operations on database objects to improve throughput, query ability and flashback
US11487714B2 (en) Data replication in a data analysis system
US8954407B2 (en) System and method for partially deferred index maintenance
US10007548B2 (en) Transaction system
US11372883B2 (en) Apparatus for calculating size of processing unit, method for calculating size of processing unit, and non-transitory computer-readable storage medium for storing program
CN118575166A (en) Data aggregation system

Legal Events

Date Code Title Description
AS Assignment

Owner name: HUAWEI TECHNOLOGIES CO., LTD., CHINA

Free format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNORS:WEN, JIJUN;NIE, YUANYUAN;LI, JIAN;REEL/FRAME:045186/0649

Effective date: 20150922

STPP Information on status: patent application and granting procedure in general

Free format text: DOCKETED NEW CASE - READY FOR EXAMINATION

STPP Information on status: patent application and granting procedure in general

Free format text: NON FINAL ACTION MAILED

STPP Information on status: patent application and granting procedure in general

Free format text: RESPONSE TO NON-FINAL OFFICE ACTION ENTERED AND FORWARDED TO EXAMINER

STPP Information on status: patent application and granting procedure in general

Free format text: FINAL REJECTION MAILED

STPP Information on status: patent application and granting procedure in general

Free format text: RESPONSE AFTER FINAL ACTION FORWARDED TO EXAMINER

STPP Information on status: patent application and granting procedure in general

Free format text: ADVISORY ACTION MAILED

STPP Information on status: patent application and granting procedure in general

Free format text: DOCKETED NEW CASE - READY FOR EXAMINATION

STPP Information on status: patent application and granting procedure in general

Free format text: NON FINAL ACTION MAILED

STPP Information on status: patent application and granting procedure in general

Free format text: RESPONSE TO NON-FINAL OFFICE ACTION ENTERED AND FORWARDED TO EXAMINER

STPP Information on status: patent application and granting procedure in general

Free format text: FINAL REJECTION MAILED

STCB Information on status: application discontinuation

Free format text: ABANDONED -- FAILURE TO RESPOND TO AN OFFICE ACTION