1. Field of the Invention
The present invention relates to information management systems and more particularly to an optimistic version number based concurrency control for memory-resident index structures.
2. Description of the Related Art
Database systems use indexes for efficient access to specific data items. Different tree structures, such as B-trees and tries (radix trees) are a method of choice for the indexes. In order to provide safe access by multiple processors at the same time, index trees employ a concurrency control method to protect different parts of the tree from being read or written by a processor while another processor is writing to the same place at the same time.
Concurrency control is important for multiprocessor scalability of an index structure. Typically, concurrency control entails the use of latches to lock a part of the index tree, usually a single node, against reading, writing, or both. The best scalability is attained by concurrency control methods that have a minimum amount of latch collisions, i.e., the same latch being wanted by two or more processors at the same time.
In certain index structures, mainly different trie (radix tree) variants (and also in B-trees), at times only a single pointer in a node is to be updated. This update itself is atomic: if the pointer value is both read and updated at the same time, the reader either gets the whole old or the whole new value. In the optimistic, latch-free index traversal (“OLFIT”) scheme, updating a single pointer value in a node would require a version number update on the node, which in turn causes any concurrent read operation to conflict and retry. With nodes typically containing at least a dozen siblings, all the searches going to the siblings other than the one whose pointer is being updated will get false conflicts, potentially causing at least ten times more false than actual conflicts.
Therefore, there is a need for an efficient index structure and a concurrency control scheme that optimize database management systems against the high cost of invalidating paths that are not updated in a multiprocessing environment.
Embodiments of the present invention provide a method, system and computer program product for traversing a level in a search path in a tree data structure by recording a version number of a node on the search path, finding a child pointer in the node on the search path, recording a version number of a child node corresponding to the child pointer, reading a version number of the node on the search path, comparing the recorded version number of the node to the read version number of the node, reading at least one child pointer in the node and comparing the read child pointer to an address of the child node.
A data processing system for traversing a level in a search path in a tree data structure includes a host computer with processor and memory, a query processing system executing in the host computer and monitoring queries of a database in a main memory. The system can include a concurrency control module coupled to the query processing system, the module comprising program code for recording a version number of a node on the search path, for finding a child pointer in the node on the search path, for recording a version number of a child node corresponding to the child pointer, for reading a version number of the node on the search path, for comparing the recorded version number of the node to the read version number of the node, and for reading the child pointer in the node and comparing the read child pointer to an address of the child node.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention, as claimed.
The accompanying drawings, which are incorporated in and constitute part of this specification, illustrate embodiments of the invention and together with the description, serve to explain the principles of the invention. The embodiments illustrated herein are presently preferred, it being understood, however, that the invention is not limited to the precise arrangements and instrumentalities shown, wherein:
Embodiments of the present invention address deficiencies of the art in respect to traversing a level in a search path in a tree data structure and provide a novel and non-obvious method, system and computer program product for traversing a level in a search path in a tree data structure.
In further illustration,
Notably a concurrency control unit 136 can be coupled to the query processing system 134 and can execute in the memory by one or more of the processors of the host computer 130. In embodiments, concurrency control unit 136, preferably implemented in software, is provided to coordinate processing elements or threads so as to maintain the consistency of processing without too frequent invalidation of cache entries. In embodiments, the concurrency control unit 136 provides control necessary for latch-free traversal of index nodes based on optimistic index concurrency control. Concurrency control unit 136 can include program code enabled to record a version number of a node on a search path in a tree structure. Concurrency control unit 136 further can include program code to find a child pointer in the node on the search path and to record a version number of a child node corresponding to the child pointer. Concurrency control unit 136 yet further can include program code to read a version number of the node on the search path and to compare the recorded number of the node to the read version number of the node. Concurrency control unit 136 finally can include program code to read the child pointer in the node and to compare the read child pointer to an address of the child node.
In further illustration,
The concurrency control module 136 can include program code enabled upon execution in the memory of the host computer 130 to record a version number of a node in a search path into a memory register (e.g., register 1 of the general purpose computer) and to check if the version number is an odd number value. Additionally, the program code of the concurrency control module 136 can find a child pointer in the node on the search path by reading and processing the content of that node, which location of the child pointer can be recorded in a memory register (e.g., register 2 of the general purpose computer). The program code of the concurrency control module 136 can read version number of parent node to check if the parent's node version is different than the recorded node version stored in register 1 or if the node's version is odd and if so, restart the traversal of the search path. The program code of the concurrency control module 136 can record the child's node version in a memory register (e.g., register 3 of the general purpose computer), read the parent's node version number, determine if the read node version number is different for the recorded version number in register 1 and if so, restart the traversal of the search path. Otherwise, the program code of the concurrency control module 136 can read the child pointer in the node and compare the read child pointer to an address of the child node. Thereafter, the program code of the concurrency control module 136 can optionally perform a node update without changing the version number of the node, which includes latching the node, atomically updating the child pointer and unlatching or releasing the latched node. The program code of the concurrency control module 136 further can determine if the child pointer and the address of the child node are equal or optionally unequal. If the child pointer and the address of the child node are equal, the program code of the concurrency control module 136 further can determine whether the read node version number and the recorded version number in register 1 are equal and if so, the process can proceed to another level in the search path. In embodiments, the program code of the concurrency control module to proceed to another level in the search path can include proceeding to a leaf level in the search path. Finally, the program code of the concurrency control module 136 can determine that the child pointer and the address of the child node are not equal and restart the traversal of the search path.
In even yet further illustration of the operation of the concurrency control module 136,
In embodiments, more comprehensive operations, such as node splits, can be performed using a node splitting algorithm, which can include obtaining a latch onto the node, increasing the version number of the node by one to an odd numerical value, performing appropriate changes onto the node, increasing the version number of the node by one to an even value and releasing the latch onto the node.
As will be appreciated by one skilled in the art, aspects of the present invention may be embodied as a system, method or computer program product. Accordingly, aspects of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment (including firmware, resident software, micro-code, etc.) or an embodiment combining software and hardware aspects that may all generally be referred to herein as a “circuit,” “module” or “system.” Furthermore, aspects of the present invention may take the form of a computer program product embodied in one or more computer readable medium(s) having computer readable program code embodied thereon.
Any combination of one or more computer readable medium(s) may be utilized. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, radiofrequency, and the like, or any suitable combination of the foregoing. Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language and conventional procedural programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider).
Aspects of the present invention have been described above with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. In this regard, the flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. For instance, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
It also will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer readable medium that can direct a computer, other programmable data processing apparatus, or other devices to function in a particular manner, such that the instructions stored in the computer readable medium produce an article of manufacture including instructions which implement the function/act specified in the flowchart and/or block diagram block or blocks. The computer program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks.
Finally, the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used herein, the singular forms “a”, “an” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms “comprises” and/or “comprising,” when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
The corresponding structures, materials, acts, and equivalents of all means or step plus function elements in the claims below are intended to include any structure, material, or act for performing the function in combination with other claimed elements as specifically claimed. The description of the present invention has been presented for purposes of illustration and description, but is not intended to be exhaustive or limited to the invention in the form disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the invention. The embodiment was chosen and described in order to best explain the principles of the invention and the practical application, and to enable others of ordinary skill in the art to understand the invention for various embodiments with various modifications as are suited to the particular use contemplated.
Having thus described the invention of the present application in detail and by reference to embodiments thereof, it will be apparent that modifications and variations are possible without departing from the scope of the invention defined in the appended claims as follows: