WO2023124421A1 - 事务并发控制方法、装置、电子设备及可读存储介质 - Google Patents

事务并发控制方法、装置、电子设备及可读存储介质 Download PDF

Info

Publication number
WO2023124421A1
WO2023124421A1 PCT/CN2022/125971 CN2022125971W WO2023124421A1 WO 2023124421 A1 WO2023124421 A1 WO 2023124421A1 CN 2022125971 W CN2022125971 W CN 2022125971W WO 2023124421 A1 WO2023124421 A1 WO 2023124421A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
record
version number
target record
target
Prior art date
Application number
PCT/CN2022/125971
Other languages
English (en)
French (fr)
Inventor
王剑
Original Assignee
深圳市兆珑科技有限公司
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 深圳市兆珑科技有限公司 filed Critical 深圳市兆珑科技有限公司
Publication of WO2023124421A1 publication Critical patent/WO2023124421A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating

Definitions

  • the read operation belongs to the first transaction, and the target record is the record created by the second transaction;
  • the deletion version number is not empty, and the deletion version number is not equal to the unique identifier of the first transaction, determine whether the creation version number and the deletion version number are in the transaction registry list;
  • the method before acquiring the read operation on the target record, the method further includes:
  • the record lock information is the first value and the deletion version number is empty, then in response to the deletion operation, the record lock information is changed from the first value to the second value, and the deletion version number is set as the unique identifier of the first transaction;
  • the method further includes:
  • Methods after deleting the information of the first transaction from the transaction registration list, deleting the target record from the physical storage space, and changing the status information from the third value to the fourth value, Methods also include:
  • the record lock information as the first value, clear the deletion version number, set the status information as the third value, set the creation version number as the unique identifier of the second transaction, and restore the target record.
  • the embodiment of the present application provides a transaction concurrency control device, including:
  • An acquisition module configured to acquire a read operation for a target record, where the read operation belongs to the first transaction, and the target record is a record created by the second transaction;
  • a judging module configured to judge the creation version if it is determined according to the status information that the target record is in a valid state, it is determined according to the record lock information that the target record has not been deleted, and the deletion version number is empty, and the creation version number is not equal to the unique identifier of the first transaction Whether the number is in the transaction registration list;
  • the reading module is used to read the target record if the creation version number is not in the transaction registration list;
  • a determining module configured to determine that the target record is unreadable for the first transaction if the creation version number is in the transaction registration list.
  • the embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and operable on the processor.
  • the processor executes the computer program, any one of the above-mentioned first aspects can be realized. Methods.
  • an embodiment of the present application is a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method according to any one of the above-mentioned first aspects is implemented.
  • an embodiment of the present application provides a computer program product, which, when the computer program product is run on an electronic device, causes the electronic device to execute the method described in any one of the foregoing first aspects.
  • FIG. 1 is a schematic flow diagram of a transaction concurrency control method provided in an embodiment of the present application
  • Fig. 2 is another schematic flow diagram of the transaction concurrency control method provided by the embodiment of the present application.
  • FIG. 3 is a structural block diagram of a transaction concurrency control device provided by an embodiment of the present application.
  • FIG. 4 is a schematic block diagram of the structure of an electronic device provided by an embodiment of the present application.
  • the term “if” may be construed, depending on the context, as “when” or “once” or “in response to determining” or “in response to detecting “.
  • the phrase “if determined” or “if [the described condition or event] is detected” may be construed, depending on the context, to mean “once determined” or “in response to the determination” or “once detected [the described condition or event] ]” or “in response to detection of [described condition or event]”.
  • references to "one embodiment” or “some embodiments” or the like in the specification of the present application means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application.
  • appearances of the phrases “in one embodiment,” “in some embodiments,” “in other embodiments,” “in other embodiments,” etc. in various places in this specification are not necessarily All refer to the same embodiment, but mean “one or more but not all embodiments” unless specifically stated otherwise.
  • the terms “including”, “comprising”, “having” and variations thereof mean “including but not limited to”, unless specifically stated otherwise.
  • FIG. 1 is a schematic flow chart of a transaction concurrency control method provided in the embodiment of the present application.
  • the method may include the following steps:
  • Step S101 Obtain a read operation on a target record, the read operation belongs to the first transaction, and the target record is a record created by the second transaction.
  • the database includes multiple records, and the above target record is one of the multiple records in the database.
  • a transaction includes a series of data operations, for example, a transaction includes a record 1 creation operation and a record 2 deletion operation.
  • the above-mentioned first transaction includes the above-mentioned read operation, and the read operation is used to query or read the target record.
  • the target record is created by the second transaction, ie the second transaction includes a create operation for creating the target record.
  • the second transaction creates the above-mentioned target record by executing the create operation.
  • the create operation of the second transaction can be obtained first, and the create operation is used to create the target record; in response to the create operation, the record lock information is set to the first value, the state information is set to the third value, and the created The version number is set to uniquely identify the second transaction. At this time, the creation version number is equal to the unique identifier of the second transaction.
  • Step S102 in response to the read operation, obtain the record header data of the target record, the record header data includes record lock information, status information, creation version number and deletion version number, the record lock information is used to describe whether the target record is deleted, and the status information uses To describe whether the target record is valid, the creation version number is used to describe the unique identifier of the transaction that created the target record, and the deletion version number is used to describe the unique identifier of the transaction that deleted the target record.
  • an implicit record header data structure is added in front of each record in the database.
  • the record header data structure may include record lock, status, creation version number and deletion version number.
  • record lock a record lock, status, creation version number and deletion version number.
  • the above value of the record lock is used to indicate whether the record is deleted. For example, a record lock is set to 1 when the record is deleted, and is set to 0 when the record is not deleted.
  • the value of the state is used to indicate whether the record is in a valid state or in an invalid state. For example, when the record is valid, the value of the state is set to 1, and the physical storage space corresponding to the record stores valid record data; when the record is invalid, the value of the state is set to 0, and the corresponding Physical storage space is either free or reclaimed.
  • the creation version number is used to represent the unique identifier of the transaction that created the record. For example, if the record is created by the transaction whose transaction unique identifier is 1, then the creation version number of the record is 1.
  • the delete version number is used to represent the unique identifier of the transaction that deletes the record. For example, if the transaction whose unique identifier is 2 deletes the record, then the deletion version number of the record is 2.
  • the unique identifier of a transaction is usually a transaction ID.
  • Each transaction will apply for a globally unique ID from the database system when it is created, and the system will maintain a sequence of transaction IDs.
  • the transaction ID sequence is incremented after each transaction application. During the entire life cycle of the database, it can be ensured that each transaction ID will not be repeated, and it will be incremented sequentially.
  • the lifecycle of a transaction starts from creation and ends with transaction commit or transaction rollback.
  • the above-mentioned record lock is a mutual exclusion lock, which can realize mutual exclusion access to critical resources.
  • There is only one 1-byte mutex variable inside that is, the value only has two states of 0 and non-0), which is defined as follows:
  • Mutex has two operations of locking and unlocking: lock(c_mutex_t *) and unlock(c_mutex_t *).
  • lock(c_mutex_t *) and unlock(c_mutex_t *) Use the function __sync_bool_compare_and_swap to realize the lock function.
  • c_mutex_t After the lock is successfully added, the value of c_mutex_t is non-zero; use the function __sync_lock_release to realize the release function. After the lock is released, the value of c_mutex_t is 0.
  • the record lock information refers to the value of the record lock
  • the state information refers to the value of the state.
  • the embodiment of the present application realizes a transaction concurrency control scheme different from the existing one through the above-mentioned record header data, and can realize the read committed transaction isolation level without dirty read problem.
  • Step S103 if it is determined according to the state information that the target record is in a valid state, and according to the record lock information it is determined that the target record has not been deleted, and the deletion version number is empty, and the creation version number is not equal to the unique identifier of the first transaction, then it is judged whether the creation version number is in the transaction registry list.
  • the database system can determine whether the target record is visible to the first transaction according to the record header data. Whether it is visible to the transaction refers to whether the record can be displayed through the select operation.
  • the state information is the third value, it is determined that the target record is in a valid state; when the state information is the fourth value, it is determined that the target record is in an invalid state.
  • the third value is 1, and the fourth value is 0 accordingly.
  • the record lock information is the first value, it is determined that the target record is not deleted, and if the record lock information is the second value, it is determined that the target record is deleted. For example, the first value is 1 and the second value is 0. If the record has not been deleted, the deletion version number is empty.
  • the creation version number is not equal to the unique identifier of the first transaction, it indicates that the target record was not created by the first transaction; if the creation version number is equal to the unique identifier of the first transaction, it indicates that the target record was created by the first transaction. At this time, the target record is created by the second transaction, so the creation version number of the record header data of the target record is the unique identifier of the second transaction.
  • the database system maintains a transaction registration list, which records the information of all online transactions in the current system (for example, including key information such as transaction ID, creation time, process to which it belongs).
  • the transactions in the transaction registration list are all online, that is, the transactions have not been committed or rolled back. All transactions will be removed from this transaction registration list after committing or rolling back. Therefore, it can be judged whether the transaction has been committed or rolled back by judging whether the transaction is in the transaction registration list.
  • Step S104 if the creation version number is not in the transaction registration list, read the target record.
  • Step S105 if the creation version number is in the transaction registration list, it is determined that the target record is unreadable for the first transaction.
  • the creation version number is in the transaction registration list, it indicates that the second transaction has not been submitted, and the target record is unreadable for the first transaction, that is, the target record is invisible to other transactions. Therefore, other transactions cannot read the target record.
  • creation version number is not in the transaction registration list, it indicates that the second transaction has been submitted.
  • the fact that the second transaction has been committed indicates that the target record is visible to other transactions, and other transactions can read the target record. At this point, the target record is read in response to the read operation on the target record.
  • the target record is in a valid state, has not been deleted and the deletion version number is empty, and further judges whether the creation version number is In the transaction registration list, if it exists, it indicates that the second transaction has not been submitted, and the target record is unreadable for the first transaction; if not, it indicates that the second transaction has been committed, and the target record is available for the first transaction If it is read, then the first transaction can read the target record. In this way, the transaction concurrency control of the database is realized, and the transaction isolation level of the read committed level (Read Commit) is realized, and the problem of dirty reading will not occur.
  • Read Commit the transaction isolation level of the read committed level
  • the deletion version number is not equal to the unique identifier of the first transaction. If the creation version number is not in the transaction registration list and the deletion version number is in the transaction list, then read the target record; if the creation version number is not in the transaction registration list, and the deletion version number is not in the transaction list, then determine the target record. Transaction is not readable.
  • the deletion version number is not empty, and the deletion version number is not equal to the unique identifier of the first transaction, it indicates that other transactions have deleted the target record. However, at this time, the target record is still in a valid state, and it is further judged whether other transactions have submitted deletion operations. If other transactions have been committed, all transactions cannot read the target record, that is, the target record is invisible to all transactions. Transactions other than the transaction that deleted the target record can read the target record if other transactions have not committed.
  • judging whether the transaction is submitted can be judged by judging whether the transaction is in the transaction registration list.
  • the delete version number of the target record is not empty, that is, other transactions can perform delete operations on the target record, it indicates that the transaction that created the target record has been committed, and the target record can be read by other transactions. Therefore, the creation version number is not in the transaction registration list.
  • the deleted version number is in the transaction registration list. If yes, it means that the transaction that deletes the target record has not been submitted, other transactions can also read the target record, and the first transaction can read the target record. If not, it means that the transaction to delete the target record has been submitted, and other transactions cannot read the target record.
  • the target record is unreadable by the first transaction.
  • the deletion version number is not empty, and the deletion version number is equal to the unique identifier of the first transaction, it indicates that the first transaction A transaction is a transaction that deletes the target record.
  • the first transaction performs the above-mentioned read operation after performing the delete operation on the target record. Since the target record is still in a valid state and has not been actually deleted, the target record is readable for other transactions. But for the first transaction, the target record is a deleted record and is unreadable, that is, it is determined that the target record is unreadable for the first transaction.
  • the method may include the following steps:
  • Step S201 Obtain a delete operation for the target record, and the delete operation belongs to the first transaction;
  • the first transaction first queries or reads the target record, that is, first performs a read operation on the target record to read the target record, and then deletes the target record.
  • Step S202 Obtain a read operation on a target record, the read operation belongs to the first transaction, and the target record is a record created by the second transaction.
  • Step S203 in response to the read operation, obtain the record header data of the target record, the record header data includes record lock information, status information, creation version number and deletion version number, the record lock information is used to describe whether the target record is deleted, and the status information uses To describe whether the target record is valid, the creation version number is used to describe the unique identifier of the transaction that created the target record, and the deletion version number is used to describe the unique identifier of the transaction that deleted the target record.
  • Step S204 if it is determined according to the state information that the target record is in a valid state, and according to the record lock information it is determined that the target record has not been deleted, and the deletion version number is empty, and the creation version number is not equal to the unique identifier of the first transaction, then judge whether the creation version number is in the transaction registry list.
  • Step S205 if the creation version number is not in the transaction registration list, read the target record.
  • step S202 to step S205 can be referred to above, and will not be repeated here.
  • Step S206 if the record lock information is the first value and the deletion version number is empty, then in response to the deletion operation, change the record lock information from the first value to the second value, and set the deletion version number as the unique value of the first transaction logo.
  • the first transaction can apply for a record lock to delete the target record.
  • the record lock can prevent uncommitted transactions from repeatedly deleting the same record, that is, for a record, if transaction 1 performs a delete operation on the record, the record lock information of the record is set to the second value. At this time, if transaction 2 applies for deleting the record, since the record lock information has been set to the second value, transaction 2 fails to apply for the record lock, and cannot delete the record. This prevents duplicate deletions.
  • Step S207 after the first transaction submits the delete operation, delete the information of the first transaction from the transaction registration list, delete the target record from the physical storage space, and change the status information from the third value to the fourth value; wherein, The first value indicates that the target record is not deleted, the second value indicates that the target record is deleted; the third value indicates that the target record is in a valid state, and the fourth value indicates that the target record is in an invalid state.
  • the above-mentioned record lock information is the second value, and the deletion version number is not empty, it indicates that the target record has been deleted by other transactions, and the first transaction cannot be repeatedly deleted. At this time, in response to the deletion operation , it is determined that the target record cannot be deleted by the first transaction, that is, the target record cannot be deleted by the first transaction.
  • the embodiment of the present application prevents repeated deletion of records based on the record lock, status, creation version number and deletion version number in the record header data.
  • the transaction is rolled back to undo all the changes in the transaction, so that the changed records are rolled back to the state before the transaction was created.
  • a rollback operation for the first transaction may be performed.
  • the first transaction includes the deletion operation on the target record, and the deletion of the target record can be undone through the rollback operation.
  • undo log data (undo log) of the first transaction is acquired first.
  • the undo log data tracks and records the change content of each operation in the transaction, records which records are created in the current transaction, and which records are deleted in the current transaction, and these records are used to roll back the transaction .
  • Each transaction corresponds to an undo log.
  • the altering operation of the first transaction includes the delete operation for the target record
  • the undo log data of the first transaction includes the relevant information of the target record, based on the relevant information of the target record in the undo log data, the first The transaction is rolled back to restore the deleted target record.
  • the record lock information of the target record can be set as the first value
  • the deletion version number can be cleared
  • the status information can be set as the third value
  • the creation version number can be set as the unique identifier of the second transaction, and restore the target record.
  • the change operation of the first transaction also includes a create operation
  • the record created by the first transaction is deleted in the rollback operation.
  • transaction A initiates a rollback request after creating record 1 and deleting record 2.
  • Record 2 was created by transaction C.
  • transaction A creates record 1 first, and then deletes record 2, so the undo operation is performed in the reverse order during the rollback operation, that is, record 2 is restored first, and record 1 is then deleted.
  • the recovery process is performed on record 2 first, the record lock of record 2 is cleared, and the deleted version number is cleared.
  • the record header data of record 2 is exemplified as follows: the record lock is 0, the record status is 1, and the version number is created The number is the ID of transaction C, and the deletion version number is empty; then delete record 1, first set the record lock of record 1 to 1, and set the deletion version number to the ID of transaction A, at this time the record header of record 1
  • the data is exemplified as follows: the record lock is 1, the record status is 1, the creation version number is the ID of transaction A, and the deletion version number is the ID of transaction A. After undoing all the records in the undo log, remove the information of transaction A from the transaction registration list.
  • the record header data of record 1 can be queried for example: the record lock is 1, the record status is 1, the creation version number is the ID of transaction A, and the deletion version number is the ID of transaction A ; Extract the creation version number and deletion version number of record 1, query the transaction registration list, and find that the deletion transaction A of record 1 has been submitted, then determine that record 1 is not visible.
  • record 1 there is another possibility.
  • the system will initiate a space reclamation operation to reclaim storage space for those deleted records, and set the record status of record 1 to 0, indicating that record 1 is no longer in the system.
  • transaction B cannot query the data of record 1 from the storage level, let alone see record 1 from the transaction level.
  • record 2 the record header data of record 2 is exemplified as follows: the record lock is 0, the record status is 1, the creation version number is the ID of transaction C, and the deletion version number is empty; extract the creation version number and After deleting the version number, by querying the transaction registration list, it is found that the creation transaction C of record 2 has been submitted, and the deletion version number is empty, so it is determined that record 2 is visible to transaction B.
  • the change operations on records include creating records (INSERT) and deleting records (DELETE).
  • INSERT INSERT
  • DELETE DELETE
  • create and delete records For any record in the database, it may be in any of the following four states: creating, created, deleting and deleted.
  • a record that is being created is only visible to the transaction that created it, not to other transactions. In other words, although the newly created record is already in the database, it has not yet officially taken effect because the transaction that created the record has not yet been committed.
  • the record When the record is in the created state, it indicates that the record has been created, and the transaction of creating the record has been committed. At this time, the recording header data of the record can be exemplarily shown in Table 2. Since the transaction that created the record has been committed, the created record is visible to all transactions, and the record has officially taken effect.
  • a record that is being deleted is not visible to the transaction that deleted it, but is still visible to other transactions.
  • the record is not actually deleted, but the record lock is set to 1 to prevent other transactions from repeatedly deleting the record, and the deleted version of the record is set to the current transaction ID, so that the record is invisible to the current transaction, but is not visible to the current transaction. Other transactions are still visible.
  • the state information is set to an invalid state, and the record is not visible to all transactions.
  • a new record 1 is created in transaction A.
  • the new record is in the state of "creating".
  • the example record header data is: the record lock is 0, the record status is 1, and the creation version number is the ID of transaction A. Delete version number is empty. Record 1 can only be seen by transaction A at this time, and transaction B cannot yet see the newly created record 1.
  • transaction A deletes record 2, which is invisible to transaction A, but for transaction B, record 2 still exists in the system at this time (that is, the record status is 1), so transaction B can Extract the "creation version number” and "deletion version number” of record 2, and check whether the deletion operation and the creation operation have been submitted by querying the transaction registration list.
  • transaction C of the creation operation of record 2 has been committed, and the transaction A of the deletion operation is still online and uncommitted, then it is determined that the record 2 is visible.
  • the device also includes:
  • the device also includes:
  • the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the procedures in the method of the above-mentioned embodiments in the present application can be completed by instructing related hardware through a computer program.
  • the computer program can be stored in a computer-readable storage medium.
  • the computer program When executed by a processor, the steps in the above-mentioned various method embodiments can be realized.
  • the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file or some intermediate form.
  • the disclosed devices, electronic devices and methods may be implemented in other ways.
  • the device/electronic device embodiments described above are only illustrative.
  • the division of the modules or units is only a logical function division.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

