Managing objects in shared caches using multiple chains

A chainset with multiple chains in multi-tenant database systems allows parallel updates and efficient garbage collection, addressing performance issues in managing shared memory by reducing lock contention and optimizing resource use.

JP2024177162AInactive Publication Date: 2024-12-19SALESFORCE INC
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
JP2024134843
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Priority Date
2020-01-31
Filing Date
2024-08-13
Publication Date
2024-12-19
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In multi-tenant database systems, managing database objects in shared memory can lead to performance degradation due to the time required for processes to obtain exclusive access to LRU chains, which interferes with other processes trying to access the chain, especially when tracking a large number of database objects.

Method used

Implementing a chainset with multiple chains to track database object usage, allowing parallel updates to different chains without locking the entire chainset, and performing garbage collection efficiently by combining chain creation and deletion operations.

Benefits of technology

Improves overall system performance by reducing lock contention and enabling parallel access to database objects, optimizing the use of shared memory resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2024177162000001_ABST
    Figure 2024177162000001_ABST
Patent Text Reader

Abstract

To provide a method and a computer-readable medium for managing objects associated with a database.SOLUTION: A method for maintaining caches of database objects using a chain set that includes multiple chains each specifying the order of the database objects is disclosed. In response to a change of a state of a database object, a corresponding chain is selected, and then the selected chain is locked, the state of the database object is changed, and thereafter the selected chain is unlocked.SELECTED DRAWING: Figure 1
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] This disclosure relates generally to accessing databases, and more particularly to managing objects associated with a database. [Background technology]

[0002] Cloud application development platforms potentially enable individual enterprises and SaaS vendors to develop robust, reliable, internet-scale applications that can access databases and process information retrieved from the databases. Some data may be computationally expensive to generate or change infrequently. Additionally, some data may be used by multiple users across an application or organization.

[0003] As part of deploying an application, the deployment platform may create database objects that assist in retrieving and processing information from a database. Such database objects may include query plans used to optimize and improve the performance of queries run against large numbers of records, as well as functions customized to meet the needs of a particular user.

[0004] A process performing an operation associated with a database can modify or manipulate database objects. When other processes try to use the database objects, they may not be using the current version of the database object. To allow other processes to synchronize and access the correct version of the modified database object, the database object can be stored in a shared memory area. [Brief description of the drawings]

[0005] [Figure 1]FIG. 2 is a block diagram of an application accessing an object in a shared memory. [Diagram 2] FIG. 2 is a block diagram of a chainset. [Diagram 3] FIG. 1 is a block diagram of a chain. [Figure 4] FIG. 2 is a block diagram of a shared memory. [Diagram 5] FIG. 1 is a block diagram of a multi-tenant database system. [Figure 6] FIG. 2 is a flow diagram illustrating one embodiment of a method for managing objects in a shared cache. [Figure 7] FIG. 2 is a flow diagram illustrating one embodiment of a method for garbage collecting a shared cache. [Figure 8] FIG. 2 is a block diagram illustrating an example of two processes accessing a database object in shared memory. [Figure 9] FIG. 1 is a block diagram of one embodiment of a computer system including a test broker application. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0006] While the present disclosure is susceptible to various modifications and alternative forms, specific embodiments thereof have been shown by way of example in the drawings and will herein be described in detail. It should be understood, however, that the drawings and detailed description are not intended to limit the disclosure to the particular forms illustrated; on the contrary, the intention is to cover all modifications, equivalents, and alternatives falling within the spirit and scope of the present disclosure as defined by the appended claims. The headings used herein are for organizational purposes only and are not intended to limit the scope of the description. As used throughout this application, the word "may" is used in a permissive sense (i.e., in the sense of "may") rather than a mandatory sense (i.e., in the sense of "must"). Similarly, the words "include," "including," and "includes" mean inclusive, but not limited.

[0007] Various units, circuits, or other components may be described as being "configured" to perform one or more tasks. In this context, "configured" is a broad reference to a structure that generally means "having circuitry" to perform one or more tasks during operation. As such, a unit / circuit / component may be configured to perform a task even if the unit / circuit / component is not currently turned on. In general, the circuitry that forms the structure corresponding to "configured" may include hardware circuitry. Similarly, various units / circuits / components may be described as performing one or more tasks for ease of description. Such descriptions should be construed to include the phrase "configured."

[0008] As used herein, the term "based on" is used to describe one or more factors that influence the determination. This term does not exclude the possibility that additional factors may influence the determination. That is, the determination may be based only on the specified factor or based on the specified factor and other unspecified factors. Consider the phrase "determining A based on B." This phrase specifies that B is a factor used to determine A or that influences the determination of A. This phrase does not preclude the possibility that the determination of A may also be based on other factors, such as C. This phrase is also intended to cover embodiments in which A is determined only based on B. Thus, the phrase "based on" is synonymous with the phrase "based at least in part on."

[0009] In a multitenant database system serving applications, deploying an application may involve the creation of multiple database objects. Such database objects may include one or more functions customized to the needs of individual users. Along with such user-defined functions, the database objects may also include plans that are generated to optimize and organize access to the database. In some cases, upgrading a user-defined application or an application that comes with the development platform may result in the generation of new versions of functions and plans.

