[go: up one dir, main page]

CN117056313A - Memory database transaction management method and device, electronic equipment and medium - Google Patents

Memory database transaction management method and device, electronic equipment and medium Download PDF

Info

Publication number
CN117056313A
CN117056313A CN202311063933.0A CN202311063933A CN117056313A CN 117056313 A CN117056313 A CN 117056313A CN 202311063933 A CN202311063933 A CN 202311063933A CN 117056313 A CN117056313 A CN 117056313A
Authority
CN
China
Prior art keywords
transaction
read
version data
data information
version
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.)
Pending
Application number
CN202311063933.0A
Other languages
Chinese (zh)
Inventor
陈奕林
周信静
张椿旭
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Zhiyu Technology Co ltd
Original Assignee
Zhejiang Zhiyu Technology 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 Zhejiang Zhiyu Technology Co ltd filed Critical Zhejiang Zhiyu Technology Co ltd
Priority to CN202311063933.0A priority Critical patent/CN117056313A/en
Publication of CN117056313A publication Critical patent/CN117056313A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/219Managing data history or versioning
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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 OR CALCULATING; 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

Landscapes

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

Abstract

本申请涉及内存数据库管理的领域,尤其是涉及一种内存数据库事务管理方法、装置、电子设备及介质,该方法包括当检测到只读事务请求访问数据行时,获取只读事务的事务标识符和数据行对应的若干个版本数据信息,每个版本数据信息包括版本数据行、版本事务标识、读取次数、事务访问区间以及日志持久化参数;基于只读事务的事务标识符和若干个版本数据信息各自对应的事务访问区间,从若干个版本数据信息中确定目标版本数据信息,目标版本数据信息为只读事务指定访问的版本数据信息;基于目标版本数据信息的日志持久化参数,确定可见版本数据行。本申请能够保证DolphinDB内存数据库中事务的正确性。

The present application relates to the field of in-memory database management, and in particular to an in-memory database transaction management method, device, electronic device and medium. The method includes obtaining the transaction identifier of the read-only transaction when a read-only transaction request is detected to access a data row. Several versions of data information corresponding to data rows. Each version of data information includes version data rows, version transaction identifiers, read times, transaction access intervals, and log persistence parameters; transaction identifiers and several versions based on read-only transactions The corresponding transaction access interval of the data information determines the target version data information from several versions of data information. The target version data information is the version data information accessed by the read-only transaction. Based on the log persistence parameters of the target version data information, the visible version data information is determined. Version data row. This application can ensure the correctness of transactions in the DolphinDB in-memory database.

Description

一种内存数据库事务管理方法、装置、电子设备及介质In-memory database transaction management method, device, electronic equipment and medium

技术领域Technical field

本申请涉及内存数据库管理的领域,尤其是涉及一种内存数据库事务管理方法、装置、电子设备及介质。The present application relates to the field of memory database management, and in particular to a memory database transaction management method, device, electronic equipment and media.

背景技术Background technique

DolphinDB是一种高性能、分布式内存数据库,旨在处理大规模数据分析和实时数据处理任务,为了保证内存数据库中事务的原子性和持久性,DolphinDB内存数据库采用了两阶段锁协议和多版本并发控制机制。其中,两阶段锁协议要求在读写事务的日志落盘前,读写事务的写锁不能释放,导致与读写事务有数据交集的并发只读事务无法及时获取到读锁。DolphinDB is a high-performance, distributed in-memory database designed to handle large-scale data analysis and real-time data processing tasks. In order to ensure the atomicity and durability of transactions in the in-memory database, the DolphinDB in-memory database uses a two-phase locking protocol and multi-version Concurrency control mechanism. Among them, the two-stage lock protocol requires that the write lock of the read-write transaction cannot be released before the log of the read-write transaction is written to disk. As a result, concurrent read-only transactions that have data intersection with the read-write transaction cannot obtain the read lock in time.

在相关技术中,通过在日志落盘前就将读写事务的写锁释放,使并发只读事务可以获取到读锁,减少对数据行的锁定时间以提高内存数据库的并发性能。其中,读写事务在对数据修改完成后立即释放锁定,若此时存在该读写事务的并发只读事务需要读取该读写事务修改后的数据且并发只读事务已完成提交,但是读写事务对数据的修改操作丢失且尚未保存至持久化存储介质(硬盘)中,则读写事务是一个需要回滚的事务,进而导致只读事务读取到的是一个需要回滚事务的修改数据,这违背了事务的隔离性,进而会影响事务的正确性。因此如何保证DolphinDB内存数据库中事务的正确性是亟待解决的问题。In related technologies, the write lock of read-write transactions is released before the log is written to disk, so that concurrent read-only transactions can obtain read locks, reducing the lock time of data rows and improving the concurrency performance of the in-memory database. Among them, the read-write transaction releases the lock immediately after completing the data modification. If there is a concurrent read-only transaction of the read-write transaction at this time and needs to read the modified data of the read-write transaction and the concurrent read-only transaction has completed the submission, but the read-write transaction If the data modification operation of the write transaction is lost and has not been saved to the persistent storage medium (hard disk), the read-write transaction is a transaction that needs to be rolled back, which in turn causes the read-only transaction to read a modification that needs to be rolled back. data, which violates the isolation of transactions, which in turn affects the correctness of transactions. Therefore, how to ensure the correctness of transactions in DolphinDB in-memory database is an urgent problem to be solved.

发明内容Contents of the invention

为了保证DolphinDB内存数据库中事务的正确性,本申请提供了一种内存数据库事务管理方法、装置、电子设备及介质。In order to ensure the correctness of transactions in the DolphinDB in-memory database, this application provides an in-memory database transaction management method, device, electronic equipment and media.

第一方面,本申请提供一种内存数据库事务管理方法,采用如下的技术方案:In the first aspect, this application provides an in-memory database transaction management method, adopting the following technical solution:

一种内存数据库事务管理方法,包括:An in-memory database transaction management method, including:

当检测到只读事务请求访问数据行时,获取所述只读事务的事务标识符和所述数据行对应的若干个版本数据信息,每个所述版本数据信息包括版本数据行、版本事务标识、读取次数、事务访问区间以及日志持久化参数,所述事务访问区间为可以读取所述版本数据行的只读事务的事务标识符区间,所述日志持久化参数用于表征创建所述版本数据行的读写事务的修改操作日志是否已写入持久存储介质中;When it is detected that a read-only transaction requests access to a data row, the transaction identifier of the read-only transaction and several version data information corresponding to the data row are obtained. Each of the version data information includes a version data row and a version transaction identifier. , the number of reads, the transaction access interval and the log persistence parameters. The transaction access interval is the transaction identifier interval of the read-only transaction that can read the version data row. The log persistence parameters are used to characterize the creation of the Whether the modification operation log of the read and write transactions of the version data row has been written to the persistent storage medium;

基于所述只读事务的事务标识符和所述若干个版本数据信息各自对应的事务访问区间,从所述若干个版本数据信息中确定目标版本数据信息,所述目标版本数据信息为所述只读事务指定访问的版本数据信息;Based on the transaction identifier of the read-only transaction and the transaction access interval corresponding to each of the several versions of data information, the target version data information is determined from the several versions of data information, and the target version data information is the only The read transaction specifies the version data information accessed;

基于所述目标版本数据信息的日志持久化参数,确定可见版本数据行。Visible version data rows are determined based on log persistence parameters of the target version data information.

通过采用上述技术方案,根据只读事务的事务标识符,从若干个版本数据信息中确定出只读事务需要读取的目标版本数据信息;进而根据目标版本数据信息的日志持久化参数,判断读写事务的修改操作日志是否已写入持久存储介质中,只有在读写事务的修改操作日志已写入持久存储介质中的情况下,才将对应的版本数据行视为可见,即确定版本数据行。这样可以保证事务的正确性,并且可以避免读取到已被删除或尚未提交的数据。By adopting the above technical solution, based on the transaction identifier of the read-only transaction, the target version data information that the read-only transaction needs to read is determined from several versions of data information; and then based on the log persistence parameters of the target version data information, the read Whether the modification operation log of the write transaction has been written to the persistent storage medium. Only when the modification operation log of the read and write transaction has been written to the persistent storage medium, the corresponding version data row will be considered visible, that is, the version data will be determined. OK. This ensures the correctness of the transaction and avoids reading deleted or uncommitted data.

在一种可能实现的方式中,所述基于所述目标版本数据行的日志持久化参数,确定可见版本数据行,包括:In a possible implementation manner, determining the visible version data row based on the log persistence parameters of the target version data row includes:

在所述目标版本数据信息对应的读写事务的修改操作日志写入持久存储介质之后,将所述版本数据信息中的日志持久化参数修改为预设可见值;After the modification operation log of the read-write transaction corresponding to the target version data information is written to the persistent storage medium, modify the log persistence parameters in the version data information to a preset visible value;

当所述目标版本数据信息的日志持久化参数为所述预设可见值时,将所述目标版本数据信息中的版本数据行确定为可见版本数据行,并对所述目标版本数据信息中的读取次数进行修改;When the log persistence parameter of the target version data information is the preset visible value, the version data row in the target version data information is determined as a visible version data row, and the version data row in the target version data information is The number of reads is modified;

当所述目标版本数据信息的日志持久化参数不为所述预设可见值时,将所述目标版本数据信息对应的读写事务加入到所述只读事务的依赖事务集合中,基于所述依赖事务集合,确定可见版本数据行,并对所述目标版本数据信息中的读取次数进行修改。When the log persistence parameter of the target version data information is not the preset visible value, the read-write transaction corresponding to the target version data information is added to the dependent transaction set of the read-only transaction, based on the Depend on the transaction set, determine the visible version data rows, and modify the number of reads in the target version data information.

通过采用上述技术方案,若目标版本数据信息对应的读写事务的修改操作日志已写入到持久存储介质中,则对应修改其日志持久化参数为预设可见值;当日志持久化参数为预设可见值时,将目标版本数据信息中已修改完成的版本数据行确定为可见版本数据行,以确保只读事务读取的数据是正确的。当目标版本数据信息的日志持久化参数不为预设可见值时,将目标版本数据信息对应的读写事务加入到该只读事务的依赖事务集合中,这样可以建立依赖关系,确保只读事务能够读取到依赖事务已提交更新的数据。通过记录读取次数,可以追踪每个版本数据行的访问情况,用于后续的优化和统计分析。By adopting the above technical solution, if the modification operation log of the read-write transaction corresponding to the target version data information has been written to the persistent storage medium, the corresponding log persistence parameters are modified to the preset visible values; when the log persistence parameters are the preset visible values When setting the visible value, determine the modified version data row in the target version data information as the visible version data row to ensure that the data read by the read-only transaction is correct. When the log persistence parameter of the target version data information is not a preset visible value, add the read-write transaction corresponding to the target version data information to the dependent transaction set of the read-only transaction. This can establish a dependency relationship and ensure the read-only transaction. Ability to read updated data that relies on transactions committed. By recording the number of reads, the access status of each version of the data row can be tracked for subsequent optimization and statistical analysis.