Landscapes

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

Abstract

本申请实施例公开了一种事务并发控制方法、装置、电子设备及计算机可读存储介质,用于实现数据库事务并发控制,实现读已提交级别的事务隔离等级。该方法包括:获取针对目标记录的第一事务的读操作;响应于读操作,获取目标记录的记录头数据,记录头数据包括用于描述是否被删除的记录锁信息、描述是否有效的状态信息、用于描述创建事务的标识的创建版本号和用于描述删除事务的标识的删除版本号;若根据状态信息确定目标记录处于有效状态,根据记录锁信息确定目标记录未被删除,且删除版本号为空,创建版本号不等于第一事务的唯一标识,则判断创建版本号是否在事务注册列表中;若不在则读取目标记录;若在则确定目标记录对第一事务不可读。

Description

事务并发控制方法、装置、电子设备及可读存储介质
本申请要求于2021年12月31日在中国专利局提交的、申请号为202111679155.9的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请属于数据库技术领域,尤其涉及一种事务并发控制方法、装置、电子设备及计算机可读存储介质。
背景技术
在数据库技术领域中,事务是指一组数据库操作序列,例如,某个事务包括记录创建操作和记录删除操作。
事务具有ACID特性。其中,A (Atomicity) 原子性:事务里的所有操作要么全部成功,要么全部失败,不能有部分生效或部分失的情况;C (Consistency) 一致性:事务的运行不会改变数据库原本的一致性约束,事务将数据库从一个一致状态变成另一个一致状态;I (Isolation) 隔离性,所谓的独立性是指并发的事务之间不会互相影响,比如一个事务要访问的数据正在被另外一个事务修改,只要另外一个事务还未提交,它所访问的数据就不受未提交事务的影响;D (Durability) 持久性,数据一旦提交就会永久生效。
多个事务可以并发,事务并发可能会出现脏读问题。
技术问题
本申请实施例提供一种事务并发控制方法、装置、电子设备及计算机可读存储介质,用于实现数据库的事务并发控制,实现读已提交级别的事务隔离等级,不会出现脏读问题。
技术解决方案
第一方面,本申请实施例提供一种事务并发控制方法,包括:
获取针对目标记录的读操作,读操作属于第一事务,目标记录为由第二事务创建的记录;
响应于读操作,获取目标记录的记录头数据,记录头数据包括记录锁信息、状态信息、创建版本号和删除版本号,记录锁信息用于描述目标记录是否被删除,状态信息用于描述目标记录是否有效,创建版本号用于描述创建目标记录的事务的唯一标识,删除版本号用于描述删除目标记录的事务的唯一标识;
若根据状态信息确定目标记录处于有效状态,根据记录锁信息确定目标记录未被删除,且删除版本号为空,创建版本号不等于第一事务的唯一标识,则判断创建版本号是否在事务注册列表中;
若创建版本号不在事务注册列表中,则读取目标记录;
若创建版本号在事务注册列表中,则确定目标记录对第一事务不可读。
本申请实施例中,根据记录头数据中的记录锁信息、状态信息、创建版本号和删除版本号,确定目标记录处于有效状态、未被删除且删除版本号为空,进一步判断创建版本号是否在事务注册列表中,如果在,则表明第二事务还未提交,该目标记录对于第一事务是不可读的,如果不在,则表明第二事务已提交,该目标记录对于第一事务是可读的,则第一事务则可以读取该目标记录。这样,实现了数据库的事务并发控制,实现读已提交级别(Read Commit)的事务隔离等级,不会出现脏读问题。
在第一方面的一些可能的实现方式中,在获取目标记录的记录头数据之后,方法还包括:
若根据状态信息确定目标记录处于有效状态,根据记录锁信息确定目标记录被删除,删除版本号不为空,且删除版本号不等于第一事务的唯一标识,判断创建版本号和删除版本号是否在事务注册列表中;
若创建版本号不在事务注册列表中且删除版本号在事务列表中,则读取目标记录;
若创建版本号不在事务注册列表中,且删除版本号不在事务列表中,则确定目标记录对第一事务不可读。
在第一方面的一些可能的实现方式中,在获取目标记录的记录头数据之后,方法还包括:
若根据状态信息确定目标记录处于无效状态,且根据记录锁信息确定目标记录被删除,则确定目标记录对第一事务不可读;
若根据状态信息确定目标记录处于有效状态,根据记录锁信息确定目标记录被删除,删除版本号不为空,且删除版本号等于第一事务的唯一标识,则确定目标记录对第一事务不可读。
在第一方面的一些可能的实现方式中,在获取针对目标记录的读操作之前,方法还包括:
获取针对目标记录的删除操作,删除操作属于第一事务;
在读取目标记录之后,方法还包括:
若记录锁信息为第一数值,且删除版本号为空,则响应于删除操作,将记录锁信息从第一数值变更为第二数值,将删除版本号设置为第一事务的唯一标识;
在第一事务提交删除操作后,从事务注册列表中删除第一事务的信息,将目标记录从物理存储空间中删除,并将状态信息从第三数值变更为第四数值;
其中,第一数值表征目标记录未被删除,第二数值表征目标记录被删除;第三数值表征目标记录处于有效状态,第四数值表征目标记录处于无效状态。
在第一方面的一些可能的实现方式中,在获取针对目标记录的删除操作之后,还包括:
若记录锁信息为第二数值,且删除版本号不为空,则响应于删除操作,确定目标记录对第一事务不可删除。
在第一方面的一些可能的实现方式中,方法还包括:
获取第二事务的创建操作,创建操作用于创建目标记录;
响应于创建操作,将记录锁信息设置为第一数值,将状态信息设置为第三数值,将创建版本号设置为第二事务的唯一标识。
在第一方面的一些可能的实现方式中,在从事务注册列表中删除第一事务的信息,将目标记录从物理存储空间中删除,并将状态信息从第三数值变更为第四数值之后,方法还包括:
获取第一事务的回滚操作;
响应于回滚操作,获取第一事务的撤销日志数据;
根据撤销日志数据,将记录锁信息设置为第一数值,将删除版本号清空,将状态信息设置为第三数值,将创建版本号设置为第二事务的唯一标识,并恢复目标记录。
第二方面,本申请实施例提供一种事务并发控制装置,包括:
获取模块,用于获取针对目标记录的读操作,读操作属于第一事务,目标记录为由第二事务创建的记录;
记录头数据获取模块,用于响应于读操作,获取目标记录的记录头数据,记录头数据包括记录锁信息、状态信息、创建版本号和删除版本号,记录锁信息用于描述目标记录是否被删除,状态信息用于描述目标记录是否有效,创建版本号用于描述创建目标记录的事务的唯一标识,删除版本号用于描述删除目标记录的事务的唯一标识;
判断模块,用于若根据状态信息确定目标记录处于有效状态,根据记录锁信息确定目标记录未被删除,且删除版本号为空,创建版本号不等于第一事务的唯一标识,则判断创建版本号是否在事务注册列表中;
读取模块,用于若创建版本号不在事务注册列表中,则读取目标记录;
确定模块,用于若创建版本号在事务注册列表中,则确定目标记录对第一事务不可读。
第三方面,本申请实施例提供一种电子设备,包括存储器、处理器以及存储在存储器中并可在处理器上运行的计算机程序,处理器执行计算机程序时实现如上述第一方面任一项的方法。
第四方面,本申请实施例一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,计算机程序被处理器执行时实现如上述第一方面任一项的方法。
第五方面,本申请实施例提供一种计算机程序产品,当计算机程序产品在电子设备上运行时,使得电子设备执行上述第一方面中任一项所述的方法。
可以理解的是,上述第二方面至第五方面的有益效果可以参见上述第一方面中的相关描述,在此不再赘述。
附图说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本申请实施例提供的事务并发控制方法的一种流程示意图;
图2为本申请实施例提供的事务并发控制方法的另一种流程示意框图;
图3为本申请实施例提供的事务并发控制装置的结构框图;
图4为本申请实施例提供的电子设备的结构示意框图。
本发明的实施方式
以下描述中,为了说明而不是为了限定,提出了诸如特定系统结构、技术之类的具体细节,以便透彻理解本申请实施例。然而,本领域的技术人员应当清楚,在没有这些具体细节的其它实施例中也可以实现本申请。在其它情况中,省略对众所周知的系统、装置、电路以及方法的详细说明,以免不必要的细节妨碍本申请的描述。
应当理解,当在本申请说明书和所附权利要求书中使用时,术语“包括”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。
还应当理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。
如在本申请说明书和所附权利要求书中所使用的那样,术语“如果”可以依据上下文被解释为“当...时”或“一旦”或“响应于确定”或“响应于检测到”。类似地,短语“如果确定”或“如果检测到[所描述条件或事件]”可以依据上下文被解释为意指“一旦确定”或“响应于确定”或“一旦检测到[所描述条件或事件]”或“响应于检测到[所描述条件或事件]”。
另外,在本申请说明书和所附权利要求书的描述中,术语“第一”、“第二”、“第三”等仅用于区分描述,而不能理解为指示或暗示相对重要性。
在本申请说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个或多个实施例中包括结合该实施例描述的特定特征、结构或特点。由此,在本说明书中的不同之处出现的语句“在一个实施例中”、“在一些实施例中”、“在其他一些实施例中”、“在另外一些实施例中”等不是必然都参考相同的实施例,而是意味着“一个或多个但不是所有的实施例”,除非是以其他方式另外特别强调。术语“包括”、“包含”、“具有”及它们的变形都意味着“包括但不限于”,除非是以其他方式另外特别强调。
请参见图1,为本申请实施例提供的事务并发控制方法的一种流程示意图,该方法可以包括以下步骤:
步骤S101、获取针对目标记录的读操作,该读操作属于第一事务,该目标记录为由第二事务创建的记录。
可以理解的是,数据库包括多条记录,上述目标记录是数据库多条记录中的一条。
事务包括一系列数据操作,例如,事务包括记录1的创建操作和记录2的删除操作。而上述第一事务包括上述读操作,该读操作用于查询或读取目标记录。
目标记录是由第二事务创建的,即第二事务包括用于创建目标记录的创建操作。第二事务通过执行该创建操作创建上述目标记录。在一些实施例中,可以先获取第二事务的创建操作,创建操作用于创建目标记录;响应于创建操作,将记录锁信息设置为第一数值,将状态信息设置为第三数值,将创建版本号设置为第二事务的唯一标识。此时,创建版本号等于第二事务的唯一标识。
步骤S102、响应于读操作,获取目标记录的记录头数据,记录头数据包括记录锁信息、状态信息、创建版本号和删除版本号,记录锁信息用于描述目标记录是否被删除,状态信息用于描述目标记录是否有效,创建版本号用于描述创建目标记录的事务的唯一标识,删除版本号用于描述删除目标记录的事务的唯一标识。
需要说明的是,本申请实施例为了实现事务并发控制,在数据库每条记录的前面增加了一个隐含的记录头数据结构。该记录头数据结构可以包括记录锁、状态、创建版本号和删除版本号,示例性地,参见下表1示出的记录头的结构。
表1
记录锁 状态 创建版本号 删除版本号 数据区
其中,上述记录锁的数值用于表征记录是否被删除。例如,当记录被删除时,记录锁被设置为1,当记录未被删除时,记录锁被设置为0。
状态的数值用于表征记录处于有效状态,还是处于无效状态。例如,当记录有效时,状态的数值设置为1,此时该记录对应的物理存储空间中存放的是有效记录数据;当记录无效时,状态的数值被设置为0,此时该记录对应的物理存储空间处于空闲状态或被回收。
创建版本号用于表征创建该记录的事务的唯一标识。例如,事务的唯一标识为1的事务创建了该记录,则该记录的创建版本号为1。
删除版本号用于表征删除该记录的事务的唯一标识。例如,事务的唯一标识为2的事务删除了该记录,则该记录的删除版本号为2。
可以理解的是,事务的唯一标识通常为事务的ID。每个事务在创建时均会向数据库系统申请一个全局唯一ID,并且,系统会维护一个事务ID序列。该事务ID序列在每次事务申请后递增,在数据库的整个生命周期内,可以确保每个事务ID不会重复,并且是依次递增。事务的生命周期从创建开始,到事务提交或事务回滚结束。
上述记录锁为互斥锁,其可以实现对临界资源的互斥访问。内部只有一个1字节的互斥变量(即值只有0和非0两种状态),定义如下:
typedef volatile unsigned char c_mutex_t;
互斥锁有加锁和解锁两个操作:lock(c_mutex_t *)和unlock(c_mutex_t *)。利用函数__sync_bool_compare_and_swap来实现加锁功能,加锁成功之后c_mutex_t的值为非0;用函数__sync_lock_release来实现释放锁功能,释放锁之后c_mutex_t的值为0。
记录锁信息是指记录锁的数值,状态信息是指状态的数值。
值得指出的是,本申请实施例通过上述记录头数据,实现了一种不同于现有的事务并发控制方案,并且能实现读已提交的事务隔离等级,不会出现脏读问题。
步骤S103、若根据状态信息确定目标记录处于有效状态,根据记录锁信息确定目标记录未被删除,且删除版本号为空,创建版本号不等于第一事务的唯一标识,则判断创建版本号是否在事务注册列表中。
在获得目标记录的记录头数据之后,数据库系统可以根据记录头数据,确定该目标记录是否对第一事务可见。对事务是否可见是指通过select操作是否可以展示出该记录。
具体应用中,如果状态信息为第三数值,则确定目标记录处于有效状态;当状态信息为第四数值,则确定目标记录处于无效状态。例如,第三数值为1,第四数值相应为0。
如果记录锁信息为第一数值,则确定目标记录未被删除,如果记录锁信息为第二数值,则确定目标记录被删除。例如,第一数值为1,第二数值为0。如果记录未被删除,则删除版本号为空。
创建版本号不等于第一事务的唯一标识,则表明目标记录不是第一事务创建的;如果创建版本号等于第一事务的唯一标识,则表明该目标记录是第一事务创建的。此时,目标记录为第二事务创建的,故目标记录的记录头数据的创建版本号为第二事务的唯一标识。
可以理解的是,数据库系统维护有一个事务注册列表,该事务注册列表记录了当前系统中所有在线的事务的信息(例如,包括事务的ID、创建时间、所属进程等关键信息)。在该事务注册列表中的事务都是在线的,即事务还未提交或回滚。所有事务在提交或回滚之后都会从这个该事务注册列表中移除。因此,可以通过判断事务是否在该事务注册列表中,来判断事务是否已经提交或是否回滚。
步骤S104、若创建版本号不在事务注册列表中,则读取目标记录。
步骤S105、若创建版本号在事务注册列表中,则确定目标记录对第一事务不可读。
可以理解的是,如果创建版本号在事务注册列表中,则表明第二事务还未提交,该目标记录对于第一事务是不可读的,即该目标记录对其他事务不可见。因此,其它事务读不出该目标记录。
如果创建版本号不在事务注册列表中,则表明第二事务已提交。第二事务已提交则表明该目标记录对其他事务是可见的,其它事务可以读取该目标记录。此时,则响应于针对目标记录的读操作,读取到该目标记录。
本申请实施例中,根据记录头数据中的记录锁信息、状态信息、创建版本号和删除版本号,确定目标记录处于有效状态、未被删除且删除版本号为空,进一步判断创建版本号是否在事务注册列表中,如果在,则表明第二事务还未提交,该目标记录对于第一事务是不可读的,如果不在,则表明第二事务已提交,该目标记录对于第一事务是可读的,则第一事务则可以读取该目标记录。这样,实现了数据库的事务并发控制,实现读已提交级别(Read Commit)的事务隔离等级,不会出现脏读问题。
基于上述任意实施例,在一些实施例中,在获取目标记录的记录头数据之后,如果根据状态信息确定目标记录处于有效状态,根据记录锁信息确定目标记录被删除,删除版本号不为空,且删除版本号不等于第一事务的唯一标识,则进一步判断创建版本号和删除版本号是否在事务注册列表中。如果创建版本号不在事务注册列表中且删除版本号在事务列表中,则读取目标记录;如果创建版本号不在事务注册列表中,且删除版本号不在事务列表中,则确定目标记录对第一事务不可读。
此时,删除版本号不为空,且删除版本号不等于第一事务的唯一标识,则表明有其它事务删除了该目标记录。但是,此时该目标记录还处于有效状态,则进一步判断其它事务是否已经提交了删除操作。如果其它事务已经提交,则所有事务均不可以读取该目标记录,即该目标记录对所有事务不可见。如果其它事务还没有提交,则除了删除该目标记录的事务外的其它事务可以读取该目标记录。
而判断是否事务是否提交可以通过判断事务是否在事务注册列表中来判断。此时,由于目标记录的删除版本号不为空,即其它事务可以对目标记录执行删除操作,则表明该创建该目标记录的事务已经提交,该目标记录可以被其它事务读取。因此,创建版本号不在事务注册列表中。
进一步地,判断删除版本号是否在事务注册列表中。如果在,则表明删除该目标记录的事务还未提交,其它事务还可以读取该目标记录,第一事务则可以读取该目标记录。如果不在,则表明删除该目标记录的事务已提交,其它事务不可读取该目标记录。
在一些实施例中,如果根据状态信息确定目标记录处于无效状态,且根据记录锁信息确定目标记录被删除,则确定目标记录对第一事务不可读。
可以理解的是,当删除该目标记录的事务提交后,该目标记录的存储空间会被系统回收,该目标记录真正地从系统上删除,然后将状态设置为第四数值,以表示该目标记录处于无效状态。因此,当确定出目标记录处于无效状态,则表明目标记录已经从存储空间中删除了,所有事务都不可读取该目标记录。
在另一些实施例中,如果根据状态信息确定目标记录处于有效状态,根据记录锁信息确定目标记录被删除,删除版本号不为空,且删除版本号等于第一事务的唯一标识,则表明第一事务是删除该目标记录的事务。此时,第一事务对目标记录执行删除操作后,再执行上述读操作。由于目标记录仍然处于有效状态,没有被真正的删除,对于其它事务来说,该目标记录是可读的。但对于第一事务来说,该目标记录是已经删除的记录,是不可读的,即确定目标记录对第一事务不可读。
基于上述任意实施例,参见图2示出的本申请实施例提供的事务并发控制方法的另一种流程示意框图,该方法可以包括以下步骤:
步骤S201、获取针对目标记录的删除操作,删除操作属于第一事务;
可以理解的是,第一事务在执行删除操作之前,先查询或读取目标记录,即先执行对目标记录的读操作,以读取到该目标记录,然后再删除该目标记录。
步骤S202、获取针对目标记录的读操作,该读操作属于第一事务,该目标记录为由第二事务创建的记录。
步骤S203、响应于读操作,获取目标记录的记录头数据,记录头数据包括记录锁信息、状态信息、创建版本号和删除版本号,记录锁信息用于描述目标记录是否被删除,状态信息用于描述目标记录是否有效,创建版本号用于描述创建目标记录的事务的唯一标识,删除版本号用于描述删除目标记录的事务的唯一标识。
步骤S204、若根据状态信息确定目标记录处于有效状态,根据记录锁信息确定目标记录未被删除,且删除版本号为空,创建版本号不等于第一事务的唯一标识,则判断创建版本号是否在事务注册列表中。
步骤S205、若创建版本号不在事务注册列表中,则读取目标记录。
其中,步骤S202~步骤S205的相关介绍可以参见上文,在此不再赘述。
步骤S206、若记录锁信息为第一数值,且删除版本号为空,则响应于删除操作,将记录锁信息从第一数值变更为第二数值,将删除版本号设置为第一事务的唯一标识。
在读取到目标记录之后,如果记录锁信息为第一数值,删除版本号为空,即该目标记录未被其它事务删除,此时,第一事务可以申请记录锁,以删除该目标记录。
记录锁可以防止未提交的事务对同一记录重复删除,即对于一个记录,如果有事务1对该记录执行了删除操作,则将该记录的记录锁信息设置为第二数值。此时,如果事务2申请对该记录进行删除,由于记录锁信息已经设置为第二数值,事务2申请记录锁失败,不能对该记录执行删除操作。这样可以防止重复删除。
步骤S207、在第一事务提交删除操作后,从事务注册列表中删除第一事务的信息,将目标记录从物理存储空间中删除,并将状态信息从第三数值变更为第四数值;其中,第一数值表征目标记录未被删除,第二数值表征目标记录被删除;第三数值表征目标记录处于有效状态,第四数值表征目标记录处于无效状态。
第一事务对目标记录删除时,先将记录锁信息从第一数值变更为第二数值,将删除版本号设置为第一事务的唯一标识,然后再第一事务提交后,删除操作生效,则从物理存储空间中删除该目标记录,以真正删除该目标记录。
在另一些实施例中,如果上述记录锁信息为第二数值,且删除版本号不为空,则表明该目标记录已经被其它事务删除,第一事务不可重复删除,此时,响应于删除操作,确定目标记录对第一事务不可删除,即第一事务不可删除该目标记录。
值的指出的是,本申请实施例基于记录头数据中的记录锁、状态、创建版本号和删除版本号,防止了记录的重复删除。
在另一些实施例中,如果事务中有失败操作,则对事务进行回滚,以撤销事务中所有的变更,让发生变更的记录回退到事务创建之前的状态。示例性地,如果第一事务中有失败操作,则可以执行针对第一事务的回滚操作。此时,第一事务包括上述针对目标记录的删除操作,通过回滚操作可以撤销对目标记录的删除。具体地,先获取到第一事务的撤销日志数据(undo日志)。其中,撤销日志数据跟踪记录了事务中每个操作的变更内容,记录了哪些记录是在当前事务中被创建的,哪些记录是在当前事务被删除的,这些记录用来对事务进行回滚操作。每个事务均对应一个撤销日志。在上述实施例中,第一事务的变更操作包括针对目标记录的删除操作,第一事务的撤销日志数据包括了目标记录的相关信息,基于撤销日志数据中的目标记录的相关信息,对第一事务进行回滚,以恢复所删除的目标记录。具体地,可以根据撤销日志数据,将目标记录的记录锁信息设置为第一数值,将删除版本号清空,将状态信息设置为第三数值,将创建版本号设置为第二事务的唯一标识,并恢复目标记录。
当然,如果第一事务的变更操作还包括创建操作,在回滚操作中则删除第一事务创建的记录。
例如,事务A在创建记录1和删除记录2后,发起回滚请求。记录2是事务C创建的。此时,事务A是先创建记录1,后删除记录2的,因此在回滚操作时以其相反顺序来进行撤销操作,即先恢复记录2,再删除记录1。具体地,先对记录2做恢复处理,首先将记录2的记录锁清零,将删除版本号清空,记录2的记录头数据则示例性为:记录锁为0,记录状态为1,创建版本号为事务C的ID,删除版本号为空;再对记录1做删除处理,先将记录1的记录锁置为1,将删除版本号设置为事务A的ID,此时记录1的记录头数据则示例性为:记录锁为1,记录状态为1,创建版本号为事务A的ID,删除版本号为事务A的ID。对undo日志中所有记录撤销之后,将事务A的信息从事务注册列表中移除。
在执行回滚操作后,其它事务查询不到记录1。假设此时事务B执行查询操作,则可以查询到记录1的记录头数据示例性为:记录锁为1,记录状态为1,创建版本号为事务A的ID,删除版本号为事务A的ID;提取记录1的创建版本号和删除版本号,通过查询事务注册列表,发现记录1的删除事务A已经提交,则确定记录1不可见。
对于记录1来说,还存在另一种可能,当事务A回滚后,系统会发起空间回收操作,对那些删除记录进行存储空间回收,并将记录1的记录状态设置为0,表明记录1已经不在系统中。此时事务B从存储层面上不能查询到记录1的数据,在事务层面上更不能看到记录1。而对于记录2来说,记录2的记录头数据示例性为:记录锁为0,记录状态为1,创建版本号为事务C的ID,删除版本号为空;提取记录2的创建版本号和删除版本号后,通过查询事务注册列表,发现记录2的创建事务C已经提交,删除版本号为空,则确定记录2对事务B是可见的。
需要说明的是,在数据库中,对记录的变更操作包括创建记录(INSERT)和删除记录(DELETE)。
在数据库中对记录的操作分为两种:INSERT和DELETE,就是创建记录和删除记录。对于数据库中的任一条记录,其可能处于以下4种状态的任意一种:创建中、已创建、删除中和已删除。
其中,当记录处于创建中的状态时,表明该记录正在被创建中,且创建该记录的事务还未提交。此时,该记录的记录头数据可以示例性如下表2:
表2
记录锁 状态 创建版本号 删除版本号
0 1 当前事务ID  
处于创建中的记录只对创建该记录的事务可见,对其他事务不可见。换句话说,新建的记录虽然已经在数据库中,但还未正式生效,因为创建记录的事务还未提交。
当记录处于已创建的状态时,表明该记录已经创建好了的,且创建的该记录的事务已经提交。此时,该记录的记录头数据可以示例性如表2。由于创建该记录的事务已经提交,已创建的记录对所有事务可见,该记录已经正式生效。
当记录处于删除中的状态时,表明该记录正在被删除中,删除的该记录的事务还未提交。此时,该记录的记录头数据可以示例性如下表3:
表3
记录锁 状态 创建版本号 删除版本号
1 1 创建事务ID 当前事务ID
处于删除中的记录记录对删除该记录的事务不可见,但对其它事务仍然可见。此时,该记录并没有被真正删除掉,只是将记录锁设置为1以防止其它事务重复删除该记录,并设置记录的删除版本为当前事务ID,这样该记录对当前事务不可见,但对其它事务仍然可见。
当记录处于已删除的状态时,表明该记录已经被删除,删除该记录的事务已经提交。此时,当记录的记录头数据如表3时,该记录对当前事务不可见,对其他事务可见。处于这个状态的记录会被系统回收存储空间,被回收存储空间后,该记录的记录头数据可以如下表4所示:
表4
记录锁 状态 创建版本号 删除版本号
1 0 创建事务ID 当前事务ID
此时,将状态信息设置为无效状态,该记录对所有事务均不可见。
例如,当前有事务A、事务B、事务C,事务A和事务B在线,即事务A和事务B都还处于未提交状态,事务A和事务B的信息还存在于事务注册列表中。事务C已经提交了的,即事务注册列表中不存在事务C的信息。
在事务A中创建了一条新记录1,此时,新记录处于“创建中”的状态,记录头数据示例性为:记录锁为0,记录状态为1,创建版本号为事务A的ID,删除版本号为空。记录1此时只能被事务A可见,事务B还不能看到新创建的记录1。
可以理解的是,对于事务B来说,尽管记录1已经存在于系统中(即记录1的状态为1),但是从记录1的“创建版本号”中提取出其创建事务ID后,通过查询系统事务注册列表,确定事务A仍然在线,即事务A此时还未提交,其它事务当前还不能“看到”事务A创建的记录1。
事务A删除了另外一条是在事务C中创建的记录2,此时,记录2的记录头数据示例性为:记录锁设置为1,记录状态为1,创建版本号为事务C的ID,删除版本号为事务A的ID。由于记录2处于“删除中”的状态,在事务A中记录2是不可见的,但对事务B来说记录2仍然是可见的。
在删除操作中,事务A删除了记录2,记录2对于事务A是不可见的,但对于事务B来说,此时记录2仍然存在于系统中(即记录状态为1),因此事务B可以提取记录2的“创建版本号”和“删除版本号”,通过查询事务注册列表,判断删除操作和创建操作是否已经提交。此时,发现记录2的创建操作的事务C已经提交,删除操作的事务A仍然在线未提交,则判定为记录2可见的。
可以理解的是,记录2对于事务B是可见的,但是由于记录2已经被事务A删除了,故事务B不能对记录2做删除操作,这样防止其它事务对记录2做重复删除操作。
需要说明的是,事务结束后,当事务中的所有操作都成功时,可以对事务作提交操作。事务提交之后,事务注册列表中该事务的信息会被移除,且事务中的所有变更内容正式生效,并且变更内容对其它事务可见。
例如,事务A在创建记录1和删除记录2后,发起了提交请求。系统首先判断事务A中是否有失败的记录,如果没有则允许执行提交操作。提交时,将事务A的信息从事务注册列表中移除,事务A中的变更内容正式生效。删除的记录2在事务提交之后,系统会发起存储空间回收操作。
假如此时事务B执行查询操作,查询到记录1的记录头数据为:记录锁为0,记录状态为1,创建版本号为事务A的ID,删除版本号为空。提取记录1的创建版本号和删除版本号后,通过查询事务注册列表,发现记录1的创建事务A已经提交,且记录1没有被设置删除版本,则可以确定记录1对于事务B可见。
对于记录2,事务B执行查询操作后,可以得到记录2的记录头数据示例性为:记录锁为1,记录状态为1,创建版本号为事务C的ID,删除版本号为事务A的ID。在提取记录2的创建版本号和删除版本号后,通过查询事务注册列表,发现记录2的创建事务C已经提交,删除事务A也已提交,则可以确定记录2对于事务B不可见。对于记录2来说,还存在另一种可能,当事务A提交后,系统会发起空间回收操作,对那些删除记录进行存储空间回收,将记录状态设置为0,表明记录已经不在系统中,此时事务B从存储层面上不能查询到记录2的数据,在事务层面上更不能看到记录2。
为了更好地接收事务并发控制流程,下面结合具体示例进行介绍。
示例性,假设存在11个读写操作时序序列,有7个事务。
在序列1中,事务ID为1的第一事务创建了一条记录1,此时该记录1处于“创建中”的状态,该记录1的记录头数据示例性如下表5。
表5
记录锁 状态 创建版本号 删除版本号
0 1 1  
此时,第一事务未提交,记录1只对第一事务可见,对其它事务不可见。
在序列2中,第一事务执行查询操作,以读取记录1。此时由于记录1的状态为有效状态,且创建版本号为本身ID,删除版本号为空,则表面第一事务可以读取自己创建的但未提交的记录1。
在序列3中,事务ID为2的第二事务执行读操作,以读取记录1。此时,记录1的状态为1,处于有效状态,创建版本号为1,小于第二事务的ID,删除版本号为空,则进一步判断第一事务是否在事务注册列表中。由于事务注册列表中仍然存在第一事务的信息,则表面第一事务未提交,因此对于第二事务来说,记录1不可读。
在序列4中,第一事务执行提交操作,记录1开始正式生效,并将第一事务从事务注册列表中删除。
在序列5中,事务ID为3的第三事务执行读操作,以读取记录1。此时,记录1处于有效状态,创建版本号为1,删除版本号为空,进一步判断出事务注册列表中不存在第一事务,则可以确定记录1对于第三事务可读,则可以读取记录1。
在序列6中,事务ID为4的第四事务对记录1执行删除操作。此时,先依据序列5的过程,读取出记录1;然后将记录1的删除版本号设置为4,记录锁设置为1,设置之后的记录头数据可以如下表6所示:
表6
记录锁 状态 创建版本号 删除版本号
1 1 1 4
此时,第四事务还未提交,删除操作还没有生效。记录1的状态为1,表面记录1还没有被真正删除,其它事务仍然可以读取记录1。但是,由于记录锁被设置为1,即记录1被设置了删除标记,其它进程或事务不重复删除该记录。
在序列7中,第四事务对记录1执行读取操作。此时,由于记录1的删除版本号等于第四事务的ID,则表明是当前事务删除了该记录,该记录对于当前事务是不可读的。
在序列8中,事务ID为5的第五事务对记录1执行读取操作。此时记录1的状态为有效状态,创建版本号和删除版本号均不等于当前事务ID,进一步判断记录1的创建事务即第一事务是否提交,删除事务即第四事务是否提交,由于第一事务已提交,第四事务未提交,则可以确定记录1对于第五事务来说,是可读的,故第五事务可以读取出记录1。
在序列9中,事务ID为6的第六事务对记录1执行删除操作。此时,由于记录1的记录锁为1,第六事务申请记录锁失败,故不能删除记录1。
在序列10中,第四事务执行了提交操作,第四事务提交后,事务注册列表中的第四事务的信息会被删除。第四事务的删除操作正式生效,数据库系统将记录1真正从数据存储位置删除,并将记录状态设置为无效,将清除记录锁。设置之后的记录头数据可以如下表7所示:
表7
记录锁 状态 创建版本号 删除版本号
0 0 1 4
在序列11中,事务ID为7的第七事务执行读取操作,以读取记录1。此时,由于记录1的记录状态为无效状态,故不可读取记录1。
可以理解的是,数据库中的UPDATE操作可以分解成INSERT操作和UPDATE操作,先将需要修该的记录复制出来修改相关信息,然后将修改之后的数据作为一条新的记录INSERT到数据库,然后将原记录标记为删除状态,等事务提交时,再真正删除原记录。
应当理解的是,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
对应于上文实施例所述的事务并发控制方法,图3示出了本申请实施例提供的事务并发控制装置的结构框图,为了便于说明,仅示出了与本申请实施例相关的部分。
参照图3,该装置包括:
获取模块31,用于获取针对目标记录的读操作,读操作属于第一事务,目标记录为由第二事务创建的记录;
记录头数据获取模块32,用于响应于读操作,获取目标记录的记录头数据,记录头数据包括记录锁信息、状态信息、创建版本号和删除版本号,记录锁信息用于描述目标记录是否被删除,状态信息用于描述目标记录是否有效,创建版本号用于描述创建目标记录的事务的唯一标识,删除版本号用于描述删除目标记录的事务的唯一标识;
判断模块33,用于若根据状态信息确定目标记录处于有效状态,根据记录锁信息确定目标记录未被删除,且删除版本号为空,创建版本号不等于第一事务的唯一标识,则判断创建版本号是否在事务注册列表中;
读取模块34,用于若创建版本号不在事务注册列表中,则读取目标记录;
确定模块35,用于若创建版本号在事务注册列表中,则确定目标记录对第一事务不可读。
在一些可能的实现方式中,该装置还包括:
第二判断模块,用于若根据状态信息确定目标记录处于有效状态,根据记录锁信息确定目标记录被删除,删除版本号不为空,且删除版本号不等于第一事务的唯一标识,判断创建版本号和删除版本号是否在事务注册列表中;若创建版本号不在事务注册列表中且删除版本号在事务列表中,则读取目标记录;若创建版本号不在事务注册列表中,且删除版本号不在事务列表中,则确定目标记录对第一事务不可读。
在一些可能的实现方式中,该装置还包括:
第二确定模块,用于若根据状态信息确定目标记录处于无效状态,且根据记录锁信息确定目标记录被删除,则确定目标记录对第一事务不可读;若根据状态信息确定目标记录处于有效状态,根据记录锁信息确定目标记录被删除,删除版本号不为空,且删除版本号等于第一事务的唯一标识,则确定目标记录对第一事务不可读。
在一些可能的实现方式中,该装置还包括:
第一删除模块,用于获取针对目标记录的删除操作,删除操作属于第一事务;若记录锁信息为第一数值,且删除版本号为空,则响应于删除操作,将记录锁信息从第一数值变更为第二数值,将删除版本号设置为第一事务的唯一标识;在第一事务提交删除操作后,从事务注册列表中删除第一事务的信息,将目标记录从物理存储空间中删除,并将状态信息从第三数值变更为第四数值;其中,第一数值表征目标记录未被删除,第二数值表征目标记录被删除;第三数值表征目标记录处于有效状态,第四数值表征目标记录处于无效状态。
在一些可能的实现方式中,该装置还包括:
第二删除模块,用于若记录锁信息为第二数值,且删除版本号不为空,则响应于删除操作,确定目标记录对第一事务不可删除。
在一些可能的实现方式中,该装置还包括:
创建模块,用于获取第二事务的创建操作,创建操作用于创建目标记录;响应于创建操作,将记录锁信息设置为第一数值,将状态信息设置为第三数值,将创建版本号设置为第二事务的唯一标识。
在一些可能的实现方式中,该装置还包括:
回滚模块,用于获取第一事务的回滚操作;响应于回滚操作,获取第一事务的撤销日志数据;根据撤销日志数据,将记录锁信息设置为第一数值,将删除版本号清空,将状态信息设置为第三数值,将创建版本号设置为第二事务的唯一标识,并恢复目标记录。
需要说明的是,上述装置/单元之间的信息交互、执行过程等内容,由于与本申请实施例方法实施例基于同一构思,其具体功能及带来的技术效果,具体可参见方法实施例部分,此处不再赘述。
图4为本申请一实施例提供的电子设备的结构示意图。如图4所示,该实施例的电子设备4包括:至少一个处理器40(图4中仅示出一个)、存储器41以及存储在所述存储器41中并可在所述至少一个处理器40上运行的计算机程序42,所述处理器40执行所述计算机程序42时实现上述任意各个目标跟踪方法实施例中的步骤。
所述电子设备4可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。该电子设备可包括,但不仅限于,处理器40、存储器41。本领域技术人员可以理解,图4仅仅是电子设备4的举例,并不构成对电子设备4的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如还可以包括输入输出设备、网络接入设备等。
所称处理器40可以是中央处理单元(Central Processing Unit,CPU),该处理器40还可以是其他通用处理器、数字信号处理器 (Digital Signal Processor,DSP)、专用集成电路 (Application Specific Integrated Circuit,ASIC)、现成可编程门阵列 (Field-Programmable Gate Array,FPGA) 或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
所述存储器41在一些实施例中可以是所述电子设备4的内部存储单元,例如电子设备4的硬盘或内存。所述存储器41在另一些实施例中也可以是所述电子设备4的外部存储设备,例如所述电子设备4上配备的插接式硬盘,智能存储卡(Smart Media Card, SMC),安全数字(Secure Digital, SD)卡,闪存卡(Flash Card)等。进一步地,所述存储器41还可以既包括所述电子设备4的内部存储单元也包括外部存储设备。所述存储器41用于存储操作系统、应用程序、引导装载程序(BootLoader)、数据以及其他程序等,例如所述计算机程序的程序代码等。所述存储器41还可以用于暂时地存储已经输出或者将要输出的数据。
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
本申请实施例还提供了一种电子设备,该电子设备包括:至少一个处理器、存储器以及存储在所述存储器中并可在所述至少一个处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现上述任意各个方法实施例中的步骤。
本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现可实现上述各个方法实施例中的步骤。
本申请实施例提供了一种计算机程序产品,当计算机程序产品在电子设备上运行时,使得电子设备执行时实现可实现上述各个方法实施例中的步骤。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,所述计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质至少可以包括:能够将计算机程序代码携带到拍照装置/终端设备的任何实体或装置、记录介质、计算机存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、电载波信号、电信信号以及软件分发介质。例如U盘、移动硬盘、磁碟或者光盘等。在某些司法管辖区,根据立法和专利实践,计算机可读介质不可以是电载波信号和电信信号。
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
在本申请所提供的实施例中,应该理解到,所揭露的装置、电子设备和方法,可以通过其它的方式实现。例如,以上所描述的装置/电子设备实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。