[0010] In some multitenant database systems, database objects may be stored in a designated area in the main memory called "shared memory". Compiling functions and generating query plans is costly. Caching database objects created during such compilation operations allows reuse of the database objects and avoids the cost of recompiling the objects, thus improving the efficiency of the database system. Database objects stored in shared memory may be accessed by multiple processes accessing the database, allowing changes applied to a particular database object made by one process to be shared by the other processes. In some cases, different types of database objects may be stored in respective cache memories (or simply "caches") located in the shared memory. For example, user-defined functions may be stored in one cache memory and plans may be stored in another cache memory.

[0011] In a computer system, shared memory has a limited size, so not all database objects are stored in the shared memory at once. In many cases, the available shared memory can be used efficiently by storing recently used database objects in the shared memory and removing less frequently used database objects. Managing shared memory in this manner requires tracking the usage of database objects stored in the shared memory.

[0012] Various techniques may be employed to track the usage of database objects stored in shared memory. One technique involves maintaining a data structure called a chain that specifies an ordering by usage of the database objects stored in shared memory. This ordering may be based on how recently the database objects in shared memory have been used. For example, a Least Recently Used ("LRU") chain may be ordered such that the most recently used database objects occupy the initial position (or "head position") of the chain and the least recently used database objects occupy the last (or "tail") position of the chain.

[0013] When a database object is created and added to shared memory, it is added to the head of the LRU chain. When a database object is accessed, its position in the chain changes. For example, when a database object is used, its current position in the LRU chain is moved to the head position in the chain, so that the database object moves towards the head of the chain. The process of moving a database object's position to the head of the chain is called "promoting the database object". By promoting frequently used database objects, more recently used objects are placed towards the head of the chain and less recently used database objects are placed towards the tail of the chain.

[0014] Each time a new database object is added to the shared memory, the free space in the shared memory is checked. If there is insufficient free space to store the new database object, a database object previously stored in the shared memory is selected and removed from the shared memory. In systems that maintain an LRU chain, the database object occupying the tail position of the LRU chain is selected for removal. A database object at the end of the LRU chain is unlikely to be needed. Therefore, removing the tail object has minimal impact on database performance.

[0015] When modifying an LRU chain to add, remove, or promote a database object, the process performing said modification must obtain exclusive access to the chain using a lock to provide synchronized access to the LRU chain. When a process is granted a lock on the LRU chain, other processes cannot access the LRU chain to make their respective modifications. The inventors have realized that given the large number of database objects tracked by the LRU chain, the time required to scan the LRU to make the required modifications can degrade system performance by preventing other processes from accessing the LRU chain. The embodiments shown in the drawings and described below provide techniques for tracking database object usage that improve overall system performance.

[0016] One example of a computer system is shown in Figure 1. As shown, computer system 100 executes application 101 to access database 102. In various embodiments, computer system 100 is a particular embodiment of a multi-tenant database system that allows multiple users to access database 102 over a computer network.

[0017] Database 102 includes a shared memory 103, which includes a cache 104. Multiple database objects, including database object 107, may be stored in cache 104. A database object may be a user-defined function, access plan, or the like that allows an application to perform a particular task against the database. As described in more detail below, the size of shared memory 103 may be based on the amount of storage available in database 102. It should be noted that while a single cache is depicted as being included in shared memory 103, other embodiments may employ any suitable number of caches.

[0018] Computer system 100 maintains a chainset 105 and multiple chains 106, where each chain in chainset 105 specifies an ordering of database objects stored in cache 104. As described in more detail below, chain 106 may include multiple links that link the database objects in a specified order. Although only a single chainset with a single set of chains is depicted in Figure 1, other embodiments may employ multiple chainsets, each with multiple sets of chains.

[0019] In addition to maintaining the chain set 105 and the plurality of chains 106, the computer system 100 monitors the state of each of the database objects stored in the cache 104. As used herein, the state of a database object may refer to when the database object was last used, when the database object was added to the cache, etc. For example, when monitoring the state of a database object, the computer system 100 may track when the database object was accessed by an application. In some embodiments, the computer system 100 may collect additional metrics regarding the state of the shared memory 103. For example, the computer system 100 may track the number of non-empty chains, record the maximum number of non-empty chains, and track the number of garbage collection events for the chains.

[0020] In response to determining that the state of database object 107 has changed, computer system 100 selects one of chains 106 that corresponds to database object 107. The selection of the one of chains 106 may be based, at least in part, on the existence of a chain link to database object 107. In multiple releases of an application, database objects from different releases may be placed into corresponding chains.

[0021] Once the one chain is selected, the computer system updates the one chain but does not prevent other chains in chains 106 from being accessed during the update. By allowing access to other chains in chains 106, updates to other database objects in other chains can be performed in parallel without waiting for the update of the one chain to complete. Such parallel access can improve the performance of computer system 100 in various embodiments.

[0022] In various embodiments, updating the chain includes locking the chain. Locking the chain prevents other processes from accessing the chain while the update is in progress, thereby preventing other processes from accessing the chain while the update is in progress. Once locked, the chain is modified to reflect the state of the database object. As described below, modifying the chain may include modifying one or more links within the chain. Once the update is complete, the chain is unlocked, allowing other processes to access the chain using the updated information.

