WO2020107352A1 - Log sequence number generation method and apparatus and readable storage medium - Google Patents

Log sequence number generation method and apparatus and readable storage medium Download PDF

Info

Publication number
WO2020107352A1
WO2020107352A1 PCT/CN2018/118292 CN2018118292W WO2020107352A1 WO 2020107352 A1 WO2020107352 A1 WO 2020107352A1 CN 2018118292 W CN2018118292 W CN 2018118292W WO 2020107352 A1 WO2020107352 A1 WO 2020107352A1
Authority
WO
WIPO (PCT)
Prior art keywords
lock
hash
sequence number
log
available
Prior art date
Application number
PCT/CN2018/118292
Other languages
French (fr)
Chinese (zh)
Inventor
袁振南
朱阅岸
简怀兵
Original Assignee
袁振南
区链通网络有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 袁振南, 区链通网络有限公司 filed Critical 袁振南
Priority to CN201880002419.7A priority Critical patent/CN109791541B/en
Priority to PCT/CN2018/118292 priority patent/WO2020107352A1/en
Publication of WO2020107352A1 publication Critical patent/WO2020107352A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases

Landscapes

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

Abstract

A log sequence number generation method and apparatus and a readable storage medium. The method comprises: using a lock manager to receive a locking application for operating an element (S1); determining whether the element is available or not (S2); and if the element is available, using the lock manager to lock the element and generate a log sequence number corresponding to the operation (S3).

Description

