JP2018049394A - Database management device, database management method, and database management program - Google Patents

Database management device, database management method, and database management program Download PDF

Info

Publication number
JP2018049394A
JP2018049394A JP2016183484A JP2016183484A JP2018049394A JP 2018049394 A JP2018049394 A JP 2018049394A JP 2016183484 A JP2016183484 A JP 2016183484A JP 2016183484 A JP2016183484 A JP 2016183484A JP 2018049394 A JP2018049394 A JP 2018049394A
Authority
JP
Japan
Prior art keywords
unit
lock
database management
execution
shared storage
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP2016183484A
Other languages
Japanese (ja)
Other versions
JP6490642B2 (en
Inventor
圭 山地
Kei Yamaji
圭 山地
基孝 金松
Mototaka Kanematsu
基孝 金松
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.)
Toshiba Corp
Original Assignee
Toshiba Corp
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 Toshiba Corp filed Critical Toshiba Corp
Priority to JP2016183484A priority Critical patent/JP6490642B2/en
Publication of JP2018049394A publication Critical patent/JP2018049394A/en
Application granted granted Critical
Publication of JP6490642B2 publication Critical patent/JP6490642B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

PROBLEM TO BE SOLVED: To provide a database management device capable of improving responce performance to a writing request from plural clients, and a database management method and database management program.SOLUTION: A large unit lock is executed in a first mode with a restriction by an execution part other than the execution part which has execute the large unit lock, which a series of processing provided for writing to a first unit area included in an area where the large unit lock is allowed to be carried out.SELECTED DRAWING: Figure 8

Description

本発明の実施形態は、データベース管理装置、データベース管理方法、およびデータベース管理プログラムに関する。   Embodiments described herein relate generally to a database management apparatus, a database management method, and a database management program.

複数のクライアントが利用するデータベース管理装置においては、ある領域への書き込みを行う権利と読み出しを行う権利の一方または双方を専有する、ロックと称される動作が行われる場合がある。ロックの種別が複数存在する場合に、それらの組み合わせによって生じ得るデッドロックを回避する仕組みなどが開示されている。   In a database management apparatus used by a plurality of clients, there is a case where an operation called “lock” is performed in which one or both of the right to write to a certain area and the right to read are exclusively used. A mechanism for avoiding a deadlock that may occur due to a combination of lock types when a plurality of types exist is disclosed.

また、ロックには、レコードなどの小単位で行うものと、ページやテーブル、ブロックといった大単位で行うものとが混在する場合がある。なお、必要に応じてロックの単位を切り替える手法は、ロックエスカレーションと称されている。   In addition, there are cases where the lock is performed in small units such as records and the lock performed in large units such as pages, tables, and blocks. The method of switching the lock unit as needed is called lock escalation.

従来の技術では、大単位で行われるロックが実行されている場合、その大単位に含まれる小単位への書き込みはロック要求の段階で拒絶されるため、大単位のロックが解放されるまで、小単位への書き込みを行うために必要な処理を行うことができなかった。この結果、複数のクライアントからの書き込みが重複して要求される場合に、データベース管理装置の応答性が悪くなる場合があった。   In the conventional technique, when a lock performed in a large unit is executed, writing to the small unit included in the large unit is rejected at the lock request stage, so until the large unit lock is released, The processing necessary for writing to the small unit could not be performed. As a result, the responsiveness of the database management apparatus may be deteriorated when writing from a plurality of clients is requested redundantly.

特許第5621904号公報Japanese Patent No. 5621904

本発明が解決しようとする課題は、複数のクライアントからの書き込みが要求される場合における応答性を向上させることができるデータベース管理装置、データベース管理方法、およびデータベース管理プログラムを提供することである。   The problem to be solved by the present invention is to provide a database management apparatus, a database management method, and a database management program capable of improving the responsiveness when writing from a plurality of clients is requested.

実施形態のデータベース管理装置は、複数のクライアントにそれぞれ対応して複数のデータベース管理部を起動させるように構成される。前記複数のデータベース管理部は、それぞれ、対応するクライアントから取得されるコマンドに従って、前記複数のデータベース管理部によって共有される共有ストレージに対する処理を実行する実行部を有する。前記複数の実行部のそれぞれは、前記共有ストレージに書き込み処理を行う前に、前記共有ストレージの領域の一部を第1単位でロックする小単位ロック、または、前記共有ストレージの領域の一部または全部を前記第1単位より大きい第2単位でロックする大単位ロックを実行する。前記大単位ロックは、前記大単位ロックを行った実行部以外の実行部による、前記大単位ロックが行われた領域に含まれる第1単位の領域に対する書き込みに備えた処理を、制限付きで許容する第1モードで実行される。   The database management apparatus according to the embodiment is configured to activate a plurality of database management units corresponding to a plurality of clients, respectively. Each of the plurality of database management units has an execution unit that executes processing for the shared storage shared by the plurality of database management units in accordance with a command acquired from a corresponding client. Each of the plurality of execution units includes a small unit lock that locks a part of the shared storage area in a first unit before performing a write process on the shared storage, or a part of the shared storage area or A large-unit lock is performed in which everything is locked in a second unit larger than the first unit. The large-unit lock allows, with restriction, processing for preparing for writing to the first unit area included in the area where the large-unit lock is performed by an execution unit other than the execution unit that performed the large-unit lock. In the first mode.

第1の実施形態に係るデータベース管理装置1の機能構成と使用環境の一例を示す図。The figure which shows an example of a function structure and use environment of the database management apparatus 1 which concerns on 1st Embodiment. データベース管理装置1による共有ストレージ100の管理区分を示す図。The figure which shows the management division of the shared storage 100 by the database management apparatus 1. FIG. ロック表24の内容の一例を示す図。The figure which shows an example of the content of the lock table. テーブルロックに関する3つのモードの効力を示す図。The figure which shows the effect of three modes regarding a table lock. データベース管理装置1のハードウェア構成の一例を示す図。The figure which shows an example of the hardware constitutions of the database management apparatus 1. テーブルロックの利点について説明するための図。The figure for demonstrating the advantage of a table lock. 共有モードまたは排他モードによってテーブルロックがなされた場面を示す図。The figure which shows the scene where the table lock was made | formed by shared mode or exclusive mode. 協調モードによってテーブルロックがなされた場面を示す図。The figure which shows the scene where the table lock was made | formed by cooperation mode. ロック制御部22により実行される処理の流れの一例を示すフローチャート。5 is a flowchart illustrating an example of a flow of processing executed by the lock control unit 22. ロック要求の結果を受けて各スレッド10により実行される処理の流れの一例を示すフローチャート。6 is a flowchart illustrating an example of a flow of processing executed by each thread 10 in response to a lock request result. 第1の実施形態におけるロック表24の推移などを示す図。The figure which shows transition etc. of the lock table 24 in 1st Embodiment. 第1の実施形態におけるロック表24の推移などを示す図。The figure which shows transition etc. of the lock table 24 in 1st Embodiment. 第1の実施形態におけるロック表24の推移などを示す図。The figure which shows transition etc. of the lock table 24 in 1st Embodiment. 変形例に係るデータベース管理装置1Aの機能成と使用環境の一例を示す図。The figure which shows an example of the functional composition and use environment of 1 A of database management apparatuses which concern on a modification. 第2の実施形態において使用されるロック表24Bの内容の一例を示す図。The figure which shows an example of the content of the lock table 24B used in 2nd Embodiment. 第2の実施形態におけるロック表24の推移などを示す図。The figure which shows transition etc. of the lock table 24 in 2nd Embodiment. 第3の実施形態に係るデータベース管理装置1Cの機能構成と使用環境の一例を示す図。The figure which shows an example of a function structure and use environment of 1 C of database management apparatuses which concern on 3rd Embodiment. 第3の実施形態に係るデータベース管理装置1Cの動作を模式的に示す図。The figure which shows typically operation | movement of 1 C of database management apparatuses which concern on 3rd Embodiment.

以下、実施形態のデータベース管理装置、データベース管理方法、およびデータベース管理プログラムを、図面を参照して説明する。実施形態のデータベース管理装置は、一以上のプロセッサにより実現される。データベース管理装置は、複数のクライアントにそれぞれ対応した複数のスレッド(データベース管理部)を起動させ、複数のクライアントからの共有ストレージへのアクセス要求に対応可能な装置である。各スレッドは、対応するクライアントから取得されるコマンドに従って、共有ストレージに対する処理を実行する。   Hereinafter, a database management device, a database management method, and a database management program according to embodiments will be described with reference to the drawings. The database management apparatus according to the embodiment is realized by one or more processors. The database management device is a device that can start a plurality of threads (database management units) respectively corresponding to a plurality of clients and can respond to access requests to the shared storage from the plurality of clients. Each thread executes processing for the shared storage according to a command acquired from the corresponding client.