[0023] 2, a block diagram of one embodiment of a chain set 105 and its associated hash table is shown. As shown, chains 201A-201C are stored in a hash table 209. The chain set 105 maintains a list of all chains stored in the hash table 209. This list is accessible via a head pointer 205 and a tail pointer 206.

[0024] When a new chain is created, the new chain is added to the tail of the list and the tail pointer 206 is updated accordingly. The list maintained by the chain set 105 can, in some embodiments, facilitate sequential scanning of all chains and is used during invalidation and deletion of database objects that rely on iterating through the chains of the chain set. In a similar manner, when a chain is removed from the list during garbage collection, one or both of the head pointer 205 and tail pointer 206 may be updated.

[0025] Each chain 201A-201C may be identified by a key 202A-202C. Each key is unique and may be a sorted array of namespace identifiers. As used herein, a namespace refers to where data types used by a function are defined or where tables referenced by a plan are defined. Such data types include, in various embodiments, argument types, return types, local variable types, etc. Namespaces may be recorded during compilation of an application's functions. In some cases, there may be a maximum number of namespaces allowed for a database object.

[0026] Chains 201A-201C are doubly linked by forward links 203A-203C and reverse links 204A-204C in hash table 209 using a linked list structure. Links 203A-203C may point to the next chain in the list, and links 204A-204C may point to the previous chain in the list. Note that hash table 209 includes only three chains, but other embodiments may include any suitable number of chains. In some cases, the maximum number of chains that may be included in hash table 209 may be based, at least in part, on the amount of available storage in shared memory 103. The maximum number of chains in hash table 209 may be configurable during initialization of the cache in shared memory 103.

[0027] Each chain 201A-201C specifies an ordering for a set of corresponding database objects stored in shared memory 103. As described in more detail below, links between database objects may be used to specify the ordering. For example, chain 201A specifies an ordering for object 207A through object 207N, chain 201B has no database objects assigned to it as indicated by null object 208, and chain 201C specifies an ordering for object 209A through object 209N.

[0028] In some cases, each of chains 201A-201C may correspond to a different release or version of an application, since new application releases typically introduce new namespaces. For example, chain 201A can specify an order of database objects associated with a first release of an application, and chain 201B can specify an order of database objects associated with a second, different release of the application.

[0029] When a new database object is ready to be cached, a routine is executed to obtain a target chain to which the new database object should be attached. In some embodiments, the function to obtain the target chain checks the hash table 209. If this target chain already exists in the hash table 209, the new database object is added to the chain. However, if there is no chain corresponding to the new database object available in the hash table 209, another routine is executed to generate a new chain and the new database object is added to the newly created chain.

[0030] As described below, database objects may be removed from chains because they are no longer needed. When the last database object is removed from a chain, the chain becomes empty. However, empty chains are not immediately removed from hash table 209. Instead, new chains are created and a garbage collection routine is run when the total number of chains in hash table 209 exceeds a threshold. During the garbage collection routine, empty chains are removed from hash table 209 to free up space in hash table 209 to accommodate the space required for new chains. By garbage collecting as chains are added, the program code for both chain creation and deletion can be consolidated into a single routine. Thus, execution of a single routine requires acquiring chain set lock 210 in exclusive mode only once, which prevents other processes from accessing the chain set. Locking the chain set in this manner is a rare event, as new namespaces are rarely introduced once an application has been deployed or released and the application is stable. During read-only access to a chainset, i.e., access to read information contained in one of the chains in the chainset, the chainset lock 210 is held in shared mode, still allowing other processes access to retrieve information. Note that when a chainset is locked in shared mode, attempts to acquire the chainset lock in exclusive mode are blocked, i.e., a process cannot modify the chainset at the same time that it is accessing it.

[0031] Such a chain may be implemented in a variety of ways. A specific embodiment of a chain is shown in Figure 3. As shown, chain 300 includes key 301, objects 302A-302C, and lock 303. Note that chain 300 may correspond to any of chains 106 or 201A-201C. Note that objects 302A-302C may correspond to database objects 105 as shown in Figure 1.

[0032] The ordering of objects 302A-302C is specified by links 304 and 305. In some cases, the actual database objects corresponding to objects 302A-302C may not be included in chain 300, but only pointers to locations in a cache contained in shared memory 103 that contain the actual data. In a similar manner, links 304 and 305 may contain pointers to locations in a cache contained in shared memory 103 that correspond to objects 302A-302C.

[0033] As shown, each object 302A-302C is associated with two links; one pointing to the previous object in the sequence and one pointing to the next object in the sequence. Although each of the objects 302A-302C is depicted as being associated with two links, in other embodiments, only one link per object may be used. In various embodiments, the most recently used one of the objects 302A-302C may be located at the head position 306 and the most recently used one of the objects 302A-302C may be located at the tail position 307. It should be noted that while only three objects are depicted in the embodiment of FIG. 3, in other embodiments, the chain 300 may include any suitable number of objects.

[0034] When a new object is added to the chain 300, the new object is added to the head position 306. Links 304 and 305 are adjusted to reflect the position of the newly added object. When an object is removed from the chain 300, links 304 and 305 are modified to relink the other objects of objects 302A-302C around the position vacated by the newly removed object. When an object of objects 302A-302C is used, the chain 300 is locked and links 304 and 305 are adjusted to promote that one of objects 302A-302C towards the head position 306.