日志序列号生成方法、装置及可读存储介质Log sequence number generating method, device and readable storage medium 【技术领域】【Technical Field】
本申请涉及数据库领域,特别是涉及一种日志序列号生成方法、装置及可读存储介质。The present application relates to the field of databases, and in particular, to a log sequence number generation method, device, and readable storage medium.
【背景技术】【Background technique】
传统的日志管理器是数据库管理系统(DataBase Management System,DBMS)的一个关键部件,它采用集中式的设计方式。所有的事务都在一个全局缓冲区上以追加的方式插入日志记录。日志给定数据库系统所有更新操作的顺序。日志序列号(log sequence number,LSN)是日志记录在磁盘上的地址,可以作为逻辑时间戳用来表示更新动作的先后次序,也是系统恢复时候日志记录重放的先后依据。The traditional log manager is a key component of a database management system (DataBase Management System, DBMS), which uses a centralized design approach. All transactions are appended to the log record in a global buffer. The log gives the sequence of all update operations of the database system. Log sequence number (LSN) is the address of the log record on the disk. It can be used as a logical timestamp to indicate the sequence of update actions, and it is also the basis for log record replay when the system is restored.
在传统的DBMS中,事务要对数据库对象进行操作时,需要向锁管理器申请封锁该数据库对象,申请成功后,才可以执行相应的操作。此外,如果本次操作要记录到日志,需要生成对应的LSN,具体包括如下步骤:1)首先获取日志缓冲区上对应的排他锁;2)为本次写操作生成对应的LSN;3)释放相应的排他锁。每次生成日志记录序列号之前都需要加上排他锁,而其它事务则竞争该排他锁。在并发场景下,该排他锁通常容易成为系统瓶颈。In a traditional DBMS, when a transaction needs to operate on a database object, it needs to apply to the lock manager to block the database object. After the application is successful, the corresponding operation can be performed. In addition, if the operation is to be recorded in the log, the corresponding LSN needs to be generated, including the following steps: 1) first obtain the corresponding exclusive lock on the log buffer; 2) generate the corresponding LSN for this write operation; 3) release The corresponding exclusive lock. Every time an exclusive lock needs to be added before generating the log record sequence number, other transactions compete for the exclusive lock. In concurrent scenarios, this exclusive lock is often easy to become a system bottleneck.
【发明内容】[Invention content]
本申请主要解决的技术问题是提供一种日志序列号生成方法、装置及可读存储介质,能够解决现有技术中LSN生成所用的排他锁容易成为系统瓶颈的问题。The technical problem mainly solved by the present application is to provide a log sequence number generation method, device and readable storage medium, which can solve the problem that the exclusive lock used for LSN generation in the prior art easily becomes a system bottleneck.
为了解决上述技术问题,本申请提供了一种日志序列号生成方法,该方法包括:利用锁管理器接收对元素进行操作的加锁申请;判断元素是否可用;若元素可用,则利用锁管理器为元素加锁并生成操作对应的日志序列号。In order to solve the above technical problems, the present application provides a method for generating a log sequence number. The method includes: using a lock manager to receive an application for locking an element; judging whether an element is available; if the element is available, using a lock manager Lock the element and generate the log sequence number corresponding to the operation.
为了解决上述技术问题,本申请提供了一种日志序列号生成装置,该装置包括:接收模块,用于利用锁管理器接收对元素进行操作的加锁申请;判断模 块,用于判断元素是否可用;生成模块,用于在元素可用时利用锁管理器为元素加锁并生成操作对应的日志序列号。In order to solve the above technical problems, the present application provides a log sequence number generating device. The device includes: a receiving module for receiving a lock application for operating an element with a lock manager; and a determining module for determining whether the element is available ; Generate module, used to lock the element when the element is available and generate the log sequence number corresponding to the operation.
为了解决上述技术问题,本申请提供了一种日志序列号生成装置,该装置包括处理器和存储器,处理器耦接存储器;处理器用于执行指令以利用锁管理器接收对元素进行操作的加锁申请;判断元素是否可用;若元素可用,则利用锁管理器为元素加锁并生成操作对应的日志序列号。In order to solve the above technical problems, the present application provides a log sequence number generating device, which includes a processor and a memory, the processor is coupled to the memory; the processor is used to execute instructions to use the lock manager to receive the lock for operating the element Apply; determine whether the element is available; if the element is available, use the lock manager to lock the element and generate the log sequence number corresponding to the operation.
为了解决上述技术问题,本申请提供了一种可读存储介质,存储有指令,指令被执行时实现前述的方法。In order to solve the above technical problem, the present application provides a readable storage medium that stores instructions, and when the instructions are executed, the foregoing method is implemented.
本申请的有益效果是:利用锁管理器接收对元素进行操作的加锁申请;判断元素是否可用;若元素可用,则利用锁管理器为元素加锁并生成操作对应的日志序列号,由锁管理器负责生成日志序列号而无需使用日志管理器,在事务进行操作及记录本次操作的过程中,只需要在锁管理器进行加锁竞争,不需要竞争生成日志序列号的排他锁,该排他锁不复存在,减少一次临界区的竞争操作,提升了数据库的性能。The beneficial effects of this application are: use the lock manager to receive the lock application for operating on the element; determine whether the element is available; if the element is available, use the lock manager to lock the element and generate the log sequence number corresponding to the operation, by the lock The manager is responsible for generating the log sequence number without using the log manager. During the operation of the transaction and the recording of this operation, it is only necessary to compete for locks in the lock manager. There is no need to compete for the exclusive lock to generate the log sequence number. The exclusive lock no longer exists, reducing a competitive operation in the critical section and improving the performance of the database.
【附图说明】【Explanation】
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。其中:In order to more clearly explain the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without paying any creative work, other drawings can be obtained based on these drawings. among them:
图1是本申请日志序列号生成方法一实施例的流程示意图;FIG. 1 is a schematic flowchart of an embodiment of a method for generating a log sequence number of this application;
图2是本申请日志序列号生成方法一具体实施例的流程示意图;2 is a schematic flowchart of a specific embodiment of a method for generating a log sequence number of this application;
图3是本申请日志序列号生成方法一具体实施例中哈希表的示意图;3 is a schematic diagram of a hash table in a specific embodiment of a method for generating a log sequence number of this application;
图4是本申请日志序列号生成装置一实施例的结构示意图;4 is a schematic structural diagram of an embodiment of an apparatus for generating a log sequence number in this application;
图5是本申请日志序列号生成装置另一实施例的结构示意图;5 is a schematic structural diagram of another embodiment of an apparatus for generating a log sequence number of this application;
图6是本申请可读存储介质一实施例的结构示意图。6 is a schematic structural diagram of an embodiment of a readable storage medium of the present application.
【具体实施方式】【detailed description】
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,以下各实施例中不冲突的可以相互结合。显然,所描述的实 施例仅是本申请的一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings in the embodiments of the present application. Those in the following embodiments that do not conflict may be combined with each other. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.
如图1所示,本申请日志序列号生成方法一实施例包括:As shown in FIG. 1, an embodiment of the method for generating a log sequence number of the present application includes:
S1:利用锁管理器接收对元素进行操作的加锁申请。S1: Use the lock manager to receive the lock application for operating on the element.
在数据库系统中,为了提高系统运行效率,常常是多事务并发执行。并发执行可能会产生多个事务同时对同一数据进行读取/写入的情况,可能导致数据的一致性被破坏,例如出现读脏数据、丢失更新等情况。为保障数据的一致性,数据库管理系统(DataBase Management System,DBMS)需要提供并发控制协议,以为并发事务实现不同的隔离级别,其中基于锁的并发控制协议(简称锁协议)是一种常用的并发控制协议。In the database system, in order to improve the operating efficiency of the system, multiple transactions are often executed concurrently. Concurrent execution may cause multiple transactions to read/write the same data at the same time, which may lead to the destruction of data consistency, such as the reading of dirty data and the loss of updates. To ensure data consistency, a database management system (DataBase Management System, DBMS) needs to provide a concurrency control protocol to achieve different isolation levels for concurrent transactions. Among them, the lock-based concurrency control protocol (referred to as the lock protocol) is a commonly used concurrency Control protocol.
在锁协议中,事务在执行操作前,需要先得到操作对象(即元素)的控制权利,这一过程也可以被称为加锁。DBMS中的锁管理器负责锁的申请和释放。事务需要先向锁管理器申请对对象进行加锁,申请成功之后才能对对象执行操作。In the lock protocol, the transaction needs to obtain the control right of the operation object (ie element) before performing the operation. This process can also be called locking. The lock manager in the DBMS is responsible for the application and release of locks. The transaction needs to apply to the lock manager to lock the object, and the operation can only be performed on the object after the application is successful.
在本发明一实施例中,锁管理器由哈希表实现,或者说,锁管理器包括至少一个哈希表。哈希表的关键码为数据库对象id。为了避免单个哈希表成为系统热点,锁管理器可以包括多个哈希表,多个哈希表可以通过对管理数据库中所有数据库对象的整体哈希表进行分段而得到,不同的哈希表中的数据库对象互不冲突,此时单个哈希表可以被视为整体哈希表的一个分段。In an embodiment of the invention, the lock manager is implemented by a hash table, or the lock manager includes at least one hash table. The key code of the hash table is the database object id. To prevent a single hash table from becoming a hotspot in the system, the lock manager can include multiple hash tables. Multiple hash tables can be obtained by segmenting the overall hash table of all database objects in the management database. Different hash The database objects in the table do not conflict with each other, in which case a single hash table can be regarded as a segment of the overall hash table.
S2:判断元素是否可用。S2: Determine whether the element is available.
为防止冲突,收到加锁申请后需要判断元素是否可用,即是否可以对元素执行申请的操作(即加锁申请对应的操作)。具体的,可以判断是否有其他事务正在对元素进行操作且排斥申请的操作。如果没有其他事务正在对元素进行操作,或者存在其他事务正在对元素进行操作但该操作不排斥申请的操作(例如二者皆为读操作),则元素可用,否则元素不可用。In order to prevent conflicts, it is necessary to determine whether the element is available after receiving the lock application, that is, whether the operation of the application can be performed on the element (that is, the operation corresponding to the lock application). Specifically, it can be determined whether there are other transactions that are operating on the element and excluding applications. If no other transaction is operating on the element, or there is another transaction that is operating on the element but the operation does not exclude the requested operation (for example, both are read operations), the element is available, otherwise the element is not available.
若元素可用,则跳转到S3;若元素不可用,则可以选择将申请加入加锁申请队列并挂起事务。If the element is available, jump to S3; if the element is not available, you can choose to add the application to the lock application queue and suspend the transaction.
S3:利用锁管理器为元素加锁并生成操作对应的日志序列号。S3: Use the lock manager to lock the element and generate the log sequence number corresponding to the operation.
加锁和生成LSN之间的先后顺序并无限制。加锁一般包括在元素处记录锁的信息,例如申请加锁的事务的信息,锁的类型(互斥锁、共享锁、意向锁等) 等。加锁之后,事务可以对元素进行操作。可以利用锁管理器在日志文件缓冲区中为该操作分配存储空间,生成该操作对应的日志序列号(log sequence number,LSN),无须使用日志管理器竞争排他锁。LSN标记了本次操作的日志记录对应的存储位置。The order between locking and LSN generation is not limited. Locking generally includes recording lock information at the element, such as information about the transaction applying for locking, the type of lock (mutually exclusive lock, shared lock, intention lock, etc.), etc. After locking, the transaction can operate on the element. You can use the lock manager to allocate storage space for the operation in the log file buffer to generate the log sequence number (LSN) corresponding to the operation without using the log manager to compete for exclusive locks. The LSN marks the storage location corresponding to the log records of this operation.
可选的,操作包括写操作,写操作包括新增、修改、删除中的至少一种。执行写操作之后数据库中的数据库对象会发生变化,应记录入日志。读操作之前虽然可能申请加锁,但由于不会改变数据库对象,可以选择不为读操作生成LSN。当然也可以为读操作生成LSN。Optionally, the operation includes a write operation, and the write operation includes at least one of adding, modifying, and deleting. After performing the write operation, the database objects in the database will change and should be recorded in the log. Although the lock may be applied before the read operation, but it will not change the database object, you can choose not to generate LSN for the read operation. Of course, LSNs can also be generated for read operations.
日志文件的数量可以为一个或者更多。当日志文件的数量大于一时,不同的日志文件可以并行操作,即满足以下条件:1)在不同的日志文件上操作的事务互不冲突,可以并行执行,即日志可以并行写入;2)系统崩溃恢复时候,不同日志文件上的解析可以同时进行,并行回放。可选的,每个日志文件只对应一个哈希表,例如日志文件和哈希表一一对应,可以实现LSN的并行生成,进一步提高系统并发运行效率。The number of log files can be one or more. When the number of log files is greater than one, different log files can be operated in parallel, that is, the following conditions are met: 1) transactions that operate on different log files do not conflict with each other and can be executed in parallel, that is, logs can be written in parallel; 2) system During crash recovery, parsing on different log files can be performed simultaneously and played back in parallel. Optionally, each log file corresponds to only one hash table. For example, the log files and the hash table have a one-to-one correspondence, which can achieve parallel LSN generation and further improve the efficiency of concurrent system operation.
即使在只采用只包括一个哈希表的锁管理器和一个日志文件的情况下,本实施例提供的方法生成的日志文件与传统的集中式日志管理器生成的日志文件不一定完全一致,但是本实施例提供的方法生成的日志文件中针对同一数据库对象的操作记录顺序与传统的日志和实际顺序保持一致,不会影响日志文件的实际使用。Even in the case where only a lock manager including only one hash table and one log file are used, the log file generated by the method provided in this embodiment may not be completely consistent with the log file generated by the traditional centralized log manager, but In the log file generated by the method provided in this embodiment, the operation record sequence for the same database object is consistent with the traditional log and the actual sequence, and does not affect the actual use of the log file.
通过本实施例的实施,由锁管理器负责生成日志序列号而无需使用日志管理器,在事务进行操作及记录本次操作的过程中,只需要在锁管理器进行加锁竞争,不需要竞争生成日志序列号的排他锁,该排他锁不复存在,减少一次临界区的竞争操作,提升了数据库的性能。Through the implementation of this embodiment, the lock manager is responsible for generating the log sequence number without using the log manager. During the operation of the transaction and the recording of this operation, the lock manager only needs to compete with the lock, and no competition is required. Generate an exclusive lock for the log sequence number. The exclusive lock no longer exists, reducing a contention operation in the critical section and improving the performance of the database.
如图2和图3所示,在本申请一具体实施例中,日志序列号生成方法包括:As shown in FIGS. 2 and 3, in a specific embodiment of the present application, the log sequence number generation method includes:
S11:利用锁管理器接收对元素进行操作的加锁申请。S11: Use the lock manager to receive a lock application for operating on the element.
本实施例是在前一实施例的基础上,采用哈希表实现锁管理器,其中与前一实施例相同的部分不再重复。This embodiment is based on the previous embodiment, using a hash table to implement the lock manager, and the same parts as in the previous embodiment are not repeated.
哈希表(也叫散列表),是根据关键码而直接进行访问的数据结构。哈希表的关键码为数据库对象id。也就是说,它通过把关键码映射到表中一个位置来访问记录,以加快查找的速度,这个映射函数叫做哈希函数(散列函数)。Hash tables (also called hash tables) are data structures that are accessed directly based on key codes. The key code of the hash table is the database object id. In other words, it accesses records by mapping key codes to a location in the table to speed up the search. This mapping function is called a hash function (hash function).
哈希表可以看成数组+链表的数据结构,数组中的每个元素表示数据库中一 个数据库对象的关键码,数组中的每个元素分别对应一个哈希桶,哈希桶中存放了记录该数据库对象的锁信息。A hash table can be regarded as an array + linked list data structure. Each element in the array represents the key code of a database object in the database. Each element in the array corresponds to a hash bucket. The hash bucket stores the record Lock information for database objects.
S12:计算元素的哈希函数值。S12: Calculate the hash function value of the element.
S13:在至少一个哈希表中找到哈希函数值对应的哈希桶。S13: Find a hash bucket corresponding to the hash function value in at least one hash table.
S14:判断哈希桶中是否存在排斥操作的其他锁。S14: Determine whether there are other locks that exclude operations in the hash bucket.
若哈希桶中不存在排斥操作的其他锁,意味着元素可用,跳转到S15。If there is no other lock that excludes the operation in the hash bucket, it means that the element is available, jump to S15.
S15:利用锁管理器向哈希函数值对应的哈希桶中插入锁,并在哈希桶所在的哈希表对应的日志文件缓冲区中生成操作对应的日志序列号。S15: Use the lock manager to insert a lock into the hash bucket corresponding to the hash function value, and generate a log sequence number corresponding to the operation in the log file buffer corresponding to the hash table where the hash bucket is located.
生成的日志序列号LSN i,i表示本次操作的序号。 The generated log sequence number LSN i , i represents the sequence number of this operation.
如图4所示,本申请日志序列号生成装置一实施例包括:As shown in FIG. 4, an embodiment of the log sequence number generating device of the present application includes:
接收模块11,用于利用锁管理器接收对元素进行操作的加锁申请。The receiving module 11 is used to receive a lock application for operating an element by using a lock manager.
判断模块12,用于判断元素是否可用。The judgment module 12 is used to judge whether the element is available.
生成模块13,用于在元素可用时利用锁管理器为元素加锁并生成操作对应的日志序列号。The generating module 13 is configured to use a lock manager to lock the element when the element is available and generate a log sequence number corresponding to the operation.
如图5所示,本申请日志序列号生成装置另一实施例包括:处理器110和存储器120。As shown in FIG. 5, another embodiment of the log sequence number generating device of the present application includes: a processor 110 and a memory 120.
处理器110控制日志序列号生成装置的操作,处理器110还可以称为CPU(Central Processing Unit,中央处理单元)。处理器110可能是一种集成电路芯片,具有信号序列的处理能力。处理器110还可以是通用处理器、数字信号序列处理器(DSP)、专用集成电路(ASIC)、现成可编程门阵列(FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The processor 110 controls the operation of the log sequence number generating device. The processor 110 may also be called a CPU (Central Processing Unit). The processor 110 may be an integrated circuit chip with signal sequence processing capabilities. The processor 110 may also be a general-purpose processor, a digital signal sequence processor (DSP), an application specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware Components. The general-purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
存储器120存储处理器110工作所需要的指令和数据。The memory 120 stores instructions and data necessary for the processor 110 to work.
处理器110用于执行指令以实现本申请日志序列号生成方法任一实施例及可能的组合所提供的方法。The processor 110 is configured to execute instructions to implement the method provided by any embodiment and possible combination of the method for generating a log sequence number of the present application.
如图6所示,本申请可读存储介质一实施例包括存储器210,存储器210存储有指令,该指令被执行时实现本申请日志序列号生成方法任一实施例及可能的组合所提供的方法。As shown in FIG. 6, an embodiment of the readable storage medium of the present application includes a memory 210, and the memory 210 stores instructions, which are executed to implement the method provided by any embodiment of the method for generating a log sequence number of the present application and possible combinations .
存储器210可以包括只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、闪存(Flash Memory)、硬盘、光盘等。The memory 210 may include read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), flash memory (Flash Memory), hard disk, optical disk, and the like.
在本申请所提供的几个实施例中,应该理解到,所揭露的方法和装置,可 以通过其它的方式实现。例如,以上所描述的装置实施方式仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed method and apparatus may be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of the module or unit is only a division of logical functions. In actual implementation, there may be other divisions, for example, multiple units or components may be The combination can either be integrated into another system, or some features can be ignored, or not implemented. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施方式方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理包括,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may be physically included separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or software functional unit.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机装置(可以是个人计算机,服务器,或者网络装置等)或处理器(processor)执行本申请各个实施方式所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application essentially or part of the contribution to the existing technology or all or part of the technical solution can be embodied in the form of a software product, the computer software product is stored in a storage medium , Including several instructions to enable a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program code .
以上所述仅为本申请的实施方式,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。The above are only the embodiments of the present application, and therefore do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made by the description and drawings of this application, or directly or indirectly used in other related technologies In the field, the same reason is included in the scope of patent protection of this application.