在一种可能实现的方式中,所述将所述目标版本数据信息对应的读写事务加入到所述只读事务的依赖事务集合中,包括:In a possible implementation manner, adding the read-write transaction corresponding to the target version data information to the dependent transaction set of the read-only transaction includes:

基于所述目标版本数据信息的事务访问区间,确定所述目标版本数据信息对应的读写事务的事务标识符;Based on the transaction access interval of the target version data information, determine the transaction identifier of the read and write transaction corresponding to the target version data information;

基于所述目标版本数据信息对应的读写事务的事务标识符,将所述目标版本数据信息对应的读写事务加入到所述只读事务的依赖事务集合中。Based on the transaction identifier of the read-write transaction corresponding to the target version data information, the read-write transaction corresponding to the target version data information is added to the dependent transaction set of the read-only transaction.

通过采用上述技术方案,在创建目标版本数据信息时,其事务访问区间的下限为创建该目标版本数据信息的读写事务的事务标识符,因此通过目标版本数据信息的事务访问区间,可以确定出创建目标版本数据信息的读写事务的事务标识符,进而根据该读写事务的事务标识符,将该读写事务加入到只读事务的依赖事务集合中,能够更快速地确定出创建目标版本数据信息的读写事务。By adopting the above technical solution, when creating the target version data information, the lower limit of the transaction access interval is the transaction identifier of the read and write transaction that created the target version data information. Therefore, through the transaction access interval of the target version data information, it can be determined Create the transaction identifier of the read-write transaction of the target version data information, and then add the read-write transaction to the dependent transaction set of the read-only transaction based on the transaction identifier of the read-write transaction, which can more quickly determine the creation of the target version Read and write transactions of data information.

在一种可能实现的方式中,在获取所述数据行对应的若干个版本数据信息之前,还包括:In a possible implementation manner, before obtaining several versions of data information corresponding to the data row, the method further includes:

当检测到读写事务请求修改所述数据行时,基于所述读写事务,创建所述数据行的版本数据信息,所述版本数据信息包括版本数据行、版本事务标识、读取次数、事务访问区间以及日志持久化参数,所述版本事务标识的初始值为创建所述版本数据信息的读写事务的事务标识符,所述日志持久化参数的初始值为预设不可见值。When it is detected that a read-write transaction requests modification of the data row, based on the read-write transaction, version data information of the data row is created. The version data information includes a version data row, a version transaction identifier, the number of reads, and a transaction Access interval and log persistence parameters. The initial value of the version transaction identifier is the transaction identifier of the read-write transaction that created the version data information. The initial value of the log persistence parameter is a preset invisible value.

通过采用上述技术方案,当检测到读写事务请求修改数据行时,根据该读写数据行创建该数据行的版本数据信息,版本数据信息中包括需要修改的版本数据行、版本事务标识、读取次数、事务访问区间以及日志持久化参数。通过将版本事务标识设置为创建该版本数据信息的读写事务的事务标识符,可以准确追踪每个版本数据信息的来源事务。通过将日志持久化参数的初始值设置为预设不可见值,可以确保新创建的版本数据对其他事务是不可见的;只有当读写事务的修改操作日志已写入持久存储介质时,即该版本数据信息的日志持久化参数被修改为预设可见值时,其他事务才可以读取到该版本数据,保证了事务的一致性。同时在只读事务需要访问该版本数据时,通过日志持久化参数就可以确定该版本的数据可以安全读取,无需再去全局事务集合中查询数据,能够降低数据库管理系统的开销。By adopting the above technical solution, when it is detected that a read-write transaction requests to modify a data row, the version data information of the data row is created based on the read-write data row. The version data information includes the version data row that needs to be modified, the version transaction identifier, the read-write transaction ID, and the version data row that needs to be modified. Fetch times, transaction access interval and log persistence parameters. By setting the version transaction identifier to the transaction identifier of the read-write transaction that created that version of data information, you can accurately track the source transaction of each version of data information. By setting the initial value of the log persistence parameter to the preset invisible value, you can ensure that the newly created version data is invisible to other transactions; only when the modification operation log of the read-write transaction has been written to the persistent storage medium, that is, Only when the log persistence parameters of this version of data information are modified to the preset visible value can other transactions read this version of data, ensuring transaction consistency. At the same time, when a read-only transaction needs to access the data of this version, the log persistence parameters can be used to determine that the data of this version can be read safely. There is no need to query the data in the global transaction collection, which can reduce the overhead of the database management system.

在一种可能实现的方式中,在创建所述数据行的版本数据信息之后,还包括:In a possible implementation manner, after creating the version data information of the data row, it also includes:

确定所述读写事务为写锁绑定状态;Determine that the read-write transaction is in a write lock-bound state;

在所述读写事务完成对所述数据行数据的修改操作之后,确定所述读写事务为写锁释放状态,并将所述读写事务对应的版本数据信息中的版本事务标识修改为预设获取锁值;After the read-write transaction completes the modification operation on the data row data, it is determined that the read-write transaction is in the write lock release state, and the version transaction identifier in the version data information corresponding to the read-write transaction is modified to the preset state. Assume to obtain the lock value;

将所述读写事务的修改操作日志写入持久存储介质,所述修改操作日志包括所述读写事务对所述数据行的修改操作。Write the modification operation log of the read-write transaction to the persistent storage medium, where the modification operation log includes the modification operation of the data row by the read-write transaction.

通过采用上述技术方案,该读写事务在创建数据行对应的版本数据信息之后,需要使读写事务获取到数据行的写锁,即确定读写事务为写锁绑定状态,以保证其他需要访问该版本数据行的只读事务无法读取正在被修改的数据行,从而保证数据的一致性;在读写事务对数据行完成修改操作后,使读写事务释放数据行的写锁,即确定读写事务为写锁释放状态,同时将读写事务对应的版本事务标识修改为预设获取锁值,这个修改可以作为一个信号,告知其他只读事务可以开始读取这个版本数据行的读锁了;之后再将读写事务的修改操作日志写入持久存储介质,确保读写事务所做的修改操作被持久保存。通过写锁绑定和释放状态的确定和版本事务标识的修改,确保并发只读事务的一致性和并发性。By adopting the above technical solution, after the read-write transaction creates the version data information corresponding to the data row, the read-write transaction needs to obtain the write lock of the data row, that is, it is determined that the read-write transaction is in the write lock-bound state to ensure other needs The read-only transaction accessing the data row of this version cannot read the data row being modified, thereby ensuring the consistency of the data; after the read-write transaction completes the modification operation on the data row, the read-write transaction releases the write lock of the data row, that is, Determine that the read-write transaction is in the write lock release state, and at the same time modify the version transaction identifier corresponding to the read-write transaction to the default acquisition lock value. This modification can be used as a signal to inform other read-only transactions that they can start reading this version of data rows. Lock; then write the modification operation log of the read-write transaction to the persistent storage medium to ensure that the modification operation made by the read-write transaction is persisted. Ensure the consistency and concurrency of concurrent read-only transactions by determining the write lock binding and release status and modifying the version transaction identifier.

在一种可能实现的方式中,在基于所述只读事务的事务标识符和所述若干个版本数据信息各自对应的事务访问区间,从所述若干个版本数据信息中确定目标版本数据信息之后,还包括:In one possible implementation manner, after determining the target version data information from the several versions of data information based on the transaction identifier of the read-only transaction and the transaction access intervals corresponding to the several versions of data information, ,Also includes:

获取所述目标版本数据信息的版本事务标识;Obtain the version transaction identifier of the target version data information;

当所述目标版本数据信息的版本事务标识为预设获取锁值时,确定所述只读事务为读锁绑定状态。When the version transaction identifier of the target version data information is a preset acquisition lock value, it is determined that the read-only transaction is in a read lock binding state.

通过采用上述技术方案,通过目标版本数据信息的版本事务标识,判断目标版本数据信息中的版本数据行是否已经完成修改,若已完成修改(版本事务标识为预设获取锁值),则向访问该版本数据的只读事务可以获取到相应的读锁,即只读事务为读锁绑定状态。读锁绑定状态意味着只读事务可以并发地读取目标版本数据信息,而不会与写事务发生冲突。这样可以提高并发性能,允许多个只读事务同时读取目标版本数据信息,增加系统的吞吐量。By adopting the above technical solution and using the version transaction identifier of the target version data information, it is judged whether the version data row in the target version data information has been modified. If the modification has been completed (the version transaction identifier is the preset acquisition lock value), then access The read-only transaction of this version of data can obtain the corresponding read lock, that is, the read-only transaction is in the read lock binding state. The read lock binding state means that read-only transactions can concurrently read target version data information without conflicting with write transactions. This can improve concurrency performance, allow multiple read-only transactions to read target version data information at the same time, and increase system throughput.

第二方面,本申请提供一种内存数据库事务管理装置,采用如下的技术方案:In the second aspect, this application provides an in-memory database transaction management device that adopts the following technical solution:

一种内存数据库事务管理装置,包括:An in-memory database transaction management device, including:

事务信息和版本数据信息获取模块,用于当检测到只读事务请求访问数据行时,获取所述只读事务的事务标识符和所述数据行对应的若干个版本数据信息,每个所述版本数据信息包括版本数据行、版本事务标识、读取次数、事务访问区间以及日志持久化参数,所述事务访问区间为可以读取所述版本数据行的只读事务的事务标识符区间,所述日志持久化参数用于表征创建所述版本数据行的读写事务的修改操作日志是否已写入持久存储介质中;A transaction information and version data information acquisition module, configured to obtain the transaction identifier of the read-only transaction and several version data information corresponding to the data row when a read-only transaction request is detected to access a data row, each of which The version data information includes version data rows, version transaction identifiers, read times, transaction access intervals, and log persistence parameters. The transaction access intervals are the transaction identifier intervals of read-only transactions that can read the version data rows, so The log persistence parameter is used to indicate whether the modification operation log of the read-write transaction that created the version data row has been written to the persistent storage medium;

目标版本数据信息确定模块,用于基于所述只读事务的事务标识符和所述若干个版本数据信息各自对应的事务访问区间,从所述若干个版本数据信息中确定目标版本数据信息,所述目标版本数据信息为所述只读事务指定访问的版本数据信息;The target version data information determination module is configured to determine the target version data information from the several version data information based on the transaction identifier of the read-only transaction and the transaction access intervals corresponding to the several version data information, so The target version data information is the version data information specified to be accessed by the read-only transaction;