[0035] In various embodiments, when an object needs to be removed from a chain, the oldest object may be selected for removal. A timestamp-based age calculation scheme may also be employed. A global timestamp counter may be maintained by the chainset 105. This counter may be incremented when a new object is added to a chain in the chainset 105. The object itself may maintain a local timestamp, which is set to the value of the global timestamp counter when the object is added to the chain or when the object is promoted to the head position of the chain.

[0036] As described elsewhere in this disclosure, different chains may correspond to different releases of the application. To distinguish between different chains, each chain includes an identifier that includes identifying information. As shown, chain 300 includes key 301, which, as previously described, may include data indicating a namespace that includes definitions of database objects, such as tables and data types, used by objects 302A-302C. Although software version or release information may be used to identify a particular chain, any suitable type of information that aids in identifying chain 300 is possible and contemplated to be included in key 301.

[0037] Lock 303 may include data indicating whether the chain is currently locked by a process. In some cases, lock 303 may include not only data indicating that chain 300 is locked, but also data identifying the process to which the lock was granted. Locking and unlocking chain 300 may include storing different information in lock 303 that identifies the lock state of chain 300. Although lock 303 is depicted as being included in chain 300, in other embodiments lock 303 may be stored in a lookup table or other suitable structure instead of chain 300.

[0038] As previously discussed, different types of database objects may be stored in different caches within the shared memory. An example of a shared memory 103 having multiple caches is shown in FIG. 4. As shown, the shared memory 103 includes a function cache 401 and a plan cache 402. It should be noted that while the embodiment of FIG. 4 depicts two caches, other embodiments may employ any suitable number of caches. It should also be noted that the amount of storage allocated to the function cache 401 and the plan cache 402 may be based, at least in part, on the amount of available storage associated with the shared memory 103. In some cases, the respective amounts of storage associated with the function cache 401 and the plan cache 402 may differ.

[0039] The function cache 401 is operable to store database objects corresponding to functions used by one or more applications. For example, function database object 403 is included in the function cache 401. In various embodiments, a chainset 405 is used to track usage of the database objects stored in the function cache 401. The chainset 405 can include multiple chains, each corresponding to a set of unique identifiers introduced by a different release of an application.

[0040] Plan cache 402 is operable to store database objects corresponding to Structured Query Language ("SQL") query plans used by one or more applications. As shown, plan database object 404 is included in plan cache 402. Chain set 406, in various embodiments, is used to track usage of the database objects stored in plan cache 402. Like chain set 405, chain set 406 can include multiple chains, each corresponding to a set of unique identifiers introduced by a different release of an application.

[0041] Employing multiple chains to organize database objects stored in a cache can further improve the impact of changes to a particular chain. For example, when a given process modifies an object in a chain in chain set 405 and therefore exclusively locks that chain, it does not prevent other processes from modifying or accessing other database objects attached to other chains in chain set 405, thereby maximizing concurrency and throughput during database operations. Furthermore, distributing database objects across multiple chains reduces the time required to look up a database object in a chain compared to when all database objects are organized in only one chain.

[0042] With reference to Figure 5, an example of an environment in which a multi-tenant database and cache system may be implemented is shown. Note that the disclosed multi-tenant system is included for illustrative purposes and is not intended to limit the scope of the present disclosure. In other embodiments, similar techniques can be implemented in non-multi-tenant environments, such as various client / server environments, cloud computing environments, clustered computers, and the like.

[0043] As shown in FIG. 5, one or more user systems 512A-512C may interact with a multitenant database system (MTS) 500 via a network 514. The users of these user systems 512A-512C may be users in differing capacities, and the capacity of a user system of user systems 512A-512C may be determined by the current user. For example, if a sales representative is using one of user systems 512A-512C to interact with MTS 500, that user system may have capacity assigned to that sales representative. However, while an administrator is using the same user system to interact with MTS 500, that administrator has capacity assigned to that administrator.

[0044] Network 514 may be a LAN (local area network), a WAN (wide area network), a wireless network, a point-to-point network, a star network, a token ring network, a hub network, or any other suitable configuration. The global internetwork of networks, often referred to as the "Internet" with a capital "I," is used in many of the examples described herein and is an example of a TCP / IP (Transfer Control Protocol and Internet Protocol) network. However, it will be appreciated that the network of the present invention may utilize any of a variety of other types of networks.

[0045] The user systems 512A-512C may communicate with the MTS 500 using TCP / IP, and at higher network levels, using other common Internet protocols such as HTTP, FTP, AFS, WAP, etc. As an example, if HTTP is used, the user systems 512A-512C may include an HTTP client, commonly referred to as a "browser," for sending and receiving HTTP messages from an HTTP server in the MTS 500. Such a server may be implemented as the only network interface between the MTS 500 and the network 514, although other techniques may be used as well or instead. In some implementations, the interface between the MTS 500 and the network 514 includes a load sharing function. For example, a round-robin HTTP request distributor balances the load and distributes incoming HTTP requests evenly across multiple servers. It is desirable for each of the multiple servers to have access to the data in the MTS, at least for users who are accessing the server.