Claims (13)

  1. 一种日志序列号生成方法,其特征在于,所述方法包括:A log sequence number generating method, characterized in that the method includes:
    利用锁管理器接收对元素进行操作的加锁申请;Use the lock manager to receive lock applications for operating on elements;
    判断所述元素是否可用;Determine whether the element is available;
    若所述元素可用,则利用所述锁管理器为所述元素加锁并生成所述操作对应的日志序列号。If the element is available, the lock manager is used to lock the element and generate a log sequence number corresponding to the operation.
  2. 根据权利要求1所述的方法,其特征在于,The method of claim 1, wherein:
    所述锁管理器包括至少一个哈希表。The lock manager includes at least one hash table.
  3. 根据权利要求2所述的方法,其特征在于,The method according to claim 2, characterized in that
    所述判断所述元素是否可用包括:The judging whether the element is available includes:
    计算所述元素的哈希函数值;Calculate the hash function value of the element;
    在所述至少一个哈希表中找到所述哈希函数值对应的哈希桶;Find a hash bucket corresponding to the hash function value in the at least one hash table;
    判断所述哈希桶中是否存在排斥所述操作的其他锁;Determine whether there are other locks in the hash bucket that exclude the operation;
    若所述哈希桶中不存在排斥所述操作的其他锁,则判定所述元素可用,否则判定所述元素不可用。If there is no other lock in the hash bucket that excludes the operation, the element is determined to be available, otherwise the element is determined to be unavailable.
  4. 根据权利要求3所述的方法,其特征在于,The method according to claim 3, characterized in that
    所述利用所述锁管理器为所述元素加锁并生成所述操作对应的日志序列号包括:The use of the lock manager to lock the element and generate a log sequence number corresponding to the operation includes:
    利用所述锁管理器向所述哈希函数值对应的哈希桶中插入所述锁,并在所述哈希桶所在的所述哈希表对应的日志文件缓冲区中生成所述操作对应的日志序列号。Use the lock manager to insert the lock into a hash bucket corresponding to the hash function value, and generate the operation correspondence in a log file buffer corresponding to the hash table where the hash bucket is located Log sequence number.
  5. 根据权利要求2-4中任一项所述的方法,其特征在于,The method according to any one of claims 2-4, characterized in that
    所述哈希表的数量大于一,且每个所述哈希表对应一个日志文件,且不同的所述日志文件可以并行操作。The number of the hash tables is greater than one, and each of the hash tables corresponds to a log file, and different log files can be operated in parallel.
  6. 根据权利要求1-4中任一项所述的方法,其特征在于,The method according to any one of claims 1-4, characterized in that
    所述操作包括写操作。The operation includes a write operation.
  7. 一种日志序列号生成装置,其特征在于,包括:A log sequence number generating device, characterized in that it includes:
    接收模块,用于利用锁管理器接收对元素进行操作的加锁申请;The receiving module is used to receive a lock application for operating an element by using a lock manager;
    判断模块,用于判断所述元素是否可用;The judgment module is used to judge whether the element is available;
    生成模块,用于在所述元素可用时利用所述锁管理器为所述元素加锁并生 成所述操作对应的日志序列号。The generating module is configured to use the lock manager to lock the element when the element is available and generate a log sequence number corresponding to the operation.
  8. 一种日志序列号生成装置,其特征在于,包括处理器和存储器,所述处理器耦接所述存储器;A log sequence number generating device, characterized in that it includes a processor and a memory, and the processor is coupled to the memory;
    所述处理器用于执行指令以利用锁管理器接收对元素进行操作的加锁申请;判断所述元素是否可用;若所述元素可用,则利用所述锁管理器为所述元素加锁并生成所述操作对应的日志序列号。The processor is used to execute an instruction to use a lock manager to receive an application for locking an element; determine whether the element is available; if the element is available, use the lock manager to lock and generate the element The log sequence number corresponding to the operation.
  9. 根据权利要求8所述的装置,其特征在于,The device according to claim 8, characterized in that
    所述锁管理器包括至少一个哈希表。The lock manager includes at least one hash table.
  10. 根据权利要求9所述的装置,其特征在于,The device according to claim 9, characterized in that
    所述处理器用于执行指令以计算所述元素的哈希函数值;在所述至少一个哈希表中找到所述哈希函数值对应的哈希桶;判断所述哈希桶中是否存在排斥所述操作的其他锁;若所述哈希桶中不存在排斥所述操作的其他锁,则利用所述锁管理器向所述哈希函数值对应的哈希桶中插入所述锁,并在所述哈希桶所在的所述哈希表对应的日志文件缓冲区中生成所述操作对应的日志序列号。The processor is used to execute an instruction to calculate a hash function value of the element; find a hash bucket corresponding to the hash function value in the at least one hash table; determine whether there is exclusion in the hash bucket Other locks of the operation; if there is no other lock in the hash bucket that excludes the operation, the lock manager is used to insert the lock into the hash bucket corresponding to the hash function value, and A log sequence number corresponding to the operation is generated in a log file buffer corresponding to the hash table where the hash bucket is located.
  11. 根据权利要求9或10所述的装置,其特征在于,The device according to claim 9 or 10, characterized in that
    所述哈希表的数量大于一,且每个所述哈希表对应一个日志文件,且不同的日志文件可以并行操作。The number of the hash tables is greater than one, and each of the hash tables corresponds to a log file, and different log files can be operated in parallel.
  12. 根据权利要求8-10中任一项所述的装置,其特征在于,The device according to any one of claims 8-10, characterized in that
    所述操作包括写操作。The operation includes a write operation.
  13. 一种可读存储介质,存储有指令,其特征在于,所述指令被执行时实现如权利要求1-6中任一项所述的方法。A readable storage medium storing instructions, characterized in that, when the instructions are executed, the method according to any one of claims 1-6 is implemented.