Claims (10)

  1. 一种事务并发控制方法,其特征在于,包括:
    获取针对目标记录的读操作,所述读操作属于第一事务,所述目标记录为由第二事务创建的记录;
    响应于所述读操作,获取所述目标记录的记录头数据,所述记录头数据包括记录锁信息、状态信息、创建版本号和删除版本号,所述记录锁信息用于描述所述目标记录是否被删除,所述状态信息用于描述所述目标记录是否有效,所述创建版本号用于描述创建所述目标记录的事务的唯一标识,所述删除版本号用于描述删除所述目标记录的事务的唯一标识;
    若根据所述状态信息确定所述目标记录处于有效状态,根据所述记录锁信息确定所述目标记录未被删除,且所述删除版本号为空,所述创建版本号不等于所述第一事务的唯一标识,则判断所述创建版本号是否在事务注册列表中;
    若所述创建版本号不在所述事务注册列表中,则读取所述目标记录;
    若所述创建版本号在所述事务注册列表中,则确定所述目标记录对所述第一事务不可读。
  2. 如权利要求1所述的方法,其特征在于,在获取所述目标记录的记录头数据之后,所述方法还包括:
    若根据所述状态信息确定所述目标记录处于有效状态,根据所述记录锁信息确定所述目标记录被删除,所述删除版本号不为空,且所述删除版本号不等于所述第一事务的唯一标识,判断所述创建版本号和所述删除版本号是否在所述事务注册列表中;
    若所述创建版本号不在所述事务注册列表中且所述删除版本号在所述事务列表中,则读取所述目标记录;
    若所述创建版本号不在所述事务注册列表中,且所述删除版本号不在所述事务列表中,则确定所述目标记录对所述第一事务不可读。
  3. 如权利要求1所述的方法,其特征在于,在获取所述目标记录的记录头数据之后,所述方法还包括:
    若根据所述状态信息确定所述目标记录处于无效状态,且根据所述记录锁信息确定所述目标记录被删除,则确定所述目标记录对所述第一事务不可读;
    若根据所述状态信息确定所述目标记录处于有效状态,根据所述记录锁信息确定所述目标记录被删除,所述删除版本号不为空,且所述删除版本号等于所述第一事务的唯一标识,则确定所述目标记录对所述第一事务不可读。
  4. 如权利要求1至3任一项所述的方法,其特征在于,在获取针对目标记录的读操作之前,所述方法还包括:
    获取针对所述目标记录的删除操作,所述删除操作属于所述第一事务;
    在读取所述目标记录之后,所述方法还包括:
    若所述记录锁信息为第一数值,且所述删除版本号为空,则响应于所述删除操作,将所述记录锁信息从所述第一数值变更为第二数值,将所述删除版本号设置为所述第一事务的唯一标识;
    在所述第一事务提交所述删除操作后,从所述事务注册列表中删除所述第一事务的信息,将所述目标记录从物理存储空间中删除,并将所述状态信息从第三数值变更为第四数值;
    其中,所述第一数值表征所述目标记录未被删除,所述第二数值表征所述目标记录被删除;所述第三数值表征所述目标记录处于有效状态,所述第四数值表征所述目标记录处于无效状态。
  5. 如权利要求4所述的方法,其特征在于,在获取针对所述目标记录的删除操作之后,还包括:
    若所述记录锁信息为所述第二数值,且所述删除版本号不为空,则响应于所述删除操作,确定所述目标记录对所述第一事务不可删除。
  6. 如权利要求4所述的方法,其特征在于,所述方法还包括:
    获取所述第二事务的创建操作,所述创建操作用于创建所述目标记录;
    响应于所述创建操作,将所述记录锁信息设置为所述第一数值,将所述状态信息设置为所述第三数值,将所述创建版本号设置为所述第二事务的唯一标识。
  7. 如权利要求4所述的方法,其特征在于,在从所述事务注册列表中删除所述第一事务的信息,将所述目标记录从物理存储空间中删除,并将所述状态信息从第三数值变更为第四数值之后,所述方法还包括:
    获取所述第一事务的回滚操作;
    响应于所述回滚操作,获取所述第一事务的撤销日志数据;
    根据所述撤销日志数据,将所述记录锁信息设置为所述第一数值,将所述删除版本号清空,将所述状态信息设置为所述第三数值,将所述创建版本号设置为所述第二事务的唯一标识,并恢复所述目标记录。
  8. 一种事务并发控制装置,其特征在于,包括:
    获取模块,用于获取针对目标记录的读操作,所述读操作属于第一事务,所述目标记录为由第二事务创建的记录;
    记录头数据获取模块,用于响应于所述读操作,获取所述目标记录的记录头数据,所述记录头数据包括记录锁信息、状态信息、创建版本号和删除版本号,所述记录锁信息用于描述所述目标记录是否被删除,所述状态信息用于描述所述目标记录是否有效,所述创建版本号用于描述创建所述目标记录的事务的唯一标识,所述删除版本号用于描述删除所述目标记录的事务的唯一标识;
    判断模块,用于若根据所述状态信息确定所述目标记录处于有效状态,根据所述记录锁信息确定所述目标记录未被删除,且所述删除版本号为空,所述创建版本号不等于所述第一事务的唯一标识,则判断所述创建版本号是否在事务注册列表中;
    读取模块,用于若所述创建版本号不在所述事务注册列表中,则读取所述目标记录;
    确定模块,用于若所述创建版本号在所述事务注册列表中,则确定所述目标记录对所述第一事务不可读。
  9. 一种电子设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如权利要求1至7任一项所述的方法。
  10. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至7任一项所述的方法。