[0046] In some examples, the system shown in Figure 5 implements a web-based customer relationship management (CRM) system. For example, in some embodiments, MTS 500 includes an application server configured to implement and run a CRM software application as well as provide associated data, code, forms, web pages and other information to and from user systems 512A-512C, and store and retrieve associated data, objects and web page content to and from a database system. In embodiments of a multi-tenant system, it may be desirable to arrange tenant data to be kept separate from other tenants' data such that one tenant's data cannot access another tenant's data unless that tenant's data is explicitly shared.

[0047] An example of the configuration of elements of the MTS 500 is shown in Figure 5. It includes a network interface 520, storage 522 for tenant data, storage 524 for system data accessible to the MTS 500 and potentially multiple tenants, program code 526 for implementing various functions of the MTS 500 (e.g., locking a particular chain), and a process space 528 for running MTS system processes and tenant-specific processes, such as running applications as part of an application service.

[0048] 5 may include conventional and well-known elements that need not be described in detail here. For example, each user system 512A-512C may be a desktop personal computer, a workstation, a laptop, a PDA, a mobile phone, or any WAP-enabled or other computing device that can interface directly or indirectly to the Internet or other network connection. User systems 512A-512C may execute an HTTP client, such as a browsing program, such as Microsoft's Edge™ browser, Google's Chrome™ browser, or a WAP-enabled browser in the case of a mobile phone, PDA, or other wireless device, to enable a user of user system 512A-512C (e.g., a subscriber to the CRM system) to access, process, and display information and pages available from MTS 500 over network 514. Each of the user systems 512A-512C may include one or more user interface devices, such as a keyboard, mouse, touch screen, pen, etc., for interacting with a graphical user interface (GUI) provided by a browser on a display monitor screen, LCD display, etc., in combination with pages, forms, and other information provided by the MTS 500 or other systems or servers. As previously mentioned, the present invention is suitable for use with the Internet, which refers to a specific global internetwork of networks, although it will be appreciated that other networks may be used in place of the Internet, such as an intranet, extranet, virtual private network (VPN), non-TCP / IP based network, any LAN or WAN, etc.

[0049] In some embodiments, the user systems 512A-512C and their components are operator configurable using an application, such as a browser, that includes computer code executable on one or more processing elements. Similarly, in some embodiments, the MTS 500 (and one or more additional instances of the MTS) and its components are operator configurable using an application that includes computer code executable on one or more processing elements. Thus, various operations described herein may be performed by executing program instructions that are stored in a non-transitory computer-readable medium and executed by one or more processing elements. The program instructions may be stored in a non-volatile medium, such as a hard disk, or other well-known volatile or non-volatile memory medium or device, such as a ROM or RAM, or may be provided on any medium capable of storing program code, such as a compact disc (CD) medium, a digital versatile disc (DVD) medium, a floppy disk, or the like. Furthermore, the entire program code or portions thereof may be transmitted and downloaded, for example, from a software source on the Internet or from another server as is well known, or via other conventional network connections as is well known (e.g., extranet, VPN, LAN, etc.) using any communication medium and protocol as is well known (e.g., TCP / IP, HTTP, HTTPS, Ethernet, etc.) It will also be appreciated that computer code for implementing aspects of the present invention may be implemented in any programming language executable on a server or server system, such as, for example, C, C+, HTML, Java, JavaScript, or any other scripting language such as VBScript.

[0050] According to one embodiment, each MTS 500 is configured to provide web pages, forms, applications, data, and / or media content to user systems 512A-512C to support access by user systems 512A-512C as tenants of the MTS 500. Thus, in this embodiment, the MTS 500 provides a security mechanism to keep each tenant's data separate unless the data is shared. When multiple MTSs are used, they may be located in close proximity to each other (e.g., in a server farm in a building or campus) or distributed at distant locations from each other (e.g., one or more servers in city A and one or more servers in city B). As used herein, an MTS may include one or more logically and / or physically connected servers that are local or distributed in one or more geographic locations. Additionally, the term "server" includes a computer system including processing hardware and processing space, as well as associated storage systems and database applications that are well known in the art. It should also be understood that "server system" and "server" are often used interchangeably herein. Similarly, the databases described herein may be implemented as a single database, a distributed database, a collection of distributed databases, databases with redundant online or offline backups or other redundancy, and may include processing intelligence associated with a distributed database or storage network.

[0051] 6, a flow diagram illustrating one embodiment of a method for accessing an object in a shared memory of a computer system is shown. The method may be applied to a variety of computer systems, including computer system 100, and begins at block 601.

[0052] The method includes a computer system maintaining a chainset having a plurality of chains, each of the plurality of chains defining an ordering of the database objects stored in the cache (block 602). In some cases, each chain may define a respective ordering of the database objects associated with a corresponding release of the software application. For example, a first chain of the plurality of chains may define an ordering of a first plurality of database objects associated with a first release of the software application, and a second chain of the plurality of chains may define an ordering of a second plurality of database objects associated with a second release of the software application that is different from the first release.