可见版本数据行确定模块,用于基于所述目标版本数据信息的日志持久化参数,确定可见版本数据行。The visible version data row determination module is used to determine the visible version data row based on the log persistence parameters of the target version data information.

通过采用上述技术方案,根据只读事务的事务标识符,从若干个版本数据信息中确定出只读事务需要读取的目标版本数据信息;进而根据目标版本数据信息的日志持久化参数,判断读写事务的修改操作日志是否已写入持久存储介质中,只有在读写事务的修改操作日志已写入持久存储介质中的情况下,才将对应的版本数据行视为可见,即确定版本数据行。这样可以保证事务的正确性,并且可以避免读取到已被删除或尚未提交的数据。By adopting the above technical solution, based on the transaction identifier of the read-only transaction, the target version data information that the read-only transaction needs to read is determined from several versions of data information; and then based on the log persistence parameters of the target version data information, the read Whether the modification operation log of the write transaction has been written to the persistent storage medium. Only when the modification operation log of the read and write transaction has been written to the persistent storage medium, the corresponding version data row will be considered visible, that is, the version data will be determined. OK. This ensures the correctness of the transaction and avoids reading deleted or uncommitted data.

在一种可能实现的方式中,所述可见版本数据行确定模块在基于所述目标版本数据行的日志持久化参数,确定可见版本数据行时,具体用于:In a possible implementation manner, when the visible version data row determination module determines the visible version data row based on the log persistence parameters of the target version data row, it is specifically used to:

在所述目标版本数据信息对应的读写事务的修改操作日志写入持久存储介质之后,将所述版本数据信息中的日志持久化参数修改为预设可见值;After the modification operation log of the read-write transaction corresponding to the target version data information is written to the persistent storage medium, modify the log persistence parameters in the version data information to a preset visible value;

当所述目标版本数据信息的日志持久化参数为所述预设可见值时,将所述目标版本数据信息中的版本数据行确定为可见版本数据行,并对所述目标版本数据信息中的读取次数进行修改;When the log persistence parameter of the target version data information is the preset visible value, the version data row in the target version data information is determined as a visible version data row, and the version data row in the target version data information is The number of reads is modified;

当所述目标版本数据信息的日志持久化参数不为所述预设可见值时,将所述目标版本数据信息对应的读写事务加入到所述只读事务的依赖事务集合中,基于所述依赖事务集合,确定可见版本数据行,并对所述目标版本数据信息中的读取次数进行修改。When the log persistence parameter of the target version data information is not the preset visible value, the read-write transaction corresponding to the target version data information is added to the dependent transaction set of the read-only transaction, based on the Depend on the transaction set, determine the visible version data rows, and modify the number of reads in the target version data information.

在一种可能实现的方式中,所述可见版本数据行确定模块在将所述目标版本数据信息对应的读写事务加入到所述只读事务的依赖事务集合中时,具体用于:In a possible implementation manner, when the visible version data row determination module adds the read-write transaction corresponding to the target version data information to the dependent transaction set of the read-only transaction, it is specifically used to:

基于所述目标版本数据信息的事务访问区间,确定所述目标版本数据信息对应的读写事务的事务标识符;Based on the transaction access interval of the target version data information, determine the transaction identifier of the read and write transaction corresponding to the target version data information;

基于所述目标版本数据信息对应的读写事务的事务标识符,将所述目标版本数据信息对应的读写事务加入到所述只读事务的依赖事务集合中。Based on the transaction identifier of the read-write transaction corresponding to the target version data information, the read-write transaction corresponding to the target version data information is added to the dependent transaction set of the read-only transaction.

在一种可能实现的方式中,一种内存数据库事务管理装置,还包括:In a possible implementation manner, an in-memory database transaction management device further includes:

版本数据信息创建模块,用于当检测到读写事务请求修改所述数据行时,基于所述读写事务,创建所述数据行的版本数据信息,所述版本数据信息包括版本数据行、版本事务标识、读取次数、事务访问区间以及日志持久化参数,所述版本事务标识的初始值为创建所述版本数据信息的读写事务的事务标识符,所述日志持久化参数的初始值为预设不可见值。A version data information creation module, configured to create version data information of the data row based on the read-write transaction when a read-write transaction request is detected to modify the data row. The version data information includes a version data row, a version Transaction identifier, number of reads, transaction access interval and log persistence parameters. The initial value of the version transaction identifier is the transaction identifier of the read and write transaction that created the version data information. The initial value of the log persistence parameter is Default invisible value.

在一种可能实现的方式中,一种内存数据库事务管理装置,还包括:In a possible implementation manner, an in-memory database transaction management device further includes:

写锁绑定状态确定模块,用于确定所述读写事务为写锁绑定状态;A write lock binding state determination module, used to determine that the read and write transaction is in a write lock binding state;

写锁释放状态确定模块,用于在所述读写事务完成对所述数据行数据的修改操作之后,确定所述读写事务为写锁释放状态,并将所述读写事务对应的版本数据信息中的版本事务标识修改为预设获取锁值;A write lock release state determination module, configured to determine that the read and write transaction is in the write lock release state after the read and write transaction completes the modification operation of the data row data, and store the version data corresponding to the read and write transaction. The version transaction identifier in the information is changed to the default acquisition lock value;

日志落盘模块,用于将所述读写事务的修改操作日志写入持久存储介质,所述修改操作日志包括所述读写事务对所述数据行的修改操作。A log writing module is configured to write the modification operation log of the read-write transaction to the persistent storage medium, where the modification operation log includes the modification operation of the data row by the read-write transaction.

在一种可能实现的方式中,一种内存数据库事务管理装置,还包括:In a possible implementation manner, an in-memory database transaction management device further includes:

版本事务标识获取模块,用于获取所述目标版本数据信息的版本事务标识;A version transaction identification acquisition module, used to obtain the version transaction identification of the target version data information;

读锁绑定状态确定模块,用于当所述目标版本数据信息的版本事务标识为预设获取锁值时,确定所述只读事务为读锁绑定状态。The read lock binding state determination module is configured to determine that the read-only transaction is in the read lock binding state when the version transaction identifier of the target version data information is a preset acquisition lock value.

第三方面,本申请提供一种电子设备,采用如下的技术方案:In the third aspect, this application provides an electronic device that adopts the following technical solution:

一种电子设备,该电子设备包括:An electronic device including:

至少一个处理器;at least one processor;

存储器;memory;

至少一个应用程序,其中所述至少一个应用程序被存储在存储器中并被配置为由至少一个处理器执行,所述至少一个应用程序配置用于:执行上述内存数据库事务管理方法。At least one application program, wherein the at least one application program is stored in a memory and configured to be executed by at least one processor, the at least one application program is configured to: execute the above-mentioned in-memory database transaction management method.

第四方面,本申请提供一种计算机可读存储介质,采用如下的技术方案:In the fourth aspect, this application provides a computer-readable storage medium, adopting the following technical solution:

一种计算机可读存储介质,包括:存储有能够被处理器加载并执行上述内存数据库事务管理方法的计算机程序。A computer-readable storage medium includes: storing a computer program that can be loaded by a processor and execute the above-mentioned memory database transaction management method.

综上所述,本申请包括以下至少一种有益技术效果:To sum up, this application includes at least one of the following beneficial technical effects:

1.根据只读事务的事务标识符,从若干个版本数据信息中确定出只读事务需要读取的目标版本数据信息;进而根据目标版本数据信息的日志持久化参数,判断读写事务的修改操作日志是否已写入持久存储介质中,只有在读写事务的修改操作日志已写入持久存储介质中的情况下,才将对应的版本数据行视为可见,即确定版本数据行。这样可以保证事务的正确性,并且可以避免读取到已被删除或尚未提交的数据。1. Based on the transaction identifier of the read-only transaction, determine the target version data information that the read-only transaction needs to read from several versions of data information; and then determine the modification of the read-write transaction based on the log persistence parameters of the target version data information. Whether the operation log has been written to the persistent storage medium. Only when the modification operation log of the read-write transaction has been written to the persistent storage medium, the corresponding version data row will be considered visible, that is, the version data row will be determined. This ensures the correctness of the transaction and avoids reading deleted or uncommitted data.

2.若目标版本数据信息对应的读写事务的修改操作日志已写入到持久存储介质中,则对应修改其日志持久化参数为预设可见值;当日志持久化参数为预设可见值时,将目标版本数据信息中已修改完成的版本数据行确定为可见版本数据行,以确保只读事务读取的数据是正确的。当目标版本数据信息的日志持久化参数不为预设可见值时,将目标版本数据信息对应的读写事务加入到该只读事务的依赖事务集合中,这样可以建立依赖关系,确保只读事务能够读取到依赖事务已提交更新的数据。通过记录读取次数,可以追踪每个版本数据行的访问情况,用于后续的优化和统计分析。2. If the modification operation log of the read-write transaction corresponding to the target version data information has been written to the persistent storage medium, the corresponding log persistence parameters are modified to the preset visible values; when the log persistence parameters are the preset visible values , determine the modified version data rows in the target version data information as visible version data rows to ensure that the data read by the read-only transaction is correct. When the log persistence parameter of the target version data information is not a preset visible value, add the read-write transaction corresponding to the target version data information to the dependent transaction set of the read-only transaction. This can establish a dependency relationship and ensure the read-only transaction. Ability to read updated data that relies on transactions submitted. By recording the number of reads, the access status of each version of the data row can be tracked for subsequent optimization and statistical analysis.

3.当检测到读写事务请求修改数据行时,根据该读写数据行创建该数据行的版本数据信息,版本数据信息中包括需要修改的版本数据行、版本事务标识、读取次数、事务访问区间以及日志持久化参数。通过将版本事务标识设置为创建该版本数据信息的读写事务的事务标识符,可以准确追踪每个版本数据信息的来源事务。通过将日志持久化参数的初始值设置为预设不可见值,可以确保新创建的版本数据对其他事务是不可见的;只有当读写事务的修改操作日志已写入持久存储介质时,即该版本数据信息的日志持久化参数被修改为预设可见值时,其他事务才可以读取到该版本数据,保证了事务的一致性。同时在只读事务需要访问该版本数据时,通过日志持久化参数就可以确定该版本的数据可以安全读取,无需再去全局事务集合中查询数据,能够降低数据库管理系统的开销。3. When it is detected that a read-write transaction requests to modify a data row, the version data information of the data row is created based on the read-write data row. The version data information includes the version data row that needs to be modified, the version transaction identifier, the number of reads, and the transaction Access interval and log persistence parameters. By setting the version transaction identifier to the transaction identifier of the read-write transaction that created that version of data information, you can accurately track the source transaction of each version of data information. By setting the initial value of the log persistence parameter to the preset invisible value, you can ensure that the newly created version data is invisible to other transactions; only when the modification operation log of the read-write transaction has been written to the persistent storage medium, that is, Only when the log persistence parameters of this version of data information are modified to the preset visible value can other transactions read this version of data, ensuring transaction consistency. At the same time, when a read-only transaction needs to access the data of this version, the log persistence parameters can be used to determine that the data of this version can be read safely. There is no need to query the data in the global transaction collection, which can reduce the overhead of the database management system.