PCT/CN2022/125971 2021-12-31 2022-10-18 事务并发控制方法、装置、电子设备及可读存储介质 WO2023124421A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111679155.9A CN114297217A (zh) 2021-12-31 2021-12-31 事务并发控制方法、装置、电子设备及可读存储介质
CN202111679155.9 2021-12-31

Publications (1)

Publication Number Publication Date
WO2023124421A1 true WO2023124421A1 (zh) 2023-07-06

Family

ID=80974967

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/125971 WO2023124421A1 (zh) 2021-12-31 2022-10-18 事务并发控制方法、装置、电子设备及可读存储介质

Country Status (2)

Country Link
CN (1) CN114297217A (zh)
WO (1) WO2023124421A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114297217A (zh) * 2021-12-31 2022-04-08 深圳市兆珑科技有限公司 事务并发控制方法、装置、电子设备及可读存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080077591A1 (en) * 2006-09-22 2008-03-27 Monish Gupta Computer program product for conducting a lock free read
CN103744936A (zh) * 2013-12-31 2014-04-23 华为技术有限公司 一种数据库中的多版本并发控制方法及数据库系统
CN107533474A (zh) * 2016-01-26 2018-01-02 华为技术有限公司 一种事务处理方法及装置
CN108363806A (zh) * 2018-03-01 2018-08-03 上海达梦数据库有限公司 数据库的多版本并发控制方法、装置、服务器及存储介质
CN111090663A (zh) * 2019-12-25 2020-05-01 上海金仕达软件科技有限公司 事务并发控制方法、装置、终端设备及介质
CN114297217A (zh) * 2021-12-31 2022-04-08 深圳市兆珑科技有限公司 事务并发控制方法、装置、电子设备及可读存储介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080077591A1 (en) * 2006-09-22 2008-03-27 Monish Gupta Computer program product for conducting a lock free read
CN103744936A (zh) * 2013-12-31 2014-04-23 华为技术有限公司 一种数据库中的多版本并发控制方法及数据库系统
CN107533474A (zh) * 2016-01-26 2018-01-02 华为技术有限公司 一种事务处理方法及装置
CN108363806A (zh) * 2018-03-01 2018-08-03 上海达梦数据库有限公司 数据库的多版本并发控制方法、装置、服务器及存储介质
CN111090663A (zh) * 2019-12-25 2020-05-01 上海金仕达软件科技有限公司 事务并发控制方法、装置、终端设备及介质
CN114297217A (zh) * 2021-12-31 2022-04-08 深圳市兆珑科技有限公司 事务并发控制方法、装置、电子设备及可读存储介质