[0053] The method also includes the computer system monitoring a state of each of the plurality of database objects (block 603). In various embodiments, the monitoring may include tracking when a particular database object is used by an application. Additionally, the monitoring may include notifying when a particular database object is removed from the cache or when a new database object is added to the cache.

[0054] The method further includes, in response to determining that a state of a database object has changed, the computer system selecting a chain of the plurality of chains that corresponds to the database object (block 604). In various embodiments, the selecting may include checking an identifier associated with each chain of the plurality of chains.

[0055] The method also includes the computer system updating the one chain without preventing other chains of the multiple chains from being accessed during the update (block 605). Because the ordering of database objects is managed across the multiple chains, locking a chain only affects a subset of the total database objects. Locking the one chain allows access to database objects associated with other chains to continue, improving overall system performance.

[0056] In various embodiments, the method includes locking the one chain, modifying the locked chain to reflect the changed state of the one object, and unlocking the one chain after updating (block 606). In various embodiments, locking the one chain may include setting a lock data field to a value that indicates the one chain is currently in use. Unlocking the one chain may include setting a lock data field to another value that indicates the one chain is no longer in use.

[0057] In some cases, modifying a locked chain may include removing the database object from the chain. Or, modifying a locked chain may include adding the database object to the chain. In some cases, modifying a locked chain may include changing the location of the database object within the order specified in the locked chain. The method ends at block 607.

[0058] Occasionally, updates of a more global nature need to be made to the chains contained in a chainset. During such global modifications, the chainset itself is locked, restricting access to the chains until the particular global modification is complete. For example, a chainset must be locked when an existing chain in the chainset is removed (in a process known as "garbage collection") or when a new chain is added to the chainset.

[0059] Because storage allocated to an empty chain may not be needed until a new chain is added, a chain does not need to be immediately removed from its associated chain set when it becomes empty. Thus, both garbage collection and the addition of a new chain can be performed simultaneously using a single lock on the chain set. Performing garbage collection while a new chain is being added can improve the overall performance of a computer system by reducing the possibility of lock contention on the chain set. Also, by not immediately removing empty chains, the overhead associated with performing such a removal operation is avoided. More importantly, when a database object is added to an empty chain, the overhead associated with generating a new chain is avoided and the empty chain is effectively reused.

[0060] A flow diagram illustrating one embodiment of a method for performing garbage collection is shown in Figure 7. The method, which may be applied to a variety of computer systems, including the computer system of Figure 1, begins at block 701.

[0061] The method includes, in response to determining to add a new chain to the chainset, locking the chainset, adding the new chain to the chainset, and unlocking the chainset (block 702). In various embodiments, adding a new chain to the chainset may correspond to receiving an upgrade to an application. Versions of database objects associated with the upgraded application may be grouped into a common chain that is added to the chainset.

[0062] The method includes performing a garbage collection operation in response to determining that the number of chains included in the chainset is greater than a threshold while the chainset is locked (block 703). In various embodiments, the threshold is based, at least in part, on an available amount of memory for storing database objects. In some implementations, performing the garbage collection operation includes removing at least empty chains from the chainset. The method ends at block 704.

[0063] An example of three processes accessing database objects simultaneously in a shared memory is shown in FIG. 8. As shown, shared memory 804 includes a chain set 802 and a cache 806. Chain set 802 includes chains 803A and 803B, and cache 806 includes database objects 805A-805C. Usage of database objects 805A and 805B is tracked by chain 803A, and usage of database object 805C is tracked by chain 803B. Note that in various embodiments, shared memory 804 may correspond to shared memory 103, chain set 802 may correspond to chain set 105, and cache 806 may correspond to cache 104. It should be further noted that processes 801A-801C may be the result of application 101 running on the computer system.

[0064] During operation, process 801A accesses database object 805A in shared memory 804. As a result of the access, process 801A needs to promote database object 805A within chain 803A in order to move it closer to the top of chain 803A. To perform the promotion of database object 805A, process 801A acquires a lock on chain 803A and begins a process to change the position of database object 805A within chain 803A.

[0065] While process 801A is updating chain 803A, process 801B is accessing database object 805B. In a similar manner to how database object 805A is accessed, the position of database object 805B must also be updated in chain 803A. When process 801B attempts to acquire a lock on chain 803A, it cannot do so due to the lock currently held by process 801A. Once process 801A completes the updated chain 803A, its lock is released and process 801B can acquire a lock on chain 803A and perform its updates. Because database objects 805A and 805B are tracked by the same chain, their updates cannot be made in parallel and must wait until the other process has performed its update.

[0066] In contrast, while process 801A is updating chain 803A, process 801C is accessing database object 805C. Because the usage of database object 805C is tracked by chain 803B, process 801C must acquire a lock on chain 803C in order to update database object 805C's position in chain 803B. Because the usage of database object 805C is tracked using a separate chain from the usage of database object 805A, updates to chains 803A and 803B can occur in parallel, improving system performance.

[0067] While the above example shows the promotion of database objects within each chain, in other embodiments other changes in the state of database variables may result in similar steps to those described above. For example, chain 803A may be locked due to the addition of a new database object, and chain 803B may be locked to perform a promotion of a database object within chain 803B.