附图说明Description of the drawings

图1是本申请实施例中一种内存数据库事务管理方法的流程示意图;Figure 1 is a schematic flow chart of an in-memory database transaction management method in an embodiment of the present application;

图2是本申请实施例中只读事务获取读锁的时间线图;Figure 2 is a timeline diagram of a read-only transaction acquiring a read lock in the embodiment of the present application;

图3是本申请实施例中一种内存数据库事务管理装置的结构示意图;Figure 3 is a schematic structural diagram of a memory database transaction management device in an embodiment of the present application;

图4是本申请实施例中电子设备的结构示意图。Figure 4 is a schematic structural diagram of an electronic device in an embodiment of the present application.

具体实施方式Detailed ways

以下结合图1-图4对本申请作进一步详细说明。The present application will be further described in detail below in conjunction with Figures 1-4.

本领域技术人员在阅读完本说明书后可以根据需要对本实施例做出没有创造性贡献的修改,但只要在本申请的范围内都受到专利法的保护。Those skilled in the art can make modifications to this embodiment without creative contribution as needed after reading this description, but as long as they are within the scope of this application, they are protected by patent law.

为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments These are part of the embodiments of this application, but not all of them. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of this application.

另外,本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中字符“/”,如无特殊说明,一般表示前后关联对象是一种“或”的关系。In addition, the term "and/or" in this article is only an association relationship that describes related objects, indicating that there can be three relationships. For example, A and/or B can mean: A alone exists, and A and B exist simultaneously. There are three cases of B alone. In addition, the character "/" in this article, unless otherwise specified, generally indicates that the related objects are in an "or" relationship.

本申请实施例提供了一种内存数据库事务管理方法,由电子设备执行,参照图1,该方法包括步骤S101-步骤S103,其中:The embodiment of the present application provides a memory database transaction management method, which is executed by an electronic device. Referring to Figure 1, the method includes steps S101 to S103, wherein:

步骤S101、当检测到只读事务请求访问数据行时,获取只读事务的事务标识符和数据行对应的若干个版本数据信息,每个版本数据信息包括版本数据行、版本事务标识、读取次数、事务访问区间以及日志持久化参数,事务访问区间为可以读取版本数据行的只读事务的事务标识符区间,日志持久化参数用于表征创建版本数据行的读写事务的修改操作日志是否已写入持久存储介质中。Step S101: When it is detected that a read-only transaction requests access to a data row, obtain the transaction identifier of the read-only transaction and several version data information corresponding to the data row. Each version data information includes a version data row, a version transaction identifier, a read times, transaction access interval and log persistence parameters. The transaction access interval is the transaction identifier interval of a read-only transaction that can read version data rows. The log persistence parameters are used to characterize the modification operation log of read-write transactions that create version data rows. Whether it has been written to persistent storage media.

对于本申请实施例,在内存数据库系统中,可以自动为每个事务分配一个唯一的事务标识符,以便系统可以识别和追踪该事务的执行和状态。同时内存数据库系统会记录该事务的事务标识符,并将事务标识符与该事务关联起来,事务标识符可以是一个数字、字符串或其他类型的标识符,事务标识符可以通过不同的方式生成,具体取决于系统的需求和设计。生成事务标识符的方式可以包括:递增计数器:数据库系统可以使用一个递增的计数器来生成事务标识符,每创建一个新事务,计数器的值就增加,将该值作为新事务的标识符。时间戳:使用当前的时间戳作为事务标识符,通常是将当前时间转换为特定格式的字符串或者使用特定的数据类型存储时间戳。全局唯一标识符(GUID):使用全局唯一标识符作为事务标识符,GUID是一个128位的唯一标识符,通常使用算法和系统特定的信息来生成。对于事务标识符的生成方式和表现形式本申请实施例中不进行具体限定,只需能够准确地表示对应的事务即可。For the embodiment of the present application, in the in-memory database system, each transaction can be automatically assigned a unique transaction identifier, so that the system can identify and track the execution and status of the transaction. At the same time, the in-memory database system will record the transaction identifier of the transaction and associate the transaction identifier with the transaction. The transaction identifier can be a number, a string, or other types of identifiers. The transaction identifier can be generated in different ways. , depending on the requirements and design of the system. Ways to generate transaction identifiers can include: Incrementing counter: The database system can use an incrementing counter to generate transaction identifiers. Every time a new transaction is created, the value of the counter is increased, and this value is used as the identifier of the new transaction. Timestamp: Use the current timestamp as a transaction identifier, usually by converting the current time into a string in a specific format or using a specific data type to store the timestamp. Globally unique identifier (GUID): Use a globally unique identifier as a transaction identifier. A GUID is a 128-bit unique identifier that is usually generated using algorithm and system-specific information. The generation method and expression form of the transaction identifier are not specifically limited in the embodiment of this application, as long as it can accurately represent the corresponding transaction.

进一步地,当检测到只读事务请求访问数据行时,获取只读事务的事务标识符,同时根据只读事务需要访问的数据行,获取该数据行对应的若干个版本数据信息,其中这里提到的版本数据信息为在检测到只读事务请求访问数据行之前,不同读写事务对该数据行创建的版本数据信息。数据行的每个版本数据信息都与创建该版本数据信息的读写事务的事务标识符相关联,版本事务标识的初始值为创建该版本数据信息的读写事务的事务标识符,当读写事务完成读写操作后会将对应的版本标识符变为某一预设标识值,预设标识值用于与读写事务的事务标识符进行区分。Further, when it is detected that a read-only transaction requests access to a data row, the transaction identifier of the read-only transaction is obtained, and at the same time, according to the data row that the read-only transaction needs to access, several versions of data information corresponding to the data row are obtained, where provided here The version data information obtained is the version data information created by different read-write transactions for the data row before the read-only transaction request is detected to access the data row. Each version of the data information of the data row is associated with the transaction identifier of the read-write transaction that created the version of the data information. The initial value of the version transaction identifier is the transaction identifier of the read-write transaction that created the version of the data information. When reading and writing After the transaction completes the read and write operations, the corresponding version identifier will be changed to a preset identification value. The preset identification value is used to distinguish it from the transaction identifier of the read and write transactions.

用户可以根据读取次数对应的数值了解当前读取该版本数据行的只读事务的数量,例如,读取次数的初始值为0,当有某一只读事务读取该版本数据行时,读取次数加1;当该只读事务完成读取时对应的读取次数减1。Users can understand the number of read-only transactions currently reading data rows of this version based on the value corresponding to the number of reads. For example, the initial value of the number of reads is 0. When a read-only transaction reads a data row of this version, The number of reads is increased by 1; when the read-only transaction completes reading, the corresponding number of reads is decremented by 1.

事务访问区间用于表征可以读取该版本数据行的只读事务的事务标识符区间,其中事务访问区间的阈值下限可以是创建该版本数据信息的读写事务的事务标识符,也即版本事务标识的初始值。事务访问区间的阈值上限可以根据用户需求确定,还可以根据下一个读写事务的使用情况确定。以事务标识符为创建对应事务的时间戳举例说明:事务访问区间的下限是创建这个版本的读写事务的时间戳,而事务访问区间的上限可以是下一个读写事务的开始时间戳减去1。假设有两个事务T1和T2,T1在时间戳为1000的时候开始,T2在时间戳为2000的时候开始;当T1对某个数据行进行修改时,会创建一个新的版本,该版本的事务访问区间的下限是1000,但上限会设置为1999(T2的开始时间戳减1),这样T1修改的数据对T2是不可见的,各个版本数据信息的事务访问区间之间不重合。The transaction access interval is used to represent the transaction identifier interval of the read-only transaction that can read the data rows of this version. The lower threshold of the transaction access interval can be the transaction identifier of the read-write transaction that created the data information of this version, that is, the version transaction. The initial value of the identifier. The upper threshold of the transaction access interval can be determined based on user needs and the usage of the next read-write transaction. Taking the transaction identifier as the timestamp of creating the corresponding transaction as an example: the lower limit of the transaction access interval is the timestamp of creating this version of the read-write transaction, and the upper limit of the transaction access interval can be the start timestamp of the next read-write transaction minus 1. Suppose there are two transactions T1 and T2. T1 starts when the timestamp is 1000, and T2 starts when the timestamp is 2000. When T1 modifies a certain data row, a new version will be created. The lower limit of the transaction access interval is 1000, but the upper limit will be set to 1999 (the start timestamp of T2 minus 1). In this way, the data modified by T1 is invisible to T2, and the transaction access intervals of each version of the data information do not overlap.

日志持久化参数对应一组数字或字符,例如,0和1,false和true等。当读写事务的操作日志已写入持久化存储介质之后,日志持久化参数会由初始值修改为对应的数组或字符组中的另一非初始值,例如,日志持久化参数的初始值为false,当读写事务的操作数据写入持久存储介质后为true。Log persistence parameters correspond to a set of numbers or characters, for example, 0 and 1, false and true, etc. After the operation log of the read-write transaction has been written to the persistent storage medium, the log persistence parameters will be modified from the initial value to another non-initial value in the corresponding array or character group. For example, the initial value of the log persistence parameter is false, true when the operation data of the read-write transaction is written to the persistent storage medium.

步骤S102、基于只读事务的事务标识符和若干个版本数据信息各自对应的事务访问区间,从若干个版本数据信息中确定目标版本数据信息,目标版本数据信息为只读事务指定访问的版本数据信息;Step S102: Based on the transaction identifier of the read-only transaction and the corresponding transaction access intervals of several versions of data information, determine the target version data information from the several versions of data information. The target version data information is the version data designated to be accessed by the read-only transaction. information;

对于本申请实施例,当只读事务开始执行时,它会通过事务标识符指定要读取的数据行的版本,因此可以通过判断只读事务的事务标识符与每个版本数据信息的事务访问区间之间的关系,从若干个版本数据信息信息中确定出目标版本数据信息,其中只读事务的事务标识符在目标版本数据信息的事务访问区间内,各个版本数据信息的事务访问区间互斥。For the embodiment of this application, when a read-only transaction starts to execute, it will specify the version of the data row to be read through the transaction identifier. Therefore, it can be judged by judging the transaction identifier of the read-only transaction and the transaction access of each version of the data information. The relationship between intervals determines the target version data information from several versions of data information. The transaction identifier of the read-only transaction is within the transaction access interval of the target version data information, and the transaction access intervals of each version of data information are mutually exclusive. .