また、各スレッドは、共有ストレージへの書き込みを行う場合に、共有ストレージの領域の一部を第1単位でロックする小単位ロック、または、共有ストレージの領域の一部または全部を第1単位より大きい第2単位でロックする大単位ロックを実行する。以下の説明では、第1単位が「レコード」であるものとし、小単位ロックを「レコードロック」と称する。また、第2単位が「テーブル」であるものとし、大単位ロックを「テーブルロック」と称する。   In addition, when writing to the shared storage, each thread locks a small unit lock that locks a part of the shared storage area in the first unit, or a part or all of the shared storage area from the first unit. Perform a large unit lock that locks on a large second unit. In the following description, the first unit is assumed to be “record”, and the small unit lock is referred to as “record lock”. The second unit is assumed to be a “table”, and the large unit lock is referred to as a “table lock”.

また、以下の説明では、ロックを要求しているスレッドを「要求者」、いずれかのロックを要求して認められ、そのロックが実行されている状態を、ロックを「取得している」と称し、ロックを取得しているスレッドを「取得者」と称する。   Also, in the following explanation, the thread requesting the lock is called “requester”, and the state where the lock is recognized and requested is called “acquiring”. The thread that acquires the lock is referred to as “acquirer”.

(第1の実施形態)
[構成]
図1は、第1の実施形態に係るデータベース管理装置1の機能構成と使用環境の一例を示す図である。データベース管理装置1は、複数のクライアントCL−A、CL−B、…からのアクセス要求を受け付ける。以下、いずれのクライアントであるかを区別しないときは、単にクライアントCLと称する。クライアントCLは、データベース管理装置1と通信する他のコンピュータ装置であってもよいし、データベース管理装置1内の仮想的な処理主体であってもよい。前者の場合、クライアントCLとデータベース管理装置1とは、WAN(Wide Area Network)やLAN(Local Area Network)、インターネット、専用回線などの通信網を介して通信する。
(First embodiment)
[Constitution]
FIG. 1 is a diagram illustrating an example of a functional configuration and usage environment of a database management apparatus 1 according to the first embodiment. The database management apparatus 1 accepts access requests from a plurality of clients CL-A, CL-B,. Hereinafter, when the client is not distinguished, it is simply referred to as a client CL. The client CL may be another computer device that communicates with the database management device 1 or may be a virtual processing entity in the database management device 1. In the former case, the client CL and the database management apparatus 1 communicate via a communication network such as a WAN (Wide Area Network), a LAN (Local Area Network), the Internet, or a dedicated line.

アクセス要求とは、共有ストレージ100にデータを書き込んだり、共有ストレージ100からデータを読み出したりする要求である。共有ストレージ100は、HDD(Hard Disk Drive)などのディスク装置やフラッシュメモリ、その他の記憶装置、或いは複数の記憶装置が組み合わされたハイブリッド型記憶装置である。   The access request is a request for writing data to the shared storage 100 or reading data from the shared storage 100. The shared storage 100 is a disk device such as an HDD (Hard Disk Drive), a flash memory, another storage device, or a hybrid storage device in which a plurality of storage devices are combined.

データベース管理装置1は、クライアントCLごとにスレッド10−A、10−B、…を起動する。以下、スレッド10−AをスレッドA、スレッド10−BをスレッドB、…というように略記する場合がある。また、いずれのスレッドであるかを区別しないときは、スレッドを区別するハイフン以下の符号を省略する。スレッド10は、コマンド解析部12と、実行部14とを備える。また、各スレッド10は、自身が利用するメモリ領域をワーキングメモリ(後述)に確保している。   The database management device 1 activates the threads 10-A, 10-B,... For each client CL. Hereinafter, the thread 10-A may be abbreviated as thread A, the thread 10-B as thread B, and so on. In addition, when it is not distinguished which thread, the symbols below the hyphen that distinguish threads are omitted. The thread 10 includes a command analysis unit 12 and an execution unit 14. Each thread 10 secures a memory area used by itself in a working memory (described later).

コマンド解析部12は、対応するクライアントCLから受信したコマンドの内容を解析し、実行部14に提供する。コマンドは、SQLなどの形式で記述されている。なお、コマンド解析部12は、スレッド10に含まれるのではなく、各スレッド10に対して解析結果を分配するものであってもよい。   The command analysis unit 12 analyzes the content of the command received from the corresponding client CL, and provides it to the execution unit 14. The command is described in a format such as SQL. The command analysis unit 12 may not be included in the thread 10 but may distribute the analysis result to each thread 10.

実行部14は、対応するクライアントから取得され、コマンド解析部12によって内容が解析されたコマンドに従って、共有ストレージ100に対する処理を実行する。実行部14は、共有ストレージ100に書き込み処理を行う前に、レコードロックまたはテーブルロックを実行する。   The execution unit 14 executes processing for the shared storage 100 according to the command acquired from the corresponding client and analyzed by the command analysis unit 12. The execution unit 14 executes record lock or table lock before performing write processing on the shared storage 100.

図2は、データベース管理装置1による共有ストレージ100の管理区分を示す図である。図示するように、書き込みの単位となるレコードの集まりがページである。ページは、コミットの対象となる単位である。コミットについては後述する。また、ページの集まりがテーブルである。   FIG. 2 is a diagram showing management divisions of the shared storage 100 by the database management apparatus 1. As shown in the figure, a collection of records as a unit of writing is a page. A page is a unit to be committed. The commit will be described later. A collection of pages is a table.

実行部14によるロックの要求(以下、ロック要求)は、マスター管理部20のロック制御部22に出力される。ロック制御部22は、要求者であるスレッド10の実行部14から入力されたロック要求に基づいてロック表24を管理する。   A lock request (hereinafter referred to as a lock request) by the execution unit 14 is output to the lock control unit 22 of the master management unit 20. The lock control unit 22 manages the lock table 24 based on the lock request input from the execution unit 14 of the thread 10 that is the requester.

図3は、ロック表24の内容の一例を示す図である。ロック表24は、例えば、テーブルと、テーブルロックのモードおよび取得者の識別情報、並びに、各テーブルに含まれるレコードと、レコードロックの取得者の識別情報が互いに対応付けられた表である。テーブルロックのモードが異なると、テーブルロックの効力が異なる。   FIG. 3 is a diagram illustrating an example of the contents of the lock table 24. The lock table 24 is a table in which, for example, a table, table lock mode and acquirer identification information, and records included in each table and record lock acquirer identification information are associated with each other. Different table lock modes have different table lock effectiveness.

本実施形態において、テーブルロックのモードは、少なくとも「協調モード」を含む。協調モードとはテーブルロックの取得者以外のスレッド10による、当該テーブル内のレコードに対する書き込みに備えた処理を、制限付きで許容するモードである。また、協調モードにおいて、テーブルロックの取得者以外のスレッド10による、当該テーブル内のレコードからの読み出しは許可されてよい。詳しくは、後述する。   In the present embodiment, the table lock mode includes at least a “cooperative mode”. The cooperative mode is a mode in which a process for writing to a record in the table by a thread 10 other than the person who acquires the table lock is allowed with a restriction. Further, in the cooperative mode, reading from the record in the table by the thread 10 other than the table lock acquirer may be permitted. Details will be described later.

また、テーブルロックのモードは、図示するように「排他モード」を含んでもよい。排他モードとは、テーブルロックの取得者以外のスレッド10による、当該テーブル内のレコードに対する書き込みと読み出しの双方を禁止するモードである。また、テーブルロックのモードは、「共有モード」を含んでもよい。共有モードとは、テーブルロックの取得者以外のスレッド10による、当該テーブル内のレコードに対する書き込みを禁止すると共に読み出しを許可するモードである。図4は、テーブルロックに関する3つのモードの効力を示す図である。   Further, the table lock mode may include an “exclusive mode” as illustrated. The exclusive mode is a mode that prohibits both writing and reading of records in the table by a thread 10 other than the table lock acquirer. The table lock mode may include a “shared mode”. The sharing mode is a mode in which writing by the thread 10 other than the table lock acquirer to the record in the table is prohibited and reading is permitted. FIG. 4 is a diagram showing the effectiveness of the three modes related to table lock.

図5は、データベース管理装置1のハードウェア構成の一例を示す図である。ここでは、図1とは異なる符号を用いて説明する。データベース管理装置1は、例えば、クライアントインターフェース50と、マルチコアプロセッサ60と、ストレージインターフェース70と、プログラムメモリ80と、ワーキングメモリ90とを備える。なお、マルチコアプロセッサを備える例はあくまで一例であり、処理主体となるプロセッサを複数備えるものであれば好適に使用することができる。   FIG. 5 is a diagram illustrating an example of a hardware configuration of the database management apparatus 1. Here, description will be made using reference numerals different from those in FIG. The database management apparatus 1 includes, for example, a client interface 50, a multi-core processor 60, a storage interface 70, a program memory 80, and a working memory 90. In addition, the example provided with a multi-core processor is an example to the last, and if it is provided with a plurality of processors as a processing subject, it can be suitably used.

クライアントインターフェース50は、例えば、NIC(Network Interface Card)などのネットワークインターフェースを含む。   The client interface 50 includes a network interface such as a NIC (Network Interface Card).