Also Published As

Publication number Publication date
CN114297217A (zh) 2022-04-08

Similar Documents

Publication Publication Date Title
EP3117348B1 (en) Systems and methods to optimize multi-version support in indexes
CN109923534B (zh) 对具有未提交事务的数据库记录的多版本并发控制
EP2356560B1 (en) Atomic multiple modification of data in a distributed storage system
CN106033437B (zh) 一种分布式事务处理方法及系统
US9727422B2 (en) Tracking files excluded from backup
US7769714B2 (en) Automatic error correction for replication and instantaneous instantiation
US6298425B1 (en) Computer disk management system using doublet A-B logging
US8364656B2 (en) Method and system for implementing multiuser cached parameterized cells
US7895172B2 (en) System and method for writing data dependent upon multiple reads in a distributed database
CN108363806A (zh) 数据库的多版本并发控制方法、装置、服务器及存储介质
US20100274768A1 (en) De-duplication and completeness in multi-log based replication
US20130198139A1 (en) Durability implementation plan in an in-memory database system
CN111090663B (zh) 事务并发控制方法、装置、终端设备及介质
JP7101566B2 (ja) 不揮発性メモリにおけるマルチバージョン同時実行制御(mvcc)
US6751636B1 (en) System and method for maintaining and recovering data consistency across multiple instances of a database
US8108356B2 (en) Method for recovering data in a storage system
CN109947742B (zh) 面向二阶段锁的多版本数据库并发控制方法和系统
WO2023124421A1 (zh) 事务并发控制方法、装置、电子设备及可读存储介质
WO2022242372A1 (zh) 对象处理方法、装置、计算机设备和存储介质
US6275832B1 (en) Providing transaction undo without logging
WO2018059239A1 (zh) 一种文件存储方法及装置
US6721739B1 (en) System and method for maintaining and recovering data consistency across multiple pages
CN117178265A (zh) 基于快照的数据损坏检测
WO2023124242A1 (zh) 事务执行方法、装置、设备和存储介质
WO2015084409A1 (en) Nosql database data validation

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22913685

Country of ref document: EP

Kind code of ref document: A1