步骤S103、基于目标版本数据信息的日志持久化参数,确定可见版本数据行。Step S103: Determine the visible version data rows based on the log persistence parameters of the target version data information.

对于本申请实施例,确定出当前目标版本数据信息的日志持久化参数,若日志持久化参数会为某一预设值,该预设值表示该目标版本数据信息对应的数据修改操作已经写入持久存储介质中,则将该目标版本数据信息中修改后的版本数据行确定出只读事务可以读取的可见版本数据行。For the embodiment of this application, the log persistence parameters of the current target version data information are determined. If the log persistence parameter will be a certain preset value, the preset value indicates that the data modification operation corresponding to the target version data information has been written. In the persistent storage medium, the modified version data rows in the target version data information are used to determine the visible version data rows that can be read by the read-only transaction.

根据只读事务的事务标识符,从若干个版本数据信息中确定出只读事务需要读取的目标版本数据信息;进而根据目标版本数据信息的日志持久化参数,判断读写事务的修改操作日志是否已写入持久存储介质中,只有在读写事务的修改操作日志已写入持久存储介质中的情况下,才将对应的版本数据行视为可见,即确定版本数据行。这样可以保证事务的正确性,并且可以避免读取到已被删除或尚未提交的数据。According to the transaction identifier of the read-only transaction, the target version data information that the read-only transaction needs to read is determined from several version data information; and then based on the log persistence parameters of the target version data information, the modification operation log of the read-write transaction is determined. Whether it has been written to the persistent storage medium, only when the modification operation log of the read-write transaction has been written to the persistent storage medium, the corresponding version data row will be considered visible, that is, the version data row will be determined. This ensures the correctness of the transaction and avoids reading deleted or uncommitted data.

进一步地,基于目标版本数据行的日志持久化参数,确定可见版本数据行,包括步骤S1031(图中未示出)-步骤S1033(图中未示出),其中:Further, based on the log persistence parameters of the target version data row, determining the visible version data row includes steps S1031 (not shown in the figure) - step S1033 (not shown in the figure), wherein:

步骤S1031、在目标版本数据信息对应的读写事务的修改操作日志写入持久存储介质之后,将版本数据信息中的日志持久化参数修改为预设可见值。Step S1031: After the modification operation log of the read-write transaction corresponding to the target version data information is written to the persistent storage medium, modify the log persistence parameters in the version data information to a preset visible value.

具体地,在目标版本数据信息对应的读写事务的操作日志写入持久存储介质(日志落盘)之后,需要将目标版本数据信息中的日志持久化参数从初始值修改为预设可见值。日志持久化参数的预设可见值与初始值不同,可以通过读取版本数据信息的日志持久化参数了解到对应的读写事务是否完成日志落盘。例如,当读写事务A创建版本数据信息X时日志持久化参数为初始值false,在读写事务A的操作日志完成日志落盘之后,日志持久化参数修改为预设可见值为true。Specifically, after the operation log of the read-write transaction corresponding to the target version data information is written to the persistent storage medium (log disk), the log persistence parameters in the target version data information need to be modified from the initial value to the preset visible value. The preset visible value of the log persistence parameter is different from the initial value. You can learn whether the corresponding read and write transaction has completed the log placement by reading the log persistence parameter of the version data information. For example, when read-write transaction A creates version data information

进一步地,步骤S1031可以在步骤S101-步骤S103任一步骤之前执行,步骤S1031也可以在步骤S101-步骤S103任一步骤之后执行,步骤S1031还可以与步骤S101-步骤S103任一步骤同时执行,只要版本数据信息对应的读写事务的修改操作日志已完成写入持久存储介质中,即可将版本数据信息中的日志持久化参数修改为预设可见值。而步骤S1032和步骤S1033需要在步骤S102之后执行,若在确定目标版本数据信息之前已执行步骤S1031,则继续执行S1032;若在确定目标版本数据信息之前尚未执行步骤S1031,则继续执行S1033。Further, step S1031 can be executed before any step from step S101 to step S103. Step S1031 can also be executed after any step from step S101 to step S103. Step S1031 can also be executed simultaneously with any step from step S101 to step S103. As long as the modification operation log of the read-write transaction corresponding to the version data information has been written to the persistent storage medium, the log persistence parameters in the version data information can be modified to the preset visible value. Steps S1032 and S1033 need to be executed after step S102. If step S1031 has been executed before the target version data information is determined, continue to execute S1032; if step S1031 has not been executed before the target version data information is determined, continue to execute S1033.

步骤S1032、当目标版本数据信息的日志持久化参数为预设可见值时,将目标版本数据信息中的版本数据行确定为可见版本数据行,并对目标版本数据信息中的读取次数进行修改;Step S1032: When the log persistence parameter of the target version data information is a preset visible value, determine the version data row in the target version data information as a visible version data row, and modify the number of reads in the target version data information. ;

步骤S1033、当目标版本数据信息的日志持久化参数不为预设可见值时,将目标版本数据信息对应的读写事务加入到只读事务的依赖事务集合中,基于依赖事务集合,确定可见版本数据行,并对目标版本数据信息中的读取次数进行修改。Step S1033: When the log persistence parameter of the target version data information is not a preset visible value, add the read-write transaction corresponding to the target version data information to the dependent transaction set of the read-only transaction, and determine the visible version based on the dependent transaction set. data row, and modify the number of reads in the target version data information.

具体地,当目标版本数据信息的日志持久化参数为预设可见值时,确定目标版本数据信息对应的版本数据行为可见版本数据行。当目标版本数据信息的日志持久化参数不为预设可见值时,为了确保只读事务能够读取到正确的版本数据,需要将目标版本数据信息对应的读写事务加入到该只读事务自己的依赖事务集合中。进而通过依赖追踪方法,对依赖事务集合中的事务进行监测分析,直至依赖事务集合中每个被依赖的读写事务的日志持久化参数就变为预设可见值,得到可见版本数据行。当确定出只读事务对应的可见版本数据行之后,需要对可见版本数据行所属的目标版本数据信息中的读取次数进行修改,例如,使当前读取次数的数值+1。Specifically, when the log persistence parameter of the target version data information is a preset visible value, the version data row corresponding to the target version data information is determined to be a visible version data row. When the log persistence parameter of the target version data information is not a preset visible value, in order to ensure that the read-only transaction can read the correct version data, the read-write transaction corresponding to the target version data information needs to be added to the read-only transaction itself. in the set of dependent transactions. Then, through the dependency tracking method, the transactions in the dependent transaction set are monitored and analyzed until the log persistence parameter of each dependent read-write transaction in the dependent transaction set becomes a preset visible value, and a visible version data row is obtained. After the visible version data row corresponding to the read-only transaction is determined, the number of reads in the target version data information to which the visible version data row belongs needs to be modified, for example, the current number of reads is increased by 1.

进一步地,将目标版本数据信息对应的读写事务加入到只读事务的依赖事务集合中,包括步骤SA1(图中未示出)-步骤SA2(图中未示出),其中:Further, the read-write transaction corresponding to the target version data information is added to the dependent transaction set of the read-only transaction, including step SA1 (not shown in the figure) - step SA2 (not shown in the figure), where:

步骤SA1、基于目标版本数据信息的事务访问区间,确定目标版本数据信息对应的读写事务的事务标识符;Step SA1: Based on the transaction access interval of the target version data information, determine the transaction identifier of the read and write transaction corresponding to the target version data information;

步骤SA2、基于目标版本数据信息对应的读写事务的事务标识符,将目标版本数据信息对应的读写事务加入到只读事务的依赖事务集合中。Step SA2: Based on the transaction identifier of the read-write transaction corresponding to the target version data information, add the read-write transaction corresponding to the target version data information to the dependent transaction set of the read-only transaction.

具体地,在创建目标版本数据信息的事务访问区间时,事务访问区间的下限为创建该目标版本数据信息的读写事务的事务标识符。因此可以通过事务访问区间确定出需要进行依赖追踪的读写事务的事务标识符。进而将目标版本数据信息对应的读写事务加入到只读事务的依赖事务集合中,实现依赖追踪。Specifically, when creating a transaction access interval for target version data information, the lower limit of the transaction access interval is the transaction identifier of the read-write transaction that creates the target version data information. Therefore, the transaction identifier of the read-write transaction that requires dependency tracking can be determined through the transaction access interval. Then, the read-write transaction corresponding to the target version data information is added to the dependent transaction set of the read-only transaction to implement dependency tracking.

进一步地,在获取数据行对应的若干个版本数据信息之前,还包括步骤S01、当检测到读写事务请求修改数据行时,基于读写事务,创建数据行的版本数据信息,版本数据信息包括版本数据行、版本事务标识、读取次数、事务访问区间以及日志持久化参数,版本事务标识的初始值为创建版本数据信息的读写事务的事务标识符,日志持久化参数的初始值为预设不可见值。Further, before obtaining several version data information corresponding to the data row, step S01 is also included. When it is detected that a read-write transaction requests to modify the data row, based on the read-write transaction, create version data information of the data row. The version data information includes Version data row, version transaction identifier, number of reads, transaction access interval, and log persistence parameters. The initial value of the version transaction identifier is the transaction identifier of the read-write transaction that created the version data information. The initial value of the log persistence parameter is the preset value. Let the value be invisible.

对于本申请实施例,DolphinDB内存数据库采用了并发控制协议,用于在数据库系统中管理事务的并发访问,通过使用多版本并发控制机制和两阶段加锁协议来实现事务的并发执行和隔离。当读写事务需要对数据行进行修改时,会请求获取对应数据行的写锁。若检测到读写事务请求修改数据行,则读写事务在开始修改数据行之前,会根据读写事务创建该数据行的版本数据信息,版本数据信息中包含该读写事务需要修改的数据行数据,即版本数据行。版本数据信息还包括版本事务标识,当前读取该版本数据行的只读事务的数量,可以读取该版本数据行的只读事务的事务标识符区间(事务访问区间),以及用于表征读写事务的操作是否完成日志落盘的日志持久化参数。其中,版本事务标识的初始值为创建该版本数据信息的读写事务的事务标识符;日志持久化参数的初始值为预设不可见值,预设不可见值与预设可见值不同,用于表征不同的日志落盘状态。For the embodiment of this application, the DolphinDB in-memory database adopts a concurrency control protocol to manage concurrent access of transactions in the database system. The concurrent execution and isolation of transactions are achieved by using a multi-version concurrency control mechanism and a two-stage locking protocol. When a read-write transaction needs to modify a data row, it will request to obtain a write lock for the corresponding data row. If it is detected that a read-write transaction requests to modify a data row, the read-write transaction will create version data information of the data row based on the read-write transaction before starting to modify the data row. The version data information contains the data row that needs to be modified by the read-write transaction. Data, that is, version data rows. The version data information also includes the version transaction identifier, the current number of read-only transactions that read the data rows of this version, the transaction identifier interval (transaction access interval) of the read-only transactions that can read the data rows of this version, and the transaction access interval used to characterize the read The log persistence parameter determines whether the write transaction operation has completed log writing. Among them, the initial value of the version transaction identifier is the transaction identifier of the read-write transaction that created the version data information; the initial value of the log persistence parameter is the preset invisible value. The preset invisible value is different from the preset visible value. Use Used to represent different log placement statuses.