マルチコアプロセッサ60は、n個のプロセッサコア62(1)〜62(n)を備える。プロセッサコア62(1)は、プログラムメモリ80に格納されたスレッド管理用プログラム82を実行し、スレッドの実行状況を管理するマスターコアとして機能する。マスターコアは、ワーキングメモリ90におけるスレッド定義ファイル92によって、クライアントCLとスレッド10との関係を管理する。また、マスターコアは、図1におけるマスター管理部20に相当する。なお、スレッドの実行状況を管理する機能と、ロックを管理する機能は、別々のプロセッサコア62によって実現されてもよい。   The multi-core processor 60 includes n processor cores 62 (1) to 62 (n). The processor core 62 (1) functions as a master core that executes the thread management program 82 stored in the program memory 80 and manages the execution status of the threads. The master core manages the relationship between the client CL and the thread 10 by the thread definition file 92 in the working memory 90. The master core corresponds to the master management unit 20 in FIG. It should be noted that the function for managing the execution status of the thread and the function for managing the lock may be realized by separate processor cores 62.

プロセッサコア62(2)〜62(n)は、プログラムメモリ80に格納されたスレッド実行用プログラム84を実行することで、スレーブコアとして機能する。スレーブコアのそれぞれには、ワーキングメモリ90においてスレッド毎領域(スレーブコア毎領域)96(2)〜96(n)が割り当てられている。スレッド毎領域96(2)〜96(n)には、それぞれ、差分管理情報98が格納される。   The processor cores 62 (2) to 62 (n) function as slave cores by executing the thread execution program 84 stored in the program memory 80. Each of the slave cores is assigned to each thread area (slave core area) 96 (2) to 96 (n) in the working memory 90. Difference management information 98 is stored in each thread area 96 (2) to 96 (n).

プログラムメモリ80は、例えば、ROM(Read Only Memory)やHDD、フラッシュメモリなどの不揮発性メモリによって実現される。また、ワーキングメモリ90は、例えば、RAM(Random Access Memory)やHDD、フラッシュメモリ、レジスタなどの読み書き可能なメモリによって実現される。プログラムメモリ80とワーキングメモリ90の境界は明確である必要はなく、これらは、例えばフラッシュメモリにおける異なる領域を指すものであってもよい。   The program memory 80 is realized by, for example, a non-volatile memory such as a ROM (Read Only Memory), an HDD, or a flash memory. The working memory 90 is realized by a readable / writable memory such as a RAM (Random Access Memory), an HDD, a flash memory, or a register. The boundary between the program memory 80 and the working memory 90 need not be clear, and they may refer to different areas in the flash memory, for example.

このような構成によって、データベース管理装置1は、複数のスレッド10を、互いに非同期に独立して動作させることができる。このことの利点については後述する。   With such a configuration, the database management apparatus 1 can operate the plurality of threads 10 independently and asynchronously with each other. The advantage of this will be described later.

[動作]
以下、データベース管理装置1のロック制御を中心とした動作について説明する。まずはテーブルロックの利点について説明する。図6は、テーブルロックの利点について説明するための図である。図6の左図はレコードロックを行う場合の動作を示し、右図は、テーブルロックを行う場合の動作を示す。また、図中、上から順に、更新処理中、コミット中、コミット後と処理の段階を示している。これらの順に時間が流れるものとする。図6では、スレッド10が、共有ストレージ100における、あるページのレコード[002]に変更データ1、2を書き込む場合を示している。
[Operation]
Hereinafter, the operation centering on the lock control of the database management apparatus 1 will be described. First, the advantages of table lock will be described. FIG. 6 is a diagram for explaining the advantages of the table lock. The left diagram in FIG. 6 shows the operation when the record lock is performed, and the right diagram shows the operation when the table lock is performed. Also, in the drawing, the stages of update processing, committing, and post-commitment are shown in order from the top. It is assumed that time flows in this order. FIG. 6 shows a case where the thread 10 writes the change data 1 and 2 to the record [002] of a certain page in the shared storage 100.

レコードロックを行う場合、まず、スレッド10の実行部14は、差分管理情報98として変更データ1および2をワーキングメモリ90に格納し、自身がコミットを行うまで待機する。そして、実行部14は、コミットの実行と共に、差分管理情報98として格納しておいた変更データ1および2を共有ストレージ100に書き込む。変更データは、レコードの一部のみ変更する場合は、変更しようとするデータを既存のデータとを統合したデータである。また、変更データは、レコードの全部を変更する場合は、変更しようとするデータそのものであってよい。   When performing the record lock, first, the execution unit 14 of the thread 10 stores the change data 1 and 2 in the working memory 90 as the difference management information 98 and waits until it commits itself. Then, the execution unit 14 writes the change data 1 and 2 stored as the difference management information 98 to the shared storage 100 together with the execution of the commit. The change data is data obtained by integrating data to be changed with existing data when only a part of the record is changed. The change data may be the data itself to be changed when changing the whole record.

レコードロックを行う場合において、実行部14が直接的に共有ストレージ100に書き込まない理由は、もし直接的に共有ストレージ100に書き込む場合、書き込み中に、書き込み対象のレコードが含まれる同じページに対して、他のスレッドがコミットを行ってしまう可能性があるからである。この場合、(共有モードであれば)書き込み途中のデータが他のスレッド10によって(すなわち書き込み主体と異なるクライアントCLによって)読み出される可能性がある。   The reason why the execution unit 14 does not directly write to the shared storage 100 when performing record locking is that, if writing directly to the shared storage 100, during the writing, the same page including the record to be written is included. This is because other threads may commit. In this case, there is a possibility that the data being written (in the shared mode) may be read by another thread 10 (that is, by a client CL different from the writing subject).

この現象が起きると、特にトランザクション処理を実行する場合に不都合が生じる。トランザクション処理とは、複数の命令を含み、それら複数の命令の全てが実行し終えた状態で公開されること(処理の一貫性)が要求される処理である。例えば、銀行における処理を考えると、ユーザAの口座から出金があり、ユーザBの口座に入金される場合、いずれか一方のみが、共有ストレージに格納されるのは回避しなければならない。例えば、図6の例では、ユーザAの出金に係るデータが変更データ1、ユーザBの入金に係るデータが変更データ2に該当する。処理の一貫性が守られない場合、ユーザAから出金があり、ユーザBには入金されていない状態のデータが参照されてしまう可能性がある。このような不都合を避けるため、レコードロックを行う場合には、直ちに共有ストレージ100に書き込まず、差分管理情報98として格納しておいたデータをコミットの実行に合わせて共有ストレージ100に書き込むという処理が行われる。   When this phenomenon occurs, inconvenience occurs particularly when executing transaction processing. The transaction process is a process that includes a plurality of instructions and requires that all of the plurality of instructions have been executed (process consistency). For example, when considering processing in a bank, when there is a withdrawal from the account of user A and the deposit is made to the account of user B, it must be avoided that only one of them is stored in the shared storage. For example, in the example of FIG. 6, the data related to the withdrawal of the user A corresponds to the change data 1, and the data related to the payment of the user B corresponds to the change data 2. If the consistency of processing is not maintained, there is a possibility that user A will withdraw money and user B may refer to data that has not been deposited. In order to avoid such inconvenience, when record locking is performed, there is a process in which data stored as the difference management information 98 is not immediately written to the shared storage 100 but is written to the shared storage 100 in accordance with the execution of the commit. Done.

これに対し、テーブルロックを行う場合、ページよりも大きい単位であるテーブル単位でロックが行われるため、上記のような現象が起きる心配は無い。このため、図6の右図に示すように、変更データをそのまま共有ストレージ100に書き込むことができる。また、テーブルロックには、ロック表24の管理を簡易に行うことができるという利点も存在する。   On the other hand, when table locking is performed, locking is performed on a table basis, which is a unit larger than a page, so there is no concern that the above phenomenon will occur. For this reason, as shown in the right diagram of FIG. 6, the changed data can be written in the shared storage 100 as it is. The table lock also has an advantage that the lock table 24 can be easily managed.

しかしながら、テーブルロックを多用すると、複数ページに亘って他のスレッド10による書き込みを排除するため、応答性が悪くなるという弊害が生じ得る。図7は、共有モードまたは排他モードによってテーブルロックがなされた場面を示す図である。本図では、スレッドAによってロックが取得され、ロック中に、スレッドB、C、Dに対してそれぞれのクライアントから書き込みコマンドが送信された。この場合、スレッドB、C、Dは、スレッドAによるロック解放を待ってから差分管理情報98を生成し、更に、同一ページへの書き込みであれば、他のスレッドの共有ストレージ100への書き込みが終了するのを待って書き込みを行わなければならない。   However, if the table lock is frequently used, writing by other threads 10 over a plurality of pages is excluded, so that the responsiveness may be adversely affected. FIG. 7 is a diagram illustrating a scene in which the table lock is performed in the shared mode or the exclusive mode. In this figure, the lock is acquired by the thread A, and a write command is transmitted from each client to the threads B, C, and D during the lock. In this case, the threads B, C, and D generate the difference management information 98 after waiting for the lock to be released by the thread A. Furthermore, if writing to the same page, writing to the shared storage 100 of other threads is possible. You must wait for it to finish before writing.