[0068] Referring to FIG. 9, a block diagram of one embodiment of a computer system including a database with shared memory is shown. Computer system 900 includes a number of workstations designated 902A through 902D. The workstations are coupled to one another via network 901 and connected to a number of storages designated 907A through 907C. In one embodiment, each workstation 902A-902D may represent any standalone computing platform including, for example, one or more processors, local system memory including any type of random access memory (RAM) device, a monitor, a network connection, and input / output (I / O) means such as a mouse, keyboard, monitor, etc. (many of which are not shown for simplicity). In some embodiments, workstations 902A-902D may be included in a server farm or other collection of computing resources for use in performing distributed computing operations.

[0069] However, while depicted as coupled to a common network in the embodiment of Figure 9, in other embodiments, workstations 902A-902D are coupled to one another, as well as storage 907A-907C, via multiple networks. Note that while four workstations are shown in the embodiment of Figure 9, in other embodiments, any suitable number of workstations may be employed.

[0070] In one embodiment, storage devices 907A-907C may represent any type of mass storage device, such as a hard disk system, optical media drive, tape drive, RAM disk storage device, etc. As such, the program instructions that make up application 101 may be stored within any of storage devices 907A-907C and loaded into the local system memory of any of the workstations during execution. In various embodiments, storage devices 907A-907C may include portable storage media that may be used directly or may be removed from computer system 900. Such portable storage media, local system memory, and mass storage devices may be referred to as non-transitory computer readable storage media.

[0071] 9, application 101 is shown stored in storage 907A and database 102 is shown stored in storage 907C. In one embodiment, application 101 may be executed by any of workstations 902A-902D. Program instructions associated with application 101 may be executed directly from storage 907A or transferred from workstation 902A to the local system memory of any of workstations 902D for subsequent execution. One or more processors on a workstation of workstations 902A-902D may execute program instructions associated with application 101, or the program instructions may be distributed among multiple workstations of workstations 902A-902D, as desired.

[0072] Implementations of the subject matter of the application include, but are not limited to, Examples 1-20 below. 1. A method for tracking usage of database objects stored in a shared memory to manage the shared memory, comprising: a computer system maintaining a chainset having a plurality of chains, each of the plurality of chains defining an ordering of database objects stored in a cache; said computer system monitoring a state of each of a plurality of database objects; In response to determining that a state of a database object has changed, the computer system selects a chain from among a plurality of chains corresponding to the database object; updating the one chain without preventing other chains of the plurality of chains from being accessed during the update, the computer system comprising: locking said one chain; modifying the one locked chain to reflect the changed state of the one database object; and unlocking the one chain after updating. method. 2. The method of example 1, wherein modifying a locked chain includes adding the database object to the chain. 3. The method of example 1, wherein modifying the locked chain includes removing the database object from the chain. 4. The method of example 1, wherein the order in which the database objects are stored in the cache is based, at least in part, on the relative frequency of use of the database objects. 5. Further, said computer system, in response to determining that a new chain is to be added to said chainset, locking the chainset; adding the new chain to the chainset; unlocking the chainset. The method of Example 1. 6. The method of embodiment 5, further comprising: performing the step in response to determining that the number of chains included in the chainset is greater than a threshold value, and is performed after the garbage collection locks the chainset but before unlocking the chainset. 7. A non-transitory computer readable medium having stored thereon programming instructions that can cause a computer system to perform operations, said operations including: a computer system maintaining a chainset having a plurality of chains, each of the plurality of chains defining an ordering of database objects stored in a cache; said computer system monitoring a state of each of a plurality of database objects; In response to determining that a state of a database object has changed, the computer system selects a chain from among a plurality of chains corresponding to the database object; updating the one chain without preventing other chains of the plurality of chains from being accessed during the update, the computer system comprising: locking said one chain; modifying the one locked chain to reflect the changed state of the one database object; and unlocking the one chain after updating. Non-transitory computer-readable medium. 8. The non-transitory computer-readable storage medium of example 7, wherein modifying the locked one chain includes adding the one database object to the chain. 9. The non-transitory computer-readable storage medium of example 7, wherein modifying the locked chain includes removing the database object from the chain. 10. The non-transitory computer-readable storage medium of example 7, wherein the order of database objects stored in the cache is based, at least in part, on a relative frequency of use of the database objects. 11. Further, the computer system, in response to determining that a new chain is to be added to the chainset, locking the chainset; adding the new chain to the chainset; and unlocking the chainset. 12. The non-transitory computer-readable storage medium of Example 11, further comprising: the performing being performed in response to a determination that the number of chains included in the chainset is greater than a threshold value, and being performed after the garbage collection locks the chainset and before unlocking the chainset. 13. The non-transitory computer-readable storage medium of example 7, wherein a first chain of the multiple chains specifies an ordering of a first set of multiple database objects associated with a set of identifiers introduced by a first release of the software application, and a second chain of the multiple chains specifies an ordering of a second set of multiple database objects associated with a different set of identifiers introduced by the first or second release of the software application. 14. A computer system comprising: one or more memories for storing instructions during operation; and one or more computational resources that, during operation, receive instructions from the one or more memories and execute the instructions to cause the computer system to perform a next operation, the next operation being: a computer system maintaining a chainset having a plurality of chains, each of the plurality of chains defining an ordering of database objects stored in a cache; said computer system monitoring a state of each of a plurality of database objects; In response to determining that a state of a database object has changed, the computer system selects a chain from among a plurality of chains corresponding to the database object; updating the one chain without preventing other chains of the plurality of chains from being accessed during the update, the updating comprising: locking said one chain; modifying the one locked chain to reflect the changed state of the one database object; and unlocking the one chain after updating. Computer system. 15. The computer system of example 14, wherein modifying the locked chain includes adding the database object to the chain. 16. The computer system of example 14, wherein modifying the locked chain includes removing the database object from the chain. 17. The computer system of example 14, wherein the order in which the database objects are stored in the cache is based, at least in part, on the relative frequency of use of the database objects. 18. Further, the computer system, in response to determining that a new chain is to be added to the chainset, locking the chainset; adding the new chain to the chainset; and unlocking the chainset. 19. The computer system of embodiment 18, further comprising: the performing being performed in response to a determination that the number of chains included in the chainset is greater than a threshold value, and being performed after the garbage collection locks the chainset but before unlocking the chainset. 20. The computer system of example 14, wherein a first chain of the multiple chains defines an ordering of a first set of multiple database objects associated with a set of identifiers introduced by a first release of the software application, and a second chain of the multiple chains defines an ordering of a second set of multiple database objects associated with a different set of identifiers introduced by the first or second release of the software application.