PCT/CN2018/118292 2018-11-29 2018-11-29 Log sequence number generation method and apparatus and readable storage medium WO2020107352A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201880002419.7A CN109791541B (en) 2018-11-29 2018-11-29 Log serial number generation method and device and readable storage medium
PCT/CN2018/118292 WO2020107352A1 (en) 2018-11-29 2018-11-29 Log sequence number generation method and apparatus and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2018/118292 WO2020107352A1 (en) 2018-11-29 2018-11-29 Log sequence number generation method and apparatus and readable storage medium

Publications (1)

Publication Number Publication Date
WO2020107352A1 true WO2020107352A1 (en) 2020-06-04

Family

ID=66499478

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/118292 WO2020107352A1 (en) 2018-11-29 2018-11-29 Log sequence number generation method and apparatus and readable storage medium

Country Status (2)

Country Link
CN (1) CN109791541B (en)
WO (1) WO2020107352A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113377641B (en) * 2021-06-24 2022-11-04 上海哔哩哔哩科技有限公司 Log statistical method and system

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140067761A1 (en) * 2012-08-28 2014-03-06 Dhruva Chakrabarti Logging modifications to a variable in persistent memory
CN105205178A (en) * 2015-10-26 2015-12-30 北京美数信息科技有限公司 Multi-process access memory database system
CN105653680A (en) * 2015-12-29 2016-06-08 北京农信互联科技有限公司 Method and system for storing data on the basis of document database
US20180032412A1 (en) * 2016-07-26 2018-02-01 Hewlett Packard Enterprise Development Lp Resume host access based on transaction logs

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100452725C (en) * 2007-02-02 2009-01-14 杭州华三通信技术有限公司 Log backup method and system unit and device for implementing the same
KR101419428B1 (en) * 2012-10-17 2014-07-17 주식회사 리얼타임테크 Apparatus for logging and recovering transactions in database installed in a mobile environment and method thereof
CN103729442B (en) * 2013-12-30 2017-11-24 华为技术有限公司 Record the method and database engine of transaction journal
US20180144015A1 (en) * 2016-11-18 2018-05-24 Microsoft Technology Licensing, Llc Redoing transaction log records in parallel

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140067761A1 (en) * 2012-08-28 2014-03-06 Dhruva Chakrabarti Logging modifications to a variable in persistent memory
CN105205178A (en) * 2015-10-26 2015-12-30 北京美数信息科技有限公司 Multi-process access memory database system
CN105653680A (en) * 2015-12-29 2016-06-08 北京农信互联科技有限公司 Method and system for storing data on the basis of document database
US20180032412A1 (en) * 2016-07-26 2018-02-01 Hewlett Packard Enterprise Development Lp Resume host access based on transaction logs

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
CONCURRENTHASHMAP, 7 May 2012 (2012-05-07), Retrieved from the Internet <URL:https://blog.csdn.net/cbjcry/article/details/84214397> *
LEVANDOSKI, JUSTIN J.: "Deuteronomy: Transaction Support for Cloud Data", 5TH BIENNIAL CONFERENCE ON INNOVATIVE DATA SYSTEMS RESEARCH, 11 October 2011 (2011-10-11), XP055066760 *