これに対し、協調モードのテーブルロックでは、テーブルロックの取得者以外のスレッド10による、テーブルロック中に当該テーブル内のレコードにして差分管理情報98を生成する処理が許容され、更に、所定条件を満たす場合に、テーブルロック中に生成した差分管理情報98を、共有ストレージ100に反映させることが許容される。所定条件については後述する。   On the other hand, in the table lock in the cooperative mode, the process of generating the difference management information 98 as a record in the table during the table lock by the thread 10 other than the table lock acquirer is allowed. When it is satisfied, the difference management information 98 generated during the table lock is allowed to be reflected in the shared storage 100. The predetermined condition will be described later.

図8は、協調モードによってテーブルロックがなされた場面を示す図である。図示するように、協調モードにおいて、テーブルロックの取得者でないスレッドB、C、Dは、テーブルロック中であっても任意のタイミングで差分管理情報を生成することができる。この結果、図7に示す場面に比して、全体的な処理時間を短くすることができ、応答性を向上させることができる。   FIG. 8 is a diagram illustrating a scene where the table lock is performed in the cooperative mode. As shown in the figure, in the cooperative mode, threads B, C, and D that are not the table lock acquirer can generate the difference management information at an arbitrary timing even during the table lock. As a result, compared with the scene shown in FIG. 7, the overall processing time can be shortened, and the responsiveness can be improved.

協調モードにおいて、レコード単位でデータを書き込もうとするスレッド10は、レコードロック要求をロック制御部22に出力する。ロック制御部22は、テーブルロックの状況と、レコードロックの状況とをロック表24に書き込む。なお、共有モードや排他モードでテーブルロックが取得された場合、そのテーブル内のレコードに対するロック要求は、ロック制御部22により棄却される。   In the cooperative mode, the thread 10 attempting to write data in record units outputs a record lock request to the lock control unit 22. The lock control unit 22 writes the table lock status and the record lock status in the lock table 24. When a table lock is acquired in the shared mode or the exclusive mode, the lock control unit 22 rejects a lock request for a record in the table.

ここで、前述した「所定条件」について説明する。以下では、所定条件が判定されるスレッド10を、対象スレッド10#と称する。所定条件には、テーブルロックの取得者であるスレッド10の実行部14(第1実行部)により、テーブルロックの解放までに、対象スレッド10#の実行部14(第2実行部)がデータを書き込もうとしているレコードに対して、レコードロックがなされなかったことが含まれる。   Here, the above-mentioned “predetermined condition” will be described. Hereinafter, the thread 10 for which the predetermined condition is determined is referred to as a target thread 10 #. The predetermined condition is that the execution unit 14 (second execution unit) of the target thread 10 # receives data before the table lock is released by the execution unit 14 (first execution unit) of the thread 10 that is the table lock acquirer. This includes the fact that no record lock was made for the record to be written.

また、所定条件には、対象スレッド10#の実行部14がデータを書き込もうとしているレコードに対して、対象スレッド10#よりも前に、他のスレッド10によるレコードロックがなされなかったことが含まれてもよい。すなわち、テーブルロックの取得者以外のスレッド10の間では、先着順にレコードロックを取得可能であることが、所定条件によって規定されてもよい。   In addition, the predetermined condition includes that the record to be written by the execution unit 14 of the target thread 10 # is not locked by another thread 10 before the target thread 10 #. May be. That is, it may be defined by a predetermined condition that the record lock can be acquired in the first-come-first-served basis among the threads 10 other than the table lock acquirer.

所定条件は、例えば、ロック制御部22により判定され、これに基づく制御が行われる。図9は、ロック制御部22により実行される処理の流れの一例を示す図である。本フローチャートの処理は、いずれかのスレッド10の実行部14からのロック要求を、ロック制御部22が受け付けたときに開始される。また、以下のフローチャートにおいて、ロックの要求が棄却され、またはロックが実行された場合、ロック制御部22から要求者に対して結果が通知されるものとする。   The predetermined condition is determined by, for example, the lock control unit 22, and control based on this is performed. FIG. 9 is a diagram illustrating an example of a flow of processing executed by the lock control unit 22. The process of this flowchart is started when the lock control unit 22 receives a lock request from the execution unit 14 of any thread 10. In the following flowchart, when the lock request is rejected or the lock is executed, the lock control unit 22 notifies the requester of the result.

まず、ロック制御部22は、ロック対象がテーブルであるか、レコードであるかを判定する(ステップS100)。ロック対象がテーブルである場合、ロック制御部22は、要求者以外のスレッドによるテーブルロック、または対象テーブルに含まれるレコードのロックが取得済であるか否かを判定する(ステップS102)。   First, the lock control unit 22 determines whether the lock target is a table or a record (step S100). When the lock target is a table, the lock control unit 22 determines whether a table lock by a thread other than the requester or a lock of a record included in the target table has been acquired (step S102).

要求者以外のスレッドによるテーブルロック、または対象テーブルに含まれるレコードのロックが取得済である場合、ロック制御部22は、テーブルロックの要求を棄却する(ステップS104)。このように、本実施形態では、テーブルロックの対象テーブルまたは対象テーブルに含まれるレコードに対して既にロックが取得されている場合には、テーブルロックの要求が棄却される。   When the table lock by the thread other than the requester or the lock of the record included in the target table has been acquired, the lock control unit 22 rejects the table lock request (step S104). As described above, in the present embodiment, when a lock has already been acquired for a target table of a table lock or a record included in the target table, the table lock request is rejected.

要求者以外のスレッドによるテーブルロック、または対象テーブルに含まれるレコードのロックが取得済でない場合、ロック制御部22は、要求者によるテーブルロックを実行する(ステップS106)。この場合、ロック制御部22は、ロック表24における対象テーブルの項目に、テーブルロックのモード、および取得者の識別情報を書き込む。テーブルロックのモードとして、データベース管理装置1全体について現在のモードが設定されてもよいし、テーブルロックの要求者によって要求の度にモードが指定されてもよい。   If the table lock by the thread other than the requester or the lock of the record included in the target table has not been acquired, the lock control unit 22 executes the table lock by the requester (step S106). In this case, the lock control unit 22 writes the table lock mode and the identification information of the acquirer in the items of the target table in the lock table 24. As the table lock mode, the current mode may be set for the entire database management apparatus 1, or the mode may be designated for each request by the table lock requester.

一方、ロック対象がレコードである場合、ロック制御部22は、要求者が、対象レコードが含まれるテーブルに対してテーブルロックを取得済であるか否かを判定する(ステップS108)。要求者がテーブルロックを取得済である場合、ロック制御部22は、レコードロックの対象レコードについて、要求者以外のスレッド10によるレコードロックが取得済であるか否かを判定する(ステップS110)。   On the other hand, when the lock target is a record, the lock control unit 22 determines whether or not the requester has acquired a table lock for the table including the target record (step S108). When the requester has acquired the table lock, the lock control unit 22 determines whether or not the record lock by the thread 10 other than the requester has been acquired for the record lock target record (step S110).

要求者以外のスレッド10によるレコードロックが取得済である場合、ロック制御部22は、元々ロック表24に登録されていたスレッド10に対して競合通知を発行し、ロック表24における対象レコードの項目を、要求者の識別情報で上書きする(ステップS112)。これによって、テーブルロックの取得者であるスレッド10が、元々レコードロックを取得していた他のスレッド10から、レコードロックの権利を奪うことになる。要求者以外のスレッド10によるレコードロックが取得済でない場合、ロック制御部22は、要求者によるレコードロックを実行する(ステップS114)。なお、ステップS114に至るのは、テーブルロックの取得者により、テーブルロックの対象テーブルに含まれるレコードに対してのロック要求がなされた場合であり、取得されたテーブルロックのモードが協調モードである場合に限られる。   When the record lock by the thread 10 other than the requester has been acquired, the lock control unit 22 issues a conflict notification to the thread 10 originally registered in the lock table 24, and the item of the target record in the lock table 24 Is overwritten with the identification information of the requester (step S112). As a result, the thread 10 that is the table lock acquirer deprives the record lock right from the other thread 10 that originally acquired the record lock. When the record lock by the thread 10 other than the requester has not been acquired, the lock control unit 22 executes the record lock by the requester (step S114). Note that step S114 is reached when the table lock acquirer makes a lock request for a record included in the table lock target table, and the acquired table lock mode is the cooperative mode. Limited to cases.