[0073] Although specific embodiments have been described above, these embodiments are not intended to limit the scope of the present disclosure, even if only a single embodiment is described for a particular feature. The examples of features provided in this disclosure are intended to be illustrative rather than limiting, unless otherwise stated. The above description is intended to cover alternatives, modifications, and equivalents as would be apparent to one skilled in the art having the benefit of this disclosure.

[0074] The scope of the present disclosure includes any feature or combination of features disclosed herein (explicitly or implicitly), or any generalization thereof, whether or not it alleviates any or all of the problems addressed herein. Accordingly, new claims may be formulated to such combinations of features during the prosecution of this application (or any application claiming priority thereto). In particular, with reference to the appended claims, features of the dependent claims may be combined with features of the independent claims, and features of each independent claim may be combined in any suitable manner, not just in the specific combinations recited in the appended claims.

Claims

1. 1. A method for tracking usage of database objects stored in a shared memory to manage the shared memory, comprising: a computer system maintaining a chainset having a plurality of chains, each of the plurality of chains defining a usage ordering of cached database objects; said computer system monitoring a state of each of a plurality of database objects; In response to determining that a state of a database object has changed, the computer system selects a chain from among a plurality of chains corresponding to the database object, where software version information is used to identify the chain; The computer system updates the one chain but does not prevent other chains of the plurality of chains from being accessed during the update, the updating comprising: locking said one chain; modifying the one locked chain to reflect the changed state of the one database object; and unlocking the one chain after updating; a first chain of the plurality of chains indicating an ordering of a first plurality of database objects associated with a first release of a software application, and a second chain of the plurality of chains indicating an ordering of a second plurality of database objects associated with a second release of the software application; method.

2. 2. The method of claim 1 , wherein a most recently used database object occupies a tail position in the chain, the method further comprising selecting the database object occupying the tail position for eviction from the shared memory and evicting the object from the shared memory.

3. 3. The method of claim 1, wherein a chain comprises links that link the database objects in a defined order.

4. 4. The method of claim 1, wherein the chain set includes an empty chain that stores a null object indicating that no database object is currently associated with the chain set.

5. 5. The method of claim 1, wherein modifying the locked chain comprises adding the database object to the chain.

6. 5. The method of claim 1, wherein modifying the locked chain comprises removing the database object from the chain.

7. 5. The method of claim 1, wherein modifying the locked chain comprises moving the database object to a position at or near the head of the chain.

8. 8. The method of claim 1, wherein the ordering of database objects stored in the cache is based, at least in part, on a relative frequency of use of the database objects.

9. Further, the computer system, in response to determining that a new chain is to be added to the chainset, locking the chainset; adding the new chain to the chainset; unlocking the chainset.

9. The method according to any one of claims 1 to 8.

10. 10. The method of claim 9, further comprising the computer system performing a garbage collection operation on the chainset, the performing being performed in response to determining that a number of chains included in the chainset is greater than a threshold, and the garbage collection being performed after locking the chainset and before unlocking the chainset.

11. a first chain of the plurality of chains defining a first plurality of database object orderings of a set of database objects associated with a set of identifiers introduced by a first release of a software application, and a second chain of the plurality of chains defining a second plurality of database object orderings of database objects associated with a different set of identifiers introduced by the first or second release of the software application; 11. The method according to any one of claims 1 to 10.

12. 12. A method according to claim 1, wherein a process that accesses a database object acquires a lock on the chain that contains the database object and changes the position of the database object within the chain, the lock preventing other processes from accessing the chain.

13. At least one processor; A memory having stored therein program instructions for causing said at least one processor to carry out the method according to any one of claims 1 to 12; A computer system having:

14. A computer readable medium having stored thereon programming instructions for causing a computer system to carry out the method of any one of claims 1 to 12.

Citation Information

Patent Citations

  • Distributing a plurality of tracks to add to cache to lists assigned to processors

    US20170052903A1