进一步地,在创建数据行的版本数据信息之后,还包括步骤S02(图中未示出)-步骤S04(图中未示出),其中:Further, after creating the version data information of the data row, steps S02 (not shown in the figure) to step S04 (not shown in the figure) are also included, wherein:

步骤S02、确定读写事务为写锁绑定状态;Step S02: Determine that the read and write transaction is in the write lock binding state;

步骤S03、在读写事务完成对数据行数据的修改操作之后,确定读写事务为写锁释放状态,并将读写事务对应的版本数据信息中的版本事务标识修改为预设获取锁值。Step S03: After the read-write transaction completes the modification operation on the data row data, determine that the read-write transaction is in the write lock release state, and modify the version transaction identifier in the version data information corresponding to the read-write transaction to the default acquisition lock value.

对于本申请实施例,在开始修改数据行之前,读写事务会需要获取写锁(Exclusive Lock)来保护被修改的数据行,即确定读写事务为写锁绑定状态。每个事务在开始时会获得一个视图(snapshot),该视图代表了事务开始时数据库的一致状态。当读写事务要对数据行进行修改时,它会根据视图的信息来判断是否能够修改该数据行,如果读写事务的视图与其他并发读写事务的版本不冲突,那么该读写事务可以生成新的版本并获取到该数据行的写锁进行写操作。在读写事务成功获得数据行的写锁之后,它可以进行对数据行进行修改操作,如更新、插入和删除的操作。一旦读写事务完成了对数据行的修改操作,它需要释放所持有的写锁,即将读写事务的状态修改为写锁释放状态。For the embodiment of this application, before starting to modify the data row, the read-write transaction will need to obtain a write lock (Exclusive Lock) to protect the modified data row, that is, it is determined that the read-write transaction is in a write lock-bound state. Each transaction obtains a view (snapshot) at the beginning, which represents the consistent state of the database at the beginning of the transaction. When a read-write transaction wants to modify a data row, it will determine whether the data row can be modified based on the view information. If the view of the read-write transaction does not conflict with the versions of other concurrent read-write transactions, then the read-write transaction can Generate a new version and obtain the write lock of the data row for write operations. After the read-write transaction successfully obtains the write lock of the data row, it can perform modification operations on the data row, such as update, insert, and delete operations. Once the read-write transaction completes the modification operation on the data row, it needs to release the write lock it holds, that is, change the status of the read-write transaction to the write lock release state.

进一步地,在版本数据信息对应的读写事务完成修改操作释放写锁之后,即版本数据信息对应的读写事务为写锁释放状态时,需要将该条版本数据信息中的版本事务标识修改为预设获取锁值。其中可以通过版本事务标识来判断其所属的版本数据信息对应的读写事务是否完成操作,预设获取锁值与读写事务的事务标识符不相同,当版本事务标识为预设获取锁值(读写事务的状态为写锁释放状态)时,其他只读事务可以获取该数据行的读锁。例如,事务的事务标识符为其创建时的时间戳,预设获取锁值为0,读写事务A的事务标识符为100,则版本事务标识的初始值为100,在读写事务A完成修改操作释放写锁之后,版本事务标识的初始值修改为0。Further, after the read-write transaction corresponding to the version data information completes the modification operation and releases the write lock, that is, when the read-write transaction corresponding to the version data information is in the write lock release state, the version transaction identifier in the version data information needs to be modified to Default acquisition lock value. The version transaction identifier can be used to determine whether the read-write transaction corresponding to the version data information to which it belongs has completed the operation. The default acquisition lock value is different from the transaction identifier of the read-write transaction. When the version transaction identifier is the default acquisition lock value ( When the status of a read-write transaction is the write lock release state), other read-only transactions can acquire the read lock of the data row. For example, the transaction identifier of a transaction is the timestamp when it was created. The default acquisition lock value is 0. The transaction identifier of read-write transaction A is 100. Then the initial value of the version transaction identifier is 100. After the read-write transaction A is completed, After the modification operation releases the write lock, the initial value of the version transaction identifier is modified to 0.

步骤S04、将读写事务的修改操作日志写入持久存储介质,修改操作日志包括读写事务对数据行的修改操作。Step S04: Write the modification operation log of the read-write transaction to the persistent storage medium. The modification operation log includes the modification operation of the data row by the read-write transaction.

对于本申请实施例,为了持久保存读写事务的操作,并确保ACID属性(原子性、一致性、隔离性、持久性),通常会将读写事务的操作记录写入持久存储介质,如磁盘或日志文件,这样可以确保即使发生系统故障,数据行的修改操作仍然可以恢复。将读写事务的操作记录写入持久存储介质是一个等待日志落盘的过程,在“等待日志落盘”阶段涉及磁盘I/O操作,并且为了保证数据的绝对安全,这个阶段通常需要一次“fsync”调用。“fsync” 是一个文件系统中的同步操作,用于确保将缓冲区或内存中的数据能够持久化到持久存储介质(磁盘)上,同时“fsync”的开销非常大,对于机械硬盘通常需要花费几个毫秒,即使是固态硬盘也要花费几百微秒。为了提升事务的吞吐量,本申请在读写事务的日志落盘之前,就需要将写锁释放,如图2所示,在前一个读写事务等待日志落盘时,并发的只读事务就可以正常开展工作。For the embodiment of this application, in order to persist the operations of read and write transactions and ensure ACID properties (atomicity, consistency, isolation, durability), the operation records of read and write transactions are usually written to a persistent storage medium, such as a disk. Or log file, this can ensure that even if a system failure occurs, the modification operation of the data row can still be recovered. Writing the operation records of read and write transactions to the persistent storage medium is a process of waiting for the log to be written to the disk. The "waiting for the log to be written to the disk" stage involves disk I/O operations, and in order to ensure the absolute security of the data, this stage usually requires a " fsync" call. "fsync" is a synchronization operation in the file system, which is used to ensure that the data in the buffer or memory can be persisted to the persistent storage medium (disk). At the same time, the overhead of "fsync" is very large, and it usually costs money for mechanical hard disks. A few milliseconds, even SSDs take hundreds of microseconds. In order to improve transaction throughput, this application needs to release the write lock before the log of the read-write transaction is placed on the disk. As shown in Figure 2, while the previous read-write transaction is waiting for the log to be placed on the disk, the concurrent read-only transaction will Can carry out work normally.

进一步地,在基于只读事务的事务标识符和若干个版本数据信息各自对应的事务访问区间,从若干个版本数据信息中确定目标版本数据信息之后,还包括步骤SB1(图中未示出)-步骤SB2(图中未示出),其中:Further, after determining the target version data information from the several version data information based on the transaction identifier of the read-only transaction and the corresponding transaction access intervals of the several version data information, step SB1 (not shown in the figure) is also included. - step SB2 (not shown in the figure), wherein:

步骤SB1、获取目标版本数据信息的版本事务标识;Step SB1: Obtain the version transaction identifier of the target version data information;

步骤SB2、当目标版本数据信息的版本事务标识为预设获取锁值时,确定只读事务为读锁绑定状态。Step SB2: When the version transaction identifier of the target version data information is the preset acquisition lock value, determine that the read-only transaction is in the read lock binding state.

对于本申请实施例,在从若干个版本数据信息中确定目标版本数据信息之后,获取目标版本数据信息的版本事务标识。当目标版本数据信息的版本事务标识为预设获取锁值时,这意味着其他事务能够读取该版本数据行,确定只读事务为读锁绑定状态。For the embodiment of the present application, after determining the target version data information from several versions of data information, the version transaction identifier of the target version data information is obtained. When the version transaction identifier of the target version data information is the preset acquisition lock value, this means that other transactions can read the version data row, and the read-only transaction is determined to be in a read lock binding state.

通过目标版本数据信息的版本事务标识,判断目标版本数据信息中的版本数据行是否已经完成修改,若已完成修改(版本事务标识为预设获取锁值),则向访问该版本数据的只读事务可以获取到相应的读锁,即只读事务为读锁绑定状态。读锁绑定状态意味着只读事务可以并发地读取目标版本数据信息,而不会与写事务发生冲突。这样可以提高并发性能,允许多个只读事务同时读取目标版本数据信息,增加系统的吞吐量。Use the version transaction identifier of the target version data information to determine whether the version data row in the target version data information has been modified. If the modification has been completed (the version transaction identifier is the default acquisition lock value), the read-only access to the version data The transaction can obtain the corresponding read lock, that is, the read-only transaction is in the read lock binding state. The read lock binding state means that read-only transactions can concurrently read target version data information without conflicting with write transactions. This can improve concurrency performance, allow multiple read-only transactions to read target version data information at the same time, and increase system throughput.

上述实施例从方法流程的角度介绍一种内存数据库事务管理的方法,下述实施例从虚拟模块或者虚拟单元的角度介绍了一种内存数据库事务管理的装置,具体详见下述实施例。The above embodiment introduces a method of in-memory database transaction management from the perspective of method flow. The following embodiment introduces a device for in-memory database transaction management from the perspective of virtual modules or virtual units. For details, see the following embodiments.

本申请实施例提供一种内存数据库事务管理的装置,如图3所示,该内存数据库事务管理的装置具体可以包括事务信息和版本数据信息获取模块201、目标版本数据信息确定模块202以及可见版本数据行确定模块203,其中:The embodiment of the present application provides a device for memory database transaction management. As shown in Figure 3, the device for memory database transaction management may specifically include a transaction information and version data information acquisition module 201, a target version data information determination module 202, and a visible version. Data row determination module 203, wherein:

事务信息和版本数据信息获取模块201,用于当检测到只读事务请求访问数据行时,获取只读事务的事务标识符和数据行对应的若干个版本数据信息,每个版本数据信息包括版本数据行、版本事务标识、读取次数、事务访问区间以及日志持久化参数,事务访问区间为可以读取版本数据行的只读事务的事务标识符区间,日志持久化参数用于表征创建版本数据行的读写事务的修改操作日志是否已写入持久存储介质中;The transaction information and version data information acquisition module 201 is used to obtain the transaction identifier of the read-only transaction and several version data information corresponding to the data row when a read-only transaction request is detected to access the data row. Each version data information includes a version Data rows, version transaction identifiers, read times, transaction access intervals, and log persistence parameters. The transaction access interval is the transaction identifier interval of a read-only transaction that can read version data rows. The log persistence parameters are used to characterize the creation of version data. Whether the modification operation log of the row's read-write transaction has been written to the persistent storage medium;