ステップS108において、要求者が、対象レコードが含まれるテーブルに対してテーブルロックを取得済でないと判定された場合、ロック制御部22は、対象レコードの属するテーブルについてテーブルロックが取得済であるか否かを判定する(ステップS116)。対象レコードの属するテーブルについてテーブルロックが取得済である場合、ロック制御部22は、協調モードでテーブルロックが取得されているか否かを判定する(ステップS118)。協調モードでテーブルロックが取得されていない場合、ロック制御部22は、レコードロックの要求を棄却する(ステップS122)。   If it is determined in step S108 that the requester has not acquired a table lock for the table including the target record, the lock control unit 22 determines whether a table lock has been acquired for the table to which the target record belongs. Is determined (step S116). When the table lock has been acquired for the table to which the target record belongs, the lock control unit 22 determines whether or not the table lock has been acquired in the cooperative mode (step S118). When the table lock is not acquired in the cooperative mode, the lock control unit 22 rejects the record lock request (step S122).

ステップS116において否定的な判定を得た場合、またはステップS118において肯定的な判定を得た場合、ロック制御部22は、対象レコードについて要求者以外によりレコードロックが取得済であるか否かを判定する(ステップS120)。ロック制御部22は、要求者以外によりレコードロックが取得済である場合、レコードロックの要求を棄却し(ステップS122)、要求者以外によりレコードロックが取得済でない場合、要求者によるレコードロックを実行する(ステップS124)。このとき、ロック制御部22は、レコードロックを行った対象レコードの属するテーブルについてのテーブルロック状況を要求者に通知する。   When a negative determination is obtained in step S116, or when a positive determination is obtained in step S118, the lock control unit 22 determines whether or not a record lock has been acquired for the target record by a person other than the requester. (Step S120). The lock control unit 22 rejects the record lock request when the record lock has been acquired by a party other than the requester (step S122), and executes the record lock by the requester when the record lock has not been acquired by a party other than the requester. (Step S124). At this time, the lock control unit 22 notifies the requester of the table lock status for the table to which the target record to which the record lock is performed belongs.

なお、ロック制御部22が一元的に図9に示す処理を行う態様は、あくまで一例であり、各スレッド10がそれぞれロック表24を参照して独自で判断を行い、結果として図9に示す処理と同等の処理を実現してもよい。   The manner in which the lock control unit 22 performs the processing shown in FIG. 9 in an integrated manner is merely an example, and each thread 10 makes its own determination with reference to the lock table 24, and as a result, the processing shown in FIG. You may implement | achieve the process equivalent to.

図10は、各スレッド10により実行される処理の流れの一例を示すフローチャートである。本フローチャートの処理は、例えば、スレッド10が共有ストレージ100への書き込みを行おうとし、ロック要求を発行したときに開始される。従って、図9に示す処理と、図10に示す処理は、スレッド10とロック制御部22により並行して実行される。   FIG. 10 is a flowchart illustrating an example of the flow of processing executed by each thread 10. The process of this flowchart is started when, for example, the thread 10 tries to write to the shared storage 100 and issues a lock request. Therefore, the process shown in FIG. 9 and the process shown in FIG. 10 are executed in parallel by the thread 10 and the lock control unit 22.

まず、スレッド10は、ロックの対象レコードが属するテーブル、またはロックの対象テーブルのロック状況をロック制御部22から取得する(ステップS200)。   First, the thread 10 acquires the table to which the lock target record belongs, or the lock status of the lock target table from the lock control unit 22 (step S200).

次に、スレッド10は、自身がテーブルロック中であるか否かを判定する(ステップS202)。自身がテーブルロック中である場合、スレッド10は、書き込みデータを共有ストレージ100に反映させ、コミットを行う(ステップS204)。   Next, the thread 10 determines whether or not itself is in the table lock (step S202). If the table itself is locked, the thread 10 reflects the write data in the shared storage 100 and commits (step S204).

自身がテーブルロック中でない場合、スレッド10は、自身がレコードロック中であるか否かを判定する(ステップS206)。自身がレコードロック中である場合、スレッド10は、差分管理情報を生成する(ステップS208)。次に、スレッド10は、他のスレッド10により協調モードでテーブルロックが取得され、解放待ち状態であるか否かを判定する(ステップS210)。   If the table 10 is not locked, the thread 10 determines whether or not the record 10 is locked (step S206). If the thread itself is in record lock, the thread 10 generates difference management information (step S208). Next, the thread 10 determines whether or not a table lock is acquired in the cooperative mode by another thread 10 and is in a release waiting state (step S210).

ステップS210で否定的な判定を得た場合、スレッド10は、生成しておいた差分管理情報を共有ストレージ100に反映させ、コミットを行う(ステップS212)。一方、ステップS210で肯定的な判定を得た場合、スレッド10は、テーブルロックの解放を待って(ステップS214)、生成しておいた差分管理情報を共有ストレージ100に反映させる(ステップS212)。なお、テーブルロックが解放されるまでに、競合通知を受け取った場合(ステップS216)、スレッド10は、差分管理情報を破棄し(ステップS218)、本フローチャートの処理を終了する。また、協調モードで解放待ちを行う時間(或いは、クロック数、サイクル数など)に上限を設け、上限に達したときにステップS218に進むようにしてもよい。   When a negative determination is obtained in step S210, the thread 10 reflects the generated difference management information in the shared storage 100 and commits (step S212). On the other hand, when a positive determination is obtained in step S210, the thread 10 waits for the table lock to be released (step S214), and reflects the generated difference management information in the shared storage 100 (step S212). If a conflict notification is received before the table lock is released (step S216), the thread 10 discards the difference management information (step S218), and ends the processing of this flowchart. Further, an upper limit may be set for the time for waiting for release in the cooperative mode (or the number of clocks, the number of cycles, etc.), and the process may proceed to step S218 when the upper limit is reached.

ステップS206で、自身がロック中でないと判定した場合、すなわち、他のスレッド10によってテーブルロック(強調モードでないもの)またはレコードロックが取得されている場合、スレッド10は、本フローチャートの処理を終了する。ステップS218で差分管理情報を破棄した場合、および、ステップS206で自身がロック中でないと判定した場合、スレッド10は、クライアントCLにエラー応答を返し、再度、書き込みコマンドを受信するまで待機する。   If it is determined in step S206 that the thread itself is not locked, that is, if a table lock (non-emphasis mode) or a record lock has been acquired by another thread 10, the thread 10 ends the processing of this flowchart. . When the difference management information is discarded in step S218 and when it is determined in step S206 that the difference management information is not locked, the thread 10 returns an error response to the client CL and waits again until a write command is received.

以下、図9および図10に示すフローチャートの処理が行われる結果として生じる場面について説明する。図11は、レコードロックの要求者がテーブルロックの取得者ではなく、且つレコードロックの対象レコードについてロックが取得されていない場合におけるロック表24の推移などを示す図である。   Hereinafter, scenes that occur as a result of the processing of the flowcharts shown in FIGS. 9 and 10 will be described. FIG. 11 is a diagram illustrating the transition of the lock table 24 when the requester of the record lock is not the acquirer of the table lock and the lock is not acquired for the record lock target record.

図示するように、まず、スレッドAによって協調モードでテーブルロックが取得される。スレッドAは、例えば、更にレコード[001]に対してレコードロックを取得してから書き込みを開始する。このとき、スレッドAはテーブルロックを取得しているため、共有ストレージ100に直接、書き込みデータを反映させる。   As shown in the figure, first, a table lock is acquired by the thread A in the cooperative mode. For example, the thread A further acquires a record lock for the record [001] and then starts writing. At this time, since the thread A has acquired the table lock, the write data is directly reflected in the shared storage 100.

スレッドAによりテーブルロックが取得されている間にスレッドBによってレコード[002]に対してレコードロックが取得される。スレッドBは、差分管理情報を生成し、テーブルロックの解放を待って差分管理情報を共有ストレージ100に反映させる。   While the table lock is acquired by the thread A, the record lock is acquired for the record [002] by the thread B. The thread B generates difference management information, waits for the release of the table lock, and reflects the difference management information in the shared storage 100.

図12は、レコードロックの要求者がテーブルロックの取得者ではなく、且つレコードロックの対象レコードについてロックが取得されている場合におけるロック表24の推移などを示す図である。   FIG. 12 is a diagram showing the transition of the lock table 24 when the requester of the record lock is not the acquirer of the table lock and the lock is acquired for the record lock target record.

この場合において、スレッドAによりテーブルロックが取得されている間にスレッドCによってレコード[002]に対してレコードロックが取得される。その後、スレッドBによりレコード[002]に対してロック要求がなされるが、既にスレッドCによりレコードロックが取得されているため、棄却される。スレッドCは、自身がレコードロックを取得した後、差分管理情報を生成し、テーブルロックの解放を待って差分管理情報を共有ストレージ100に反映させる。   In this case, while the table lock is acquired by the thread A, the record lock is acquired for the record [002] by the thread C. Thereafter, a lock request is made to the record [002] by the thread B, but is rejected because the record lock has already been acquired by the thread C. After the thread C acquires the record lock, the thread C generates difference management information, waits for the release of the table lock, and reflects the difference management information in the shared storage 100.