Also Published As

Publication number Publication date
CN109791541B (en) 2023-11-24
CN109791541A (en) 2019-05-21

Similar Documents

Publication Publication Date Title
US10180946B2 (en) Consistent execution of partial queries in hybrid DBMS
CA3121919C (en) System and method for augmenting database applications with blockchain technology
US11386065B2 (en) Database concurrency control through hash-bucket latching
US9189487B2 (en) Method for recording transaction log, and database engine
US10599630B2 (en) Elimination of log file synchronization delay at transaction commit time
US11934383B2 (en) Mimetic database-based network operating system design method
US20130262426A1 (en) Method and apparatus for accessing database and database application system
KR20130115995A (en) Checkpoints for a file system
US20150347315A1 (en) Transactional memory
US20160110265A1 (en) Handling server and client operations uninterruptedly during pack and audit processes
CN106155839B (en) A kind of method and apparatus for Backup Data
US11748215B2 (en) Log management method, server, and database system
WO2014153940A1 (en) Method and apparatus for processing redo data of database
WO2022048358A1 (en) Data processing method and device, and storage medium
CN111125040A (en) Method, apparatus and storage medium for managing redo log
JP2004252986A (en) System and method of distributing replication command
JP2023541298A (en) Transaction processing methods, systems, devices, equipment, and programs
WO2023197404A1 (en) Object storage method and apparatus based on distributed database
WO2020119709A1 (en) Data merging implementation method, device, system, and storage medium
CN115408411A (en) Data writing method and device, electronic equipment and storage medium
WO2022242372A1 (en) Object processing method and apparatus, computer device, and storage medium
JP5105713B2 (en) Information processing device
US20120059997A1 (en) Apparatus and method for detecting data race
WO2022048416A1 (en) Operation request processing method and apparatus, and device, and readable storage medium, and system
CN110019527B (en) Slave library reading method, related device and equipment

Legal Events

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

Ref document number: 18941805

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18941805

Country of ref document: EP

Kind code of ref document: A1