目标版本数据信息确定模块202,用于基于只读事务的事务标识符和若干个版本数据信息各自对应的事务访问区间,从若干个版本数据信息中确定目标版本数据信息,目标版本数据信息为只读事务指定访问的版本数据信息;The target version data information determination module 202 is used to determine the target version data information from several version data information based on the transaction identifier of the read-only transaction and the corresponding transaction access intervals of several version data information. The target version data information is only The read transaction specifies the version data information accessed;

可见版本数据行确定模块203,用于基于目标版本数据信息的日志持久化参数,确定可见版本数据行。The visible version data row determination module 203 is used to determine the visible version data row based on the log persistence parameters of the target version data information.

通过采用上述技术方案,根据只读事务的事务标识符,从若干个版本数据信息中确定出只读事务需要读取的目标版本数据信息;进而根据目标版本数据信息的日志持久化参数,判断读写事务的修改操作日志是否已写入持久存储介质中,只有在读写事务的修改操作日志已写入持久存储介质中的情况下,才将对应的版本数据行视为可见,即确定版本数据行。这样可以保证事务的正确性,并且可以避免读取到已被删除或尚未提交的数据。By adopting the above technical solution, based on the transaction identifier of the read-only transaction, the target version data information that the read-only transaction needs to read is determined from several versions of data information; and then based on the log persistence parameters of the target version data information, the read Whether the modification operation log of the write transaction has been written to the persistent storage medium. Only when the modification operation log of the read and write transaction has been written to the persistent storage medium, the corresponding version data row will be considered visible, that is, the version data will be determined. OK. This ensures the correctness of the transaction and avoids reading deleted or uncommitted data.

在一种可能实现的方式中,可见版本数据行确定模块203在基于目标版本数据行的日志持久化参数,确定可见版本数据行时,具体用于:In a possible implementation manner, when determining the visible version data row based on the log persistence parameters of the target version data row, the visible version data row determination module 203 is specifically used to:

在目标版本数据信息对应的读写事务的修改操作日志写入持久存储介质之后,将版本数据信息中的日志持久化参数修改为预设可见值;After the modification operation log of the read-write transaction corresponding to the target version data information is written to the persistent storage medium, modify the log persistence parameters in the version data information to the preset visible value;

当目标版本数据信息的日志持久化参数为预设可见值时,将目标版本数据信息中的版本数据行确定为可见版本数据行,并对目标版本数据信息中的读取次数进行修改;When the log persistence parameter of the target version data information is a preset visible value, determine the version data row in the target version data information as a visible version data row, and modify the number of reads in the target version data information;

当目标版本数据信息的日志持久化参数不为预设可见值时,将目标版本数据信息对应的读写事务加入到只读事务的依赖事务集合中,基于依赖事务集合,确定可见版本数据行,并对目标版本数据信息中的读取次数进行修改。When the log persistence parameter of the target version data information is not a preset visible value, add the read-write transaction corresponding to the target version data information to the dependent transaction set of the read-only transaction, and determine the visible version data row based on the dependent transaction set. And modify the number of reads in the target version data information.

在一种可能实现的方式中,可见版本数据行确定模块203在将目标版本数据信息对应的读写事务加入到只读事务的依赖事务集合中时,具体用于:In one possible implementation manner, when adding the read-write transaction corresponding to the target version data information to the dependent transaction set of the read-only transaction, the visible version data row determination module 203 is specifically used to:

基于目标版本数据信息的事务访问区间,确定目标版本数据信息对应的读写事务的事务标识符;Based on the transaction access interval of the target version data information, determine the transaction identifier of the read and write transaction corresponding to the target version data information;

基于目标版本数据信息对应的读写事务的事务标识符,将目标版本数据信息对应的读写事务加入到只读事务的依赖事务集合中。Based on the transaction identifier of the read-write transaction corresponding to the target version data information, the read-write transaction corresponding to the target version data information is added to the dependent transaction set of the read-only transaction.

在一种可能实现的方式中,一种内存数据库事务管理装置,还包括:In a possible implementation manner, an in-memory database transaction management device further includes:

版本数据信息创建模块,用于当检测到读写事务请求修改数据行时,基于读写事务,创建数据行的版本数据信息,版本数据信息包括版本数据行、版本事务标识、读取次数、事务访问区间以及日志持久化参数,版本事务标识的初始值为创建版本数据信息的读写事务的事务标识符,日志持久化参数的初始值为预设不可见值。The version data information creation module is used to create version data information of the data row based on the read-write transaction when a read-write transaction request is detected to modify the data row. The version data information includes version data rows, version transaction identifiers, read times, and transactions. Access interval and log persistence parameters. The initial value of the version transaction identifier is the transaction identifier of the read-write transaction that created the version data information. The initial value of the log persistence parameters is the preset invisible value.

在一种可能实现的方式中,一种内存数据库事务管理装置,还包括:In a possible implementation manner, an in-memory database transaction management device further includes:

写锁绑定状态确定模块,用于确定读写事务为写锁绑定状态;The write lock binding status determination module is used to determine that the read and write transactions are in the write lock binding status;

写锁释放状态确定模块,用于在读写事务完成对数据行数据的修改操作之后,确定读写事务为写锁释放状态,并将读写事务对应的版本数据信息中的版本事务标识修改为预设获取锁值;The write lock release state determination module is used to determine that the read and write transaction is in the write lock release state after the read and write transaction completes the modification operation of the data row data, and modifies the version transaction identifier in the version data information corresponding to the read and write transaction to Default acquisition lock value;

日志落盘模块,用于将读写事务的修改操作日志写入持久存储介质,修改操作日志包括读写事务对数据行的修改操作。The log writing module is used to write the modification operation log of the read-write transaction to the persistent storage medium. The modification operation log includes the modification operation of the data row by the read-write transaction.

在一种可能实现的方式中,一种内存数据库事务管理装置,还包括:In a possible implementation manner, an in-memory database transaction management device further includes:

版本事务标识获取模块,用于获取目标版本数据信息的版本事务标识;The version transaction identifier acquisition module is used to obtain the version transaction identifier of the target version data information;

读锁绑定状态确定模块,用于当目标版本数据信息的版本事务标识为预设获取锁值时,确定只读事务为读锁绑定状态。The read lock binding state determination module is used to determine that the read-only transaction is in the read lock binding state when the version transaction identifier of the target version data information is a preset acquisition lock value.

本申请实施例中提供了一种电子设备,如图4所示,图4所示的电子设备300包括:处理器301和存储器303。其中,处理器301和存储器303相连,如通过总线302相连。可选地,电子设备300还可以包括收发器304。需要说明的是,实际应用中收发器304不限于一个,该电子设备300的结构并不构成对本申请实施例的限定。An electronic device is provided in an embodiment of the present application, as shown in FIG. 4 . The electronic device 300 shown in FIG. 4 includes: a processor 301 and a memory 303 . Among them, the processor 301 and the memory 303 are connected, such as through a bus 302. Optionally, electronic device 300 may also include a transceiver 304. It should be noted that in practical applications, the number of transceivers 304 is not limited to one, and the structure of the electronic device 300 does not constitute a limitation on the embodiments of the present application.

处理器301可以是CPU(Central Processing Unit,中央处理器),通用处理器,DSP(Digital Signal Processor,数据信号处理器),ASIC(Application SpecificIntegrated Circuit,专用集成电路),FPGA(Field Programmable Gate Array,现场可编程门阵列)或者其他可编程逻辑器件、晶体管逻辑器件、硬件部件或者其任意组合。其可以实现或执行结合本申请公开内容所描述的各种示例性的逻辑方框,模块和电路。处理器301也可以是实现计算功能的组合,例如包含一个或多个微处理器组合,DSP和微处理器的组合等。The processor 301 may be a CPU (Central Processing Unit, central processing unit), a general-purpose processor, a DSP (Digital Signal Processor, data signal processor), ASIC (Application Specific Integrated Circuit, application specific integrated circuit), FPGA (Field Programmable Gate Array, field programmable gate array) or other programmable logic device, transistor logic device, hardware component, or any combination thereof. It may implement or execute the various illustrative logical blocks, modules, and circuits described in connection with this disclosure. The processor 301 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

总线302可包括一通路,在上述组件之间传送信息。总线302可以是PCI(Peripheral Component Interconnect,外设部件互连标准)总线或EISA(ExtendedIndustry Standard Architecture,扩展工业标准结构)总线等。总线302可以分为地址总线、数据总线、控制总线等。为便于表示,图4中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。Bus 302 may include a path that carries information between the above-mentioned components. The bus 302 may be a PCI (Peripheral Component Interconnect, Peripheral Component Interconnect Standard) bus or an EISA (Extended Industry Standard Architecture, Extended Industry Standard Architecture) bus, etc. The bus 302 can be divided into an address bus, a data bus, a control bus, etc. For ease of presentation, only one thick line is used in Figure 4, but it does not mean that there is only one bus or one type of bus.

存储器303可以是ROM(Read Only Memory,只读存储器)或可存储静态信息和指令的其他类型的静态存储设备,RAM(Random Access Memory,随机存取存储器)或者可存储信息和指令的其他类型的动态存储设备,也可以是EEPROM(Electrically ErasableProgrammable Read Only Memory,电可擦可编程只读存储器)、CD-ROM(Compact DiscRead Only Memory,只读光盘)或其他光盘存储、光碟存储(包括压缩光碟、激光碟、光碟、数字通用光碟、蓝光光碟等)、磁盘存储介质或者其他磁存储设备、或者能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。The memory 303 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, RAM (Random Access Memory, random access memory) or other types that can store information and instructions. Dynamic storage devices can also be EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact DiscRead Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, Laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), magnetic disk storage medium or other magnetic storage device, or any other device capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer medium, but not limited to this.

存储器303用于存储执行本申请方案的应用程序代码,并由处理器301来控制执行。处理器301用于执行存储器303中存储的应用程序代码,以实现前述方法实施例所示的内容。The memory 303 is used to store application program code for executing the solution of the present application, and is controlled by the processor 301 for execution. The processor 301 is used to execute the application program code stored in the memory 303 to implement the contents shown in the foregoing method embodiments.