図13は、レコードロックの要求者がテーブルロックの取得者ではなく、且つレコードロックの対象レコードについてロックが取得できたが、テーブルロックの解放までの間に、テーブルロックの取得者によって対象レコードについてレコードロックが要求された場合におけるロック表24の推移などを示す図である。   FIG. 13 shows that the requester of the record lock is not the acquirer of the table lock and the lock can be acquired for the target record of the record lock, but the target record is acquired by the acquirer of the table lock until the release of the table lock. It is a figure which shows transition etc. of the lock table 24 when a record lock is requested | required.

この場合において、スレッドAによりテーブルロックが取得されている間にスレッドBによってレコード[002]に対してレコードロックが取得される。スレッドBは、差分管理情報を生成し始めるが、テーブルロックの解放までに、テーブルロックの取得者であるスレッドAにより、同じレコード[002]に対してロック要求がなされた。この場合、スレッドAが入れ替わりにレコード[002]の取得者となり、スレッドBの差分管理情報は破棄される。   In this case, while the table lock is acquired by the thread A, the record lock is acquired for the record [002] by the thread B. The thread B starts to generate the difference management information, but before the table lock is released, the lock request is made to the same record [002] by the thread A who is the table lock acquirer. In this case, the thread A is replaced and becomes the acquirer of the record [002], and the difference management information of the thread B is discarded.

このように、第1の実施形態によれば、テーブルロックは、テーブルロックの取得者以外のスレッド10による、テーブルロックが行われたテーブルに含まれるレコードに対する書き込みに備えた処理を、制限付きで許容する協調モードで実行される。この結果、複数のクライアントCLからの書き込みが要求される場合における応答性を向上させることができる。   As described above, according to the first embodiment, the table lock is a limited process for preparing for writing to the record included in the table on which the table lock is performed by the thread 10 other than the table lock acquirer. It is executed in an allowed cooperative mode. As a result, it is possible to improve responsiveness when writing from a plurality of clients CL is requested.

第1の実施形態において、協調モードや排他モードの切替は、例えば、クライアントCLからの指示、或いはオペレータによる操作に基づいて切り替えられるようにすると、好適である。図14は、変形例に係るデータベース管理装置1Aの機能成と使用環境の一例を示す図である。図示するように、マスター管理部20は、モード選択部26を備える。モード選択部26は、クライアントCLからの指示、或いはオペレータによる操作に基づいて、テーブルロックのモードを、少なくとも協調モードと排他モードの間で切り替える。なお、テーブルロックのモードの切り替えについて、コマンドによらず一定のモードを維持することが指示されてもよいし、コマンドごとに指示されてもよい。なお、係る構成は、後述する第2の実施形態や第3の実施形態に適用されてもよい。   In the first embodiment, it is preferable that the cooperative mode and the exclusive mode are switched based on, for example, an instruction from the client CL or an operation by an operator. FIG. 14 is a diagram illustrating an example of the functional configuration and usage environment of the database management device 1A according to the modification. As illustrated, the master management unit 20 includes a mode selection unit 26. The mode selection unit 26 switches the table lock mode between at least the cooperative mode and the exclusive mode based on an instruction from the client CL or an operation by the operator. Regarding switching of the table lock mode, it may be instructed to maintain a constant mode regardless of the command, or may be instructed for each command. Such a configuration may be applied to a second embodiment or a third embodiment described later.

(第2の実施形態)
以下、第2の実施形態について説明する。図15は、第2の実施形態において使用されるロック表24Bの内容の一例を示す図である。第2の実施形態において、協調モードのテーブルロックは、同じ対象テーブルに対して複数のスレッド10が取得可能である。但し、テーブルロックには序列があり、序列の高いスレッド10が優先的に書き込みを行うことができる。図15では、これを第1テーブルロック、第2テーブルロック、…と表記した。第1テーブルロックの取得者は、他の全てのスレッド10に対して、第1の実施形態におけるテーブルロックの取得者と同じ効力を有する。第2テーブルロックの取得者は、第1テーブルロックの取得者以外のスレッド10に対して、第1の実施形態におけるテーブルロックの取得者と同じ効力を有する。第3テーブルロック以下についても同様であってよい。各テーブルロックは、先着順で取得される。また、協調モードであっても、対象テーブルに属するレコードについて既にレコードロックが取得されている場合には、いずれのテーブルロックも取得することができない。
(Second Embodiment)
Hereinafter, the second embodiment will be described. FIG. 15 is a diagram illustrating an example of the contents of the lock table 24B used in the second embodiment. In the second embodiment, the table lock in the cooperative mode can be acquired by a plurality of threads 10 for the same target table. However, the table lock has an order, and the thread 10 having the higher order can write preferentially. In FIG. 15, this is expressed as a first table lock, a second table lock,. The acquirer of the first table lock has the same effect as the acquirer of the table lock in the first embodiment for all other threads 10. The acquirer of the second table lock has the same effect as the acquirer of the table lock in the first embodiment for the thread 10 other than the acquirer of the first table lock. The same applies to the third table lock and below. Each table lock is acquired on a first-come-first-served basis. Even in the cooperative mode, if a record lock has already been acquired for a record belonging to the target table, no table lock can be acquired.

すなわち、第1テーブルロックの取得者は、他の全てのスレッド10に対して、レコードロックに関する優先度を有する。また、第2テーブルロックの取得者は、第1テーブルロックの取得者以外のスレッド10に対して、レコードロックに関する優先度を有する。   That is, the acquirer of the first table lock has a priority regarding the record lock with respect to all other threads 10. Further, the acquirer of the second table lock has a priority regarding the record lock with respect to the thread 10 other than the acquirer of the first table lock.

図16は、第2の実施形態におけるロック表24の推移などを示す図である。図示するように、まず、スレッドBによって協調モードで第1テーブルロックが取得される。スレッドBは、例えば、更にレコード[001]に対してレコードロックを取得してから書き込みを開始する。このとき、スレッドBはテーブルロックを取得しているため、共有ストレージ100に直接、書き込みデータを反映させる。続いて、スレッドAによって第2テーブルロックが取得される。   FIG. 16 is a diagram illustrating the transition of the lock table 24 in the second embodiment. As shown in the figure, first, the first table lock is acquired by the thread B in the cooperative mode. For example, the thread B further acquires a record lock for the record [001] and then starts writing. At this time, since the thread B has acquired the table lock, the write data is directly reflected in the shared storage 100. Subsequently, the second table lock is acquired by the thread A.

スレッドBにより第1テーブルロックが、スレッドAにより第2テーブルロックが取得されている間に、スレッドCによってレコード[002]に対してレコードロックが取得される。スレッドCは、差分管理情報を生成する。一方、第2テーブルロックの取得者であるスレッドAによりレコード[001]に対してロック要求がなされるが、既に第1テーブルロックの取得者であるスレッドBによりレコードロックが取得されているため、棄却される。   While the first table lock is acquired by the thread B and the second table lock is acquired by the thread A, the record lock is acquired for the record [002] by the thread C. The thread C generates difference management information. On the other hand, the thread A who is the acquirer of the second table lock makes a lock request for the record [001], but since the record lock has already been acquired by the thread B who is the acquirer of the first table lock, Rejected.

その後、第1テーブルロックの解放までに、第2テーブルロックの取得者であるスレッドAにより、スレッドCと同じレコード[002]に対してロック要求がなされた。この場合、スレッドAが入れ替わりにレコード[002]の取得者となり、スレッドCの差分管理情報は破棄される。スレッドAは、差分管理情報を生成し、第1テーブルロックの解放と共に差分管理情報を共有ストレージ100に反映させる。   Thereafter, the lock request for the same record [002] as the thread C is made by the thread A who is the acquirer of the second table lock until the first table lock is released. In this case, the thread A is replaced and becomes the acquirer of the record [002], and the difference management information of the thread C is discarded. The thread A generates difference management information, and reflects the difference management information in the shared storage 100 along with the release of the first table lock.

以上説明した第2の実施形態によれば、第1の実施形態と同様の効果を奏する他、特にテーブルのサイズが大きい場合に、多層的な管理を実現することができる。   According to the second embodiment described above, the same effects as those of the first embodiment can be obtained, and multilayer management can be realized particularly when the table size is large.

(第3の実施形態)
以下、第3の実施形態について説明する。図17は、第3の実施形態に係るデータベース管理装置1Cの機能構成と使用環境の一例を示す図である。図示するように、データベース管理装置1Cは、第1の実施形態と比較すると、差分集約部30を備える点と、それに関連する機能をスレッド10が有する点で相違する。
(Third embodiment)
Hereinafter, a third embodiment will be described. FIG. 17 is a diagram illustrating an example of a functional configuration and usage environment of a database management apparatus 1C according to the third embodiment. As illustrated, the database management device 1C is different from the first embodiment in that the thread 10 has a difference aggregation unit 30 and a function related thereto.

図18は、第3の実施形態に係るデータベース管理装置1Cの動作を模式的に示す図である。図示するように、第3の実施形態に係る各スレッド10は、差分管理情報を生成すると、生成した差分管理情報を差分集約部30にそれぞれ出力する。差分集約部30は、各スレッド10から入力された差分管理情報を集約し、例えば、格納するアドレス順に並べ替えた上で、テーブルロックが解放された時点で、まとめて共有ストレージ100に書き込む。   FIG. 18 is a diagram schematically illustrating the operation of the database management apparatus 1C according to the third embodiment. As illustrated, each thread 10 according to the third embodiment outputs the generated difference management information to the difference aggregating unit 30 when generating the difference management information. The difference aggregating unit 30 aggregates the difference management information input from each thread 10 and, for example, rearranges them in the order of stored addresses, and writes them together in the shared storage 100 when the table lock is released.

これによって、各スレッド10が独自に共有ストレージ100に書き込む場合に比して、効率的な処理を行うことができる。仮に、図5に示したストレージインターフェース70が一つのみ設けられる場合、各スレッド10の間でストレージインターフェース70を使用する順序を調停しなければならない。また、ストレージインターフェース70を複数設けると、コストの上昇となってしまう。これに対し、第3の実施形態に示す構成によれば、差分集約部30が、共有ストレージ100に書き込むべきデータを一元的に管理するため、上記の調停処理などが不要となり、またアドレスの参照順を効率の良い順序に決定することも可能であるため、効率的な処理を実現することができる。   As a result, it is possible to perform more efficient processing than when each thread 10 independently writes to the shared storage 100. If only one storage interface 70 shown in FIG. 5 is provided, the order in which the storage interfaces 70 are used among the threads 10 must be arbitrated. Further, if a plurality of storage interfaces 70 are provided, the cost increases. On the other hand, according to the configuration shown in the third embodiment, the difference aggregating unit 30 manages the data to be written to the shared storage 100 in an integrated manner, so that the above arbitration processing is not necessary, and address reference is performed. Since the order can be determined in an efficient order, efficient processing can be realized.

以上説明した第3の実施形態によれば、第1の実施形態と同様の効果を奏する他、効率的な共有ストレージ100への書き込み処理を行うことができる。   According to the third embodiment described above, the same effects as those of the first embodiment can be obtained, and efficient write processing to the shared storage 100 can be performed.

上記説明した各実施形態において、第1単位が「レコード」、小単位ロックが「レコードロック」、第2単位が「テーブル」、大単位ロックが「テーブルロック」であるものとして説明したが、これに限られない。第1単位と第2単位は、第1単位よりも第2単位の方が大きい関係を有する限り、「複数のレコードをまとめたレコード群」、「ページ」、「ページ群」、「ブロック」、「ブロック群」、「データベース全体」などの単位の中から任意に選択することができる。また、小単位ロックと大単位ロックは、任意に選択された第1単位と第2単位に対応するものであってよい。   In each of the embodiments described above, the first unit is “record”, the small unit lock is “record lock”, the second unit is “table”, and the large unit lock is “table lock”. Not limited to. As long as the first unit and the second unit have a relationship in which the second unit is larger than the first unit, “record group in which a plurality of records are collected”, “page”, “page group”, “block”, It can be arbitrarily selected from units such as “block group” and “whole database”. Further, the small unit lock and the large unit lock may correspond to arbitrarily selected first unit and second unit.

以上説明した少なくともひとつの実施形態によれば、テーブルロックは、テーブルロックの取得者以外のスレッド10による、テーブルロックが行われたテーブルに含まれるレコードに対する書き込みに備えた処理を、制限付きで許容する協調モードで実行される。この結果、複数のクライアントCLからの書き込みが要求される場合における応答性を向上させることができる。   According to at least one of the embodiments described above, the table lock allows the processing for preparing for writing to the record included in the table on which the table lock is performed, by the thread 10 other than the table lock acquirer, with limitation. It is executed in cooperative mode. As a result, it is possible to improve responsiveness when writing from a plurality of clients CL is requested.

本発明のいくつかの実施形態を説明したが、これらの実施形態は、例として提示したものであり、発明の範囲を限定することは意図していない。これら実施形態は、その他の様々な形態で実施されることが可能であり、発明の要旨を逸脱しない範囲で、種々の省略、置き換え、変更を行うことができる。これら実施形態やその変形は、発明の範囲や要旨に含まれると同様に、特許請求の範囲に記載された発明とその均等の範囲に含まれるものである。   Although several embodiments of the present invention have been described, these embodiments are presented by way of example and are not intended to limit the scope of the invention. These embodiments can be implemented in various other forms, and various omissions, replacements, and changes can be made without departing from the spirit of the invention. These embodiments and their modifications are included in the scope and gist of the invention, and are also included in the invention described in the claims and the equivalents thereof.

1…データベース管理装置、10…スレッド、12…コマンド解析部、14…実行部、20…マスター管理部、22…ロック制御部、24…ロック表、26…モード選択部、30…差分集約部、60…マルチコアプロセッサ、62…プロセッサコア、100…共有ストレージ DESCRIPTION OF SYMBOLS 1 ... Database management apparatus, 10 ... Thread, 12 ... Command analysis part, 14 ... Execution part, 20 ... Master management part, 22 ... Lock control part, 24 ... Lock table, 26 ... Mode selection part, 30 ... Difference aggregation part, 60 ... multi-core processor, 62 ... processor core, 100 ... shared storage

Claims (12)