其中,电子设备包括但不限于:移动电话、笔记本电脑、数字广播接收器、PDA(个人数字助理)、PAD(平板电脑)、PMP(便携式多媒体播放器)、车载终端(例如车载导航终端)等等的移动终端以及诸如数字TV、台式计算机等等的固定终端。还可以为服务器等。图4示出的电子设备仅仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。Among them, electronic devices include but are not limited to: mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PAD (tablet computers), PMP (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc. mobile terminals such as digital TVs, desktop computers, etc. Also for servers etc. The electronic device shown in FIG. 4 is only an example and should not impose any restrictions on the functions and usage scope of the embodiments of the present application.

本申请实施例提供了一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,当其在计算机上运行时,使得计算机可以执行前述方法实施例中相应内容。Embodiments of the present application provide a computer-readable storage medium. The computer-readable storage medium stores a computer program. When run on a computer, the computer can execute the corresponding content in the foregoing method embodiments.

应该理解的是,虽然附图的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,其可以以其他的顺序执行。而且,附图的流程图中的至少一部分步骤可以包括多个子步骤或者多个阶段,这些子步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,其执行顺序也不必然是依次进行,而是可以与其他步骤或者其他步骤的子步骤或者阶段的至少一部分轮流或者交替地执行。It should be understood that although various steps in the flowchart of the accompanying drawings are shown in sequence as indicated by arrows, these steps are not necessarily performed in the order indicated by arrows. Unless explicitly stated in this article, the execution of these steps is not strictly limited in order, and they can be executed in other orders. Moreover, at least some of the steps in the flow chart of the accompanying drawings may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but may be executed at different times, and their execution order is also It does not necessarily need to be performed sequentially, but may be performed in turn or alternately with other steps or sub-steps of other steps or at least part of the stages.

以上所述仅是本申请的部分实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本申请原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本申请的保护范围。The above are only some of the embodiments of the present application. It should be pointed out that those of ordinary skill in the technical field can also make several improvements and modifications without departing from the principles of the present application. These improvements and modifications can also be made. should be regarded as the scope of protection of this application.

Claims (9)

1. A memory database transaction management method, comprising:
when a read-only transaction request access data line is detected, acquiring a transaction identifier of the read-only transaction and a plurality of version data information corresponding to the data line, wherein each version data information comprises a version data line, a version transaction identifier, reading times, a transaction access interval and a log persistence parameter, the transaction access interval is a transaction identifier interval of the read-only transaction capable of reading the version data line, and the log persistence parameter is used for representing whether a modification operation log of a read-write transaction creating the version data line is written into a persistent storage medium;
determining target version data information from the plurality of version data information based on a transaction identifier of the read-only transaction and transaction access intervals corresponding to the plurality of version data information, wherein the target version data information designates accessed version data information for the read-only transaction;
And determining visible version data lines based on the log persistence parameters of the target version data information.
2. The method of claim 1, wherein determining visible version data lines based on log persistence parameters of the target version data lines comprises:
after a modification operation log of a read-write transaction corresponding to the target version data information is written into a persistent storage medium, modifying a log persistence parameter in the version data information into a preset visible value;
when the log persistence parameter of the target version data information is the preset visible value, determining the version data line in the target version data information as a visible version data line, and modifying the reading times in the target version data information;
when the log persistence parameter of the target version data information is not the preset visible value, adding the read-write transaction corresponding to the target version data information into a dependent transaction set of the read-only transaction, determining visible version data lines based on the dependent transaction set, and modifying the reading times in the target version data information.
3. The method for managing memory database transactions according to claim 2, wherein adding the read-write transaction corresponding to the target version data information to the dependent transaction set of the read-only transaction includes:
determining a transaction identifier of a read-write transaction corresponding to the target version data information based on the transaction access interval of the target version data information;
and adding the read-write transaction corresponding to the target version data information into a dependent transaction set of the read-only transaction based on the transaction identifier of the read-write transaction corresponding to the target version data information.
4. The method for managing memory database transactions according to claim 1, further comprising, before obtaining the version data information corresponding to the data line:
when the read-write transaction request is detected to modify the data row, based on the read-write transaction, version data information of the data row is created, wherein the version data information comprises a version data row, a version transaction identifier, reading times, a transaction access interval and a log persistence parameter, the initial value of the version transaction identifier is a transaction identifier of the read-write transaction for creating the version data information, and the initial value of the log persistence parameter is a preset invisible value.
5. The method of claim 4, further comprising, after creating version data information for the data line:
determining that the read-write transaction is in a write lock binding state;
after the read-write transaction completes the modification operation on the data of the data line, determining that the read-write transaction is in a write lock release state, and modifying a version transaction identifier in version data information corresponding to the read-write transaction into a preset acquisition lock value;
writing a modification operation log of the read-write transaction to a persistent storage medium, the modification operation log comprising modification operations of the read-write transaction to the data line.
6. The method of claim 5, further comprising, after determining the target version data information from the plurality of version data information based on the transaction identifier of the read-only transaction and the transaction access interval corresponding to each of the plurality of version data information:
a version transaction identifier of the target version data information is obtained;
and when the version transaction identifier of the target version data information is a preset acquisition lock value, determining that the read-only transaction is in a read lock binding state.
7. A memory database transaction management device, comprising:
the system comprises a transaction information and version data information acquisition module, a data storage module and a data storage module, wherein the transaction information and version data information acquisition module is used for acquiring a transaction identifier of a read-only transaction and a plurality of version data information corresponding to the data row when detecting that the read-only transaction requests to access the data row, each version data information comprises a version data row, a version transaction identifier, reading times, a transaction access interval and a log persistence parameter, the transaction access interval is a transaction identifier interval of the read-only transaction capable of reading the version data row, and the log persistence parameter is used for representing whether a modification operation log of a read-write transaction creating the version data row is written into a persistent storage medium;
the target version data information determining module is used for determining target version data information from the plurality of version data information based on the transaction identifier of the read-only transaction and the transaction access interval corresponding to the plurality of version data information, wherein the target version data information is version data information appointed for access by the read-only transaction;
and the visible version data row determining module is used for determining visible version data rows based on the log persistence parameters of the target version data information.
8. An electronic device, comprising:
at least one processor;
a memory;
at least one application, wherein the at least one application is stored in memory and configured to be executed by at least one processor, the at least one application configured to: performing the in-memory database transaction management method of any one of claims 1-6.
9. A computer-readable storage medium, comprising: a computer program stored with instructions capable of being loaded by a processor and executing the method of memory database transaction management as claimed in any one of claims 1 to 6.
CN202311063933.0A 2023-08-22 2023-08-22 Memory database transaction management method and device, electronic equipment and medium Pending CN117056313A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311063933.0A CN117056313A (en) 2023-08-22 2023-08-22 Memory database transaction management method and device, electronic equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311063933.0A CN117056313A (en) 2023-08-22 2023-08-22 Memory database transaction management method and device, electronic equipment and medium

Publications (1)

Publication Number Publication Date
CN117056313A true CN117056313A (en) 2023-11-14

Family

ID=88669057

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311063933.0A Pending CN117056313A (en) 2023-08-22 2023-08-22 Memory database transaction management method and device, electronic equipment and medium

Country Status (1)

Country Link
CN (1) CN117056313A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119149179A (en) * 2024-11-18 2024-12-17 苏州吉呗思数据技术有限公司 Multi-version concurrency control method, device, equipment and medium for database

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110153566A1 (en) * 2009-12-18 2011-06-23 Microsoft Corporation Optimistic serializable snapshot isolation
US20140297598A1 (en) * 2013-03-28 2014-10-02 Microsoft Corporation Recovery processing for database in persistent system
US20150120687A1 (en) * 2013-10-25 2015-04-30 International Business Machines Corporation Reducing database locking contention using multi-version data record concurrency control
CN106033439A (en) * 2015-03-13 2016-10-19 阿里巴巴集团控股有限公司 Method and system for processing distributed transaction
CN107577678A (en) * 2016-06-30 2018-01-12 华为技术有限公司 The method of processing data storehouse affairs, client and server
CN111259071A (en) * 2020-01-04 2020-06-09 浙江科技学院 Concurrent access control method in distributed database system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110153566A1 (en) * 2009-12-18 2011-06-23 Microsoft Corporation Optimistic serializable snapshot isolation
US20140297598A1 (en) * 2013-03-28 2014-10-02 Microsoft Corporation Recovery processing for database in persistent system
US20150120687A1 (en) * 2013-10-25 2015-04-30 International Business Machines Corporation Reducing database locking contention using multi-version data record concurrency control
CN106033439A (en) * 2015-03-13 2016-10-19 阿里巴巴集团控股有限公司 Method and system for processing distributed transaction
CN107577678A (en) * 2016-06-30 2018-01-12 华为技术有限公司 The method of processing data storehouse affairs, client and server
CN111259071A (en) * 2020-01-04 2020-06-09 浙江科技学院 Concurrent access control method in distributed database system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
O今晚打老虎O: "MySQL事务和锁", pages 1 - 4, Retrieved from the Internet <URL:https://blog.csdn.net/qq_37351027 /article/details/124423911> *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119149179A (en) * 2024-11-18 2024-12-17 苏州吉呗思数据技术有限公司 Multi-version concurrency control method, device, equipment and medium for database

Similar Documents

Publication Publication Date Title
CN110865888B (en) Resource loading method and device, server and storage medium
US10255108B2 (en) Parallel execution of blockchain transactions
CN111352902A (en) Log processing method, device, terminal device and storage medium
CN109086388B (en) Block chain data storage method, device, equipment and medium
US9542235B2 (en) Process-safe read/write locks
US9514170B1 (en) Priority queue using two differently-indexed single-index tables
US11327905B2 (en) Intents and locks with intent
KR20080031039A (en) A method and computer readable medium for managing memory access to a shared memory location
CN109791541B (en) Log serial number generation method and device and readable storage medium
US20130262388A1 (en) Database backup to highest-used page
CN117056313A (en) Memory database transaction management method and device, electronic equipment and medium
US20100262594A1 (en) Reducing access time for data in file systems when seek requests are received ahead of access requests
WO2022267676A1 (en) Data processing method and apparatus for shared memory, and device and medium
US11010332B2 (en) Set-based mutual exclusion using object metadata tags in a storage appliance
CN107016296B (en) Data index construction method, data index reading method, data index construction device, data reading device and electronic equipment
US8024380B2 (en) Improving data access speed while processing transaction requests from web based applications
EP3765972B1 (en) Index management in a multi-process environment
CN112000971A (en) File permission recording method, system and related device
US20050120352A1 (en) Meta directory server providing users the ability to customize work-flows
CN111984379A (en) Read-write transaction control method, system, terminal device and storage medium
US7657664B2 (en) Method and system for tracking device driver requests
US20250068332A1 (en) Data read-write control method and electronic device
CN116257519A (en) Method, device, computer equipment and storage medium for reading and writing data
CN115185458A (en) A data writing method, apparatus, storage medium and computer equipment
CN115454570A (en) Disaster recovery method, virtual machine system, device, and storage medium

Legal Events

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