複数のクライアントにそれぞれ対応して複数のデータベース管理部を起動させるように構成されるデータベース管理装置であって、
前記複数のデータベース管理部は、それぞれ、対応するクライアントから取得されるコマンドに従って、前記複数のデータベース管理部によって共有される共有ストレージに対する処理を実行する実行部を有し、
前記複数の実行部のそれぞれは、前記共有ストレージに書き込み処理を行う前に、前記共有ストレージの領域の一部を第1単位でロックする小単位ロック、または、前記共有ストレージの領域の一部または全部を前記第1単位より大きい第2単位でロックする大単位ロックを実行し、
前記大単位ロックは、前記大単位ロックを行った実行部以外の実行部による、前記大単位ロックが行われた領域に含まれる第1単位の領域に対する書き込みに備えた処理を、制限付きで許容する第1モードで実行される、
データベース管理装置。
A database management device configured to start a plurality of database management units corresponding to a plurality of clients,
Each of the plurality of database management units has an execution unit that executes processing for the shared storage shared by the plurality of database management units according to a command acquired from a corresponding client,
Each of the plurality of execution units includes a small unit lock that locks a part of the shared storage area in a first unit before performing a write process on the shared storage, or a part of the shared storage area or Performing a large unit lock that locks all in a second unit greater than the first unit;
The large-unit lock allows, with restriction, processing for preparing for writing to the first unit area included in the area where the large-unit lock is performed by an execution unit other than the execution unit that performed the large-unit lock. Executed in the first mode,
Database management device.
前記複数の実行部は、分散化されたハードウェア資源を用いて、互いに非同期に動作可能である、
請求項1記載のデータベース管理装置。
The plurality of execution units can operate asynchronously with each other using distributed hardware resources.
The database management apparatus according to claim 1.
前記複数の実行部のうち第1実行部により前記第1モードで前記大単位ロックが実行されている場合において、前記複数の実行部のうち前記第1実行部以外の第2実行部は、所定条件を満たす場合、前記第1単位での前記共有ストレージへの書き込みに備えた差分管理情報を生成してメモリに格納すると共に、前記第1モードでの大単位ロックが解放されたときに前記メモリに格納した前記差分管理情報を前記共有ストレージに反映させる、
請求項1または2記載のデータベース管理装置。
When the large unit lock is executed in the first mode by the first execution unit among the plurality of execution units, a second execution unit other than the first execution unit among the plurality of execution units is predetermined. If the condition is satisfied, difference management information for writing to the shared storage in the first unit is generated and stored in the memory, and when the large unit lock in the first mode is released, the memory Reflect the difference management information stored in the shared storage,
The database management apparatus according to claim 1 or 2.
前記複数の実行部のそれぞれは、前記大単位ロックを実行しているときに、前記大単位ロックの対象である前記第2単位に含まれる前記第1単位に対して前記小単位ロックを実行する場合があり、
前記所定条件は、前記第2実行部が書き込みを行おうとする第1単位に対して、前記第1実行部により小単位ロックが実行されなかったことを含む、
請求項3記載のデータベース管理装置。
Each of the plurality of execution units executes the small unit lock for the first unit included in the second unit that is a target of the large unit lock when the large unit lock is being executed. Sometimes
The predetermined condition includes that a small unit lock is not executed by the first execution unit with respect to a first unit to which the second execution unit attempts to write,
The database management apparatus according to claim 3.
前記所定条件は、前記第2実行部が書き込みを行おうとする第1単位に対して、他の第2実行部により、前記小単位ロックが先に実行されていないことを更に含む、
請求項3または4記載のデータベース管理装置。
The predetermined condition further includes that the small unit lock is not executed first by another second execution unit with respect to the first unit to which the second execution unit is to write.
The database management apparatus according to claim 3 or 4.
前記複数の実行部により生成された差分管理情報を集約し、前記第1モードでの大単位ロックが解放されたときに、前記集約した差分管理情報を、前記複数の実行部に代わって前記共有ストレージに反映させる差分集約部を更に備え、
前記複数の実行部は、生成した前記差分管理情報を、それぞれ前記差分集約部に出力する、
請求項3から5のうちいずれか1項記載のデータベース管理装置。
The difference management information generated by the plurality of execution units is aggregated, and when the large-unit lock in the first mode is released, the aggregated difference management information is shared on behalf of the plurality of execution units It further includes a difference aggregation unit to be reflected in the storage,
The plurality of execution units respectively output the generated difference management information to the difference aggregation unit.
The database management device according to any one of claims 3 to 5.
前記第1モードによる前記大単位ロックは、複数の実行部により、先着順に基づく優先度を伴って取得される、
請求項1から6のうちいずれか1項記載のデータベース管理装置。
The large unit lock according to the first mode is acquired by a plurality of execution units with a priority based on a first-come-first-served basis.
The database management apparatus according to any one of claims 1 to 6.
前記第1モードにおける前記大単位ロックは、対象とする第2単位の領域について、既に第1単位でのロックが取得されている場合、棄却される、
請求項1から7のうちいずれか1項記載のデータベース管理装置。
The large unit lock in the first mode is rejected when the lock in the first unit has already been acquired for the target second unit region,
The database management device according to claim 1.
前記大単位ロックのモードを、前記第1モードと他のモードとの間で切り替えるモード切替部を更に備える、
請求項1から8のうちいずれか1項記載のデータベース管理装置。
A mode switching unit for switching the mode of the large unit lock between the first mode and another mode;
The database management device according to claim 1.
前記第1単位よりも大きい第3単位でコミットが実行され、
前記共有ストレージにおける第3単位のデータは、コミットが実行されるまでは更新前の状態で読み出される、
請求項1から9のうちいずれか1項記載のデータベース管理装置。
A commit is executed in a third unit larger than the first unit;
The third unit of data in the shared storage is read in the state before update until a commit is executed.
The database management apparatus according to any one of claims 1 to 9.
データベース管理装置が、
複数のクライアントにそれぞれ対応して複数のデータベース管理部を起動させ、
前記複数のデータベース管理部は、それぞれ、対応するクライアントから取得されるコマンドに従って、前記複数のデータベース管理部によって共有される共有ストレージに対する処理を実行する実行部を備え、
前記複数の実行部のそれぞれが、前記共有ストレージに書き込み処理を行う前に、前記共有ストレージの領域の一部を第1単位でロックする小単位ロック、または、前記共有ストレージの領域の一部または全部を前記第1単位より大きい第2単位でロックする大単位ロックを実行し、
前記大単位ロックを、前記大単位ロックを行った実行部以外の実行部による、前記大単位ロックが行われた領域に含まれる第1単位の領域に対する書き込みに備えた処理を、制限付きで許容する第1モードで実行する、
データベース管理方法。
The database management device
Start multiple database managers corresponding to multiple clients,
Each of the plurality of database management units includes an execution unit that executes processing for the shared storage shared by the plurality of database management units according to a command acquired from a corresponding client.
Before each of the plurality of execution units performs a write process on the shared storage, a small unit lock that locks a part of the shared storage area in a first unit, or a part of the shared storage area or Performing a large unit lock that locks all in a second unit greater than the first unit;
Allowing the large-unit lock to be processed with a restriction by the execution unit other than the execution unit that has performed the large-unit lock with a limitation in preparation for writing to the first unit area included in the large-unit lock area. Running in the first mode,
Database management method.
データベース管理装置に、
複数のクライアントにそれぞれ対応して複数のデータベース管理部を起動させ、
前記複数のデータベース管理部は、それぞれ、対応するクライアントから取得されるコマンドに従って、前記複数のデータベース管理部によって共有される共有ストレージに対する処理を実行する実行部を備え、
前記複数の実行部のそれぞれが、前記共有ストレージに書き込み処理を行う前に、前記共有ストレージの領域の一部を第1単位でロックする小単位ロック、または、前記共有ストレージの領域の一部または全部を前記第1単位より大きい第2単位でロックする大単位ロックを実行させ、
前記大単位ロックを、前記大単位ロックを行った実行部以外の実行部による、前記大単位ロックが行われた領域に含まれる第1単位の領域に対する書き込みに備えた処理を、制限付きで許容する第1モードで実行させる、
データベース管理プログラム。
In the database management unit,
Start multiple database managers corresponding to multiple clients,
Each of the plurality of database management units includes an execution unit that executes processing for the shared storage shared by the plurality of database management units according to a command acquired from a corresponding client.
Before each of the plurality of execution units performs a write process on the shared storage, a small unit lock that locks a part of the shared storage area in a first unit, or a part of the shared storage area or Performing a large unit lock that locks all in a second unit greater than the first unit;
Allowing the large-unit lock to be processed with a restriction by the execution unit other than the execution unit that has performed the large-unit lock with a limitation in preparation for writing to the first unit area included in the large-unit lock area. To run in the first mode
Database management program.
JP2016183484A 2016-09-20 2016-09-20 Database management apparatus, database management method, and database management program Active JP6490642B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2016183484A JP6490642B2 (en) 2016-09-20 2016-09-20 Database management apparatus, database management method, and database management program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2016183484A JP6490642B2 (en) 2016-09-20 2016-09-20 Database management apparatus, database management method, and database management program

Publications (2)

Publication Number Publication Date
JP2018049394A true JP2018049394A (en) 2018-03-29
JP6490642B2 JP6490642B2 (en) 2019-03-27

Family

ID=61767560

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2016183484A Active JP6490642B2 (en) 2016-09-20 2016-09-20 Database management apparatus, database management method, and database management program

Country Status (1)

Country Link
JP (1) JP6490642B2 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2021144288A (en) * 2020-03-10 2021-09-24 株式会社日立製作所 Computer system, file storage, and data transfer method
JP2022177955A (en) * 2021-05-19 2022-12-02 株式会社ユニバーサルエンターテインメント game machine
JP2022177954A (en) * 2021-05-19 2022-12-02 株式会社ユニバーサルエンターテインメント game machine

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010015344A (en) * 2008-07-03 2010-01-21 Murata Mach Ltd Database system
JP2015230689A (en) * 2014-06-06 2015-12-21 株式会社東芝 Database apparatus and data access method

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010015344A (en) * 2008-07-03 2010-01-21 Murata Mach Ltd Database system
JP2015230689A (en) * 2014-06-06 2015-12-21 株式会社東芝 Database apparatus and data access method

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2021144288A (en) * 2020-03-10 2021-09-24 株式会社日立製作所 Computer system, file storage, and data transfer method
JP7061635B2 (en) 2020-03-10 2022-04-28 株式会社日立製作所 Computer system, file storage, and data transfer method
JP2022177955A (en) * 2021-05-19 2022-12-02 株式会社ユニバーサルエンターテインメント game machine
JP2022177954A (en) * 2021-05-19 2022-12-02 株式会社ユニバーサルエンターテインメント game machine
JP7278632B2 (en) 2021-05-19 2023-05-22 株式会社ユニバーサルエンターテインメント game machine
JP7360192B2 (en) 2021-05-19 2023-10-12 株式会社ユニバーサルエンターテインメント gaming machine

Also Published As

Publication number Publication date
JP6490642B2 (en) 2019-03-27

Similar Documents

Publication Publication Date Title
CN107977376B (en) Distributed database system and transaction processing method
JP2021057072A (en) Processing data from multiple sources
US11575748B2 (en) Data storage method and apparatus for combining different data distribution policies
AU2016244128B2 (en) Processing database transactions in a distributed computing system
US9558194B1 (en) Scalable object store
JP5765416B2 (en) Distributed storage system and method
US8626765B2 (en) Processing database operation requests
US11321302B2 (en) Computer system and database management method
US11755356B2 (en) Asynchronous queries on secondary data cores in a distributed computing system
US11811839B2 (en) Managed distribution of data stream contents
JP6490642B2 (en) Database management apparatus, database management method, and database management program
US10747739B1 (en) Implicit checkpoint for generating a secondary index of a table
US9875270B1 (en) Locking item ranges for creating a secondary index from an online table
Tang et al. Toward coordination-free and reconfigurable mixed concurrency control
US20130086124A1 (en) Mapping Data Structures
EP1519274A2 (en) Apparatus, program, and method for memory management
US20170371707A1 (en) Data analysis in storage system
US11940972B2 (en) Execution of operations on partitioned tables
US10824640B1 (en) Framework for scheduling concurrent replication cycles
US20170185629A1 (en) Multi-stream object-based upload in a distributed file system
JP5031538B2 (en) Data distribution method, data distribution program, and parallel database system
JP2007206913A (en) Database access system, application server node, database access method and program
JP5580754B2 (en) Exclusive control device and exclusive control method
JP5818264B2 (en) Computer system and job net execution method
WO2022091204A1 (en) Data analysis processing device, data analysis processing method, and program

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20180327

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20181212

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20181218

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20190121

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20190129

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20190227

R151 Written notification of patent or utility model registration

Ref document number: 6490642

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R151