Managing objects in a shared cache using multiple chains

By using chain sets and hash table structures to manage database objects in a multi-tenant database system, efficient use of shared memory is achieved, performance issues caused by LRU chain synchronous access are resolved, and the overall performance and throughput of the system are improved.

CN114207601BActive Publication Date: 2025-09-09SALESFORCE INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202180004832.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2020-01-31
Filing Date
2021-01-29
Publication Date
2025-09-09
Estimated Expiration
2041-01-29

AI Technical Summary

Technical Problem

In a multi-tenant database system, the existing technology has the problem of reduced system performance when managing database objects in a shared memory, because the synchronous access of the LRU chain causes other processes to be blocked, affecting system efficiency.

Method used

The chain set and hash table structure are used to manage the sorting of database objects. By updating different chains in parallel, exclusive access to the LRU chain is avoided, thereby improving system performance.

Benefits of technology

By updating different chains in parallel, system performance bottlenecks are reduced, the efficiency and throughput of the database system are improved, and the probability of lock contention is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114207601B_ABST
    Figure CN114207601B_ABST
Patent Text Reader

Abstract

A method for maintaining a cache of database objects using a chain set is disclosed. The chain set includes a plurality of chains, each chain specifying an ordering of database objects. In response to a state change of a particular database object, a corresponding chain is selected. The selected chain is then locked, the state of the particular database object is changed, and then the selected chain is unlocked.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art Technical Field

[0002] The disclosure relates generally to accessing databases and, more particularly, to managing objects associated with databases.

[0003] Description of Related Technology

[0004] Cloud application development platforms enable individual businesses and software-as-a-service providers to develop robust, reliable, and internet-scale applications. Such applications can access databases and process information retrieved from them. Some data may be computationally expensive to generate, while some data may rarely change. Furthermore, some data may be used by multiple users across applications or organizations.

[0005] As part of application deployment, the deployment platform may allow the creation of database objects to assist in retrieving and processing information from the database. Such database objects may include query plans for optimizing and improving the performance of queries executed on large numbers of records, as well as functions that have been customized to specific user needs.

[0006] Processes that perform operations associated with a database can modify or manipulate database objects. When other processes attempt to use database objects, they might not be using the current version of the database objects. To enable other processes to access the correct version of modified database objects in a synchronized manner, database objects can be stored in a shared memory area. BRIEF DESCRIPTION OF THE DRAWINGS

[0007] Figure 1 is a block diagram of an application that accesses objects in shared memory.

[0008] Figure 2 It is a block diagram of a chain set.

[0009] Figure 3 It is a block diagram of the chain.

[0010] Figure 4 is a block diagram of shared memory.

[0011] Figure 5 It is a block diagram of a multi-tenant database system.

[0012] Figure 6 A flow chart depicting an embodiment of a method for managing objects in a shared cache is shown.

[0013] Figure 7 A flow chart depicting an embodiment of a method for performing garbage collection in a shared cache is shown.

[0014] Figure 8 is a block diagram depicting an example of two processes accessing a database object in shared memory.

[0015] Figure 9 is a block diagram of one embodiment of a computer system that includes a test agent application.

[0016] Although the disclosure allows various modifications and alternative forms, its specific embodiments are shown by the examples in the accompanying drawings and will be described in detail herein. However, it should be understood that the drawings and their detailed description are not intended to limit the disclosure to the specific forms shown, but on the contrary, are intended to cover all modifications, equivalents and replacements that fall within the spirit and scope of the disclosure defined by the appended claims. The titles used herein are only for organizational purposes and are not meant to limit the scope of this specification. As used in this application, the word "may" is used in a permitted sense (that is, to mean that it is possible), rather than a mandatory sense (that is, to mean that it must). Similarly, the word "comprises" means including but not limited to.

[0017] Various units, circuits, or other components may be described as being “configured to” perform one or more tasks. In such contexts, “configured to” is a broad description of structure, generally meaning “having circuitry that” performs one or more tasks during operation. Thus, a unit / circuit / component may be configured to perform a task even when the unit / circuit / component is not currently turned on. Typically, the circuitry forming the structure corresponding to “configured to” may include hardware circuitry. Similarly, for ease of description, various units / circuit / components may be described as performing one or more tasks. Such descriptions should be interpreted as including the phrase “configured to.”

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

[0019] In a multi-tenant database system serving applications, application deployment may involve the creation of multiple database objects. These database objects may include customized versions of one or more functions to suit individual user needs. In addition to these user-defined functions, database objects may also include pre-generated plans for optimizing and organizing database access. In some cases, new versions of functions and plans may be generated when user-defined applications or applications provided with the development platform are upgraded.

[0020] In some multi-tenant database systems, database objects may be stored in a designated area within main memory called "shared memory." Compiling functions and generating query plans can be expensive. Caching database objects created during such compilation operations enables the reuse of database objects without the cost of recompiling the objects, thereby improving the efficiency of the database system. Database objects stored in shared memory can be accessed by multiple processes accessing the database, allowing changes made to a particular database object by one process to be shared by other processes. In some cases, different types of database objects may be stored in corresponding buffer memories (or simply "caches") located within shared memory. For example, user-defined functions may be stored in one buffer memory, while plans may be stored in a separate buffer memory.

[0021] In computer systems, the size of shared memory is limited, preventing all database objects from being stored in shared memory at a given time. In many cases, efficient use of available shared memory can be achieved by storing the most recently used database objects in shared memory and retiring less frequently used database objects. To manage shared memory in this manner, it is necessary to track the use of database objects stored in shared memory.

[0022] Various techniques can be employed to track the usage of database objects stored in shared memory. One technique involves maintaining a data structure, known as a chain, that specifies an ordering of the usage of database objects stored in shared memory. The ordering can be based on how recently the database objects in shared memory have been used. For example, a least recently used ("LRU") chain specifies an ordering in which the most recently used database object occupies the beginning (or "head") position in the chain, while the least recently used database object occupies the last (or "tail") position in the chain.

[0023] When a given database object is created and added to shared memory, it is added to the head of the LRU chain. As database objects are accessed, their respective positions in the chain are modified. For example, when a particular database object is used, its current position in the LRU chain is moved to the head of the chain, moving the particular database object toward the head of the chain. The process of moving a database object's position to the head of the chain is called "promoting a database object." By promoting frequently used database objects, objects that have been used more recently will be at the head of the chain, while unused database objects will be at the tail of the chain.

[0024] Each time a new database object is added to the shared memory, the available space in the shared memory is checked. If there is not enough available space to store the new database object, the database object previously stored in the shared memory is selected and eliminated from the shared memory. In a system that maintains an LRU chain, the database object occupying the tail position of the LRU chain is selected and eliminated. The database object at the end of the LRU chain is less likely to be needed. Therefore, eliminating the tail object minimizes the impact on database performance.

[0025] When modifying the LRU chain to add, remove, or promote a database object, the process performing the modification must use a lock to obtain exclusive access to the chain in order to synchronize access to the LRU chain. When a given process is granted a lock on the LRU chain, other processes are blocked from accessing the LRU chain to make their own modifications. The inventors have recognized that given the large number of database objects tracked by the LRU chain, the time required to traverse the LRU in order to make the desired modifications can degrade system performance by hindering other processes attempting to access the LRU chain. The embodiments shown in the accompanying drawings and described below provide techniques for tracking database object usage that improve overall system performance.

[0026] Figure 1 1. As shown, computer system 100 executes application 101 to access database 102. In various embodiments, computer system 100 may be a specific embodiment of a multi-tenant database system that allows multiple users to access database 102 via a computer network.

[0027] Database 102 includes shared memory 103, which includes cache 104. Multiple database objects, including database object 107, can be stored in cache 104. As used herein, database objects refer to user-defined functions, access plans, and the like that enable applications to perform specific tasks on a database. As described in more detail below, the size of shared memory 103 can be based on the amount of memory available to database 102. It should be noted that while a single cache is described as being included in shared memory 103, in other embodiments, any suitable number of caches can be employed.

[0028] Computer system 100 maintains chain set 105 and chain 106, wherein each chain in chain set 105 specifies an ordering of database objects stored in cache 104. As described in more detail below, chain 106 may include multiple links linking database objects in a specified ordering. Figure 1 Only a single chain set having a single group of chains is depicted in FIG, but in other embodiments, multiple chain sets may be employed, each chain set having multiple groups of chains.

[0029] In addition to maintaining chain sets 105 and chains 106, computer system 100 also monitors the state of each of the database objects stored in cache 104. As used herein, the state of a database object can 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 given database object, computer system 100 can track when the given database object is accessed by an application. In some embodiments, computer system 100 can collect additional metrics about the state of shared memory 103. For example, computer system 100 can track the number of non-empty chains, record the highest number of non-empty chains, and track the number of chain garbage collection events.

[0030] In response to determining that the state of database object 107 has changed, computer system 100 selects a particular chain in chains 106 that corresponds to database object 107. Selecting a particular chain in chains 106 can be based at least in part on which links to the chain of database object 107 reside. In the case of multiple releases of an application, database objects from different releases can be located in corresponding chains.

[0031] Once a particular chain is selected, the computer system updates the particular chain without preventing other chains in the chain 106 from being accessed during the update. By allowing access to other chains in the chain 106, updates to other database objects in other chains can be performed in parallel without having to wait for the update of the particular chain to complete. In various embodiments, this parallel access can improve the performance of the computer system 100.

[0032] In various embodiments, updating a particular chain includes locking the particular chain. While the update is in progress, the lock on the particular chain prevents other processes from accessing the particular chain, thereby ensuring that other processes cannot access the particular chain during the mid-update. Once locked, the particular chain is modified to reflect the state of the particular database object. As described below, modifying the chain may include modifying one or more links included in the particular chain. Once the update is complete, the particular chain is unlocked, allowing other processes to access the chain with the updated information.

[0033] Steering Figure 2 , depicts a block diagram of an embodiment of a chain set 105 and its associated hash table. As shown, chains 201A-201C are stored in a hash table 209. Chain set 105 maintains a list of all chains stored in hash table 209. This list can be accessed through a head pointer 205 and a tail pointer 206.

[0034] When a new chain is created, it is appended to the end of the list and the tail pointer 206 is updated accordingly. In some embodiments, the list maintained by the chain set 105 can facilitate sequential scanning of all chains and is used during invalidation and elimination of database objects, which relies on iterating through the chains in 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 the tail pointer 206 can be updated.

[0035] Each chain 201A-201C can be identified by a key 202A-202C. Each key is unique and can be an ordered array of namespace identifiers. As used herein, a namespace is a place where data types used by a function are defined or where tables referenced by a plan are defined. In various embodiments, such data types can include independent variable types, return types, local variable types, etc. Namespaces can be recorded during function compilation in an application. In some cases, there may be a maximum number of namespaces for a given database object.

[0036] Chains 201A-201C are bidirectionally linked using a linked list structure by forward links 203A-203C and backward links 204A-204C in the hash table 209. Links 203A-203C can point to the next chain in the list, while links 204A-204C can point to the previous chain in the list. Note that although only three chains have been described as being included in the hash table 209, in other embodiments, any suitable number of chains may be included. In some cases, the maximum number of chains that may be included in the hash table 209 may be based at least in part on the available storage in the shared memory 103. The maximum number of chains in the hash table 209 may be configured during initialization of the cache in the shared memory 103.

[0037] Each chain 201A-201C specifies an ordering of a corresponding set of database objects stored in shared memory 103. As described in more detail below, the ordering can be specified by using links between database objects. For example, chain 201A specifies the ordering of objects 207A through 207N, chain 201B has no database objects assigned to it and is marked as empty object 208, and chain 201C specifies the ordering of objects 209A through 209N.

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

[0039] 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 is to be attached. In some embodiments, the function that obtains the target chain will check hash table 209. If the target chain already exists in hash table 209, the new database object will be added to that chain. However, if no chain corresponding to the new database object is available in hash table 209, a different routine will be executed to create a new chain and add the new database object to the newly created chain.

[0040] As described below, database objects can be removed from chains when they are no longer needed. When the last database object is removed from a particular chain, the chain becomes empty. However, empty chains are not immediately removed from hash table 209. Instead, when a new chain is created and the total number of chains in hash table 209 exceeds a threshold, a garbage collection routine is executed. During the garbage collection routine, empty chains are removed from hash table 209 to free up space within hash table 209 to accommodate the new chain. By performing garbage collection simultaneously with chain additions, the program code for creating and removing chains can be organized within a single routine. Consequently, executing a single routine requires only a single acquisition of the chainset lock 210 in exclusive mode, which prevents other processes from accessing the chainset. Locking the chainset in this manner may be infrequent once an application is deployed or released and the application is stable, as the introduction of new namespaces becomes less common. During read-only access to the chainset (i.e., access to search for information contained in one of the chains in the chainset), the chainset lock 210 remains in shared mode, which still allows access by other processes for information lookup. Note that when a chainset is locked in shared mode, attempts to acquire the chainset lock in exclusive mode are blocked. In other words, while a process is accessing the chainset, modifications to the chainset are prevented simultaneously.

[0041] Chains such as those described above can be implemented in various ways. Figure 3 A specific embodiment of a chain is depicted in FIG. As shown, chain 300 includes key 301, objects 302A-302C, and lock 303. Note that chain 300 may correspond to chain 106 or any of 201A-201C. Note that any of objects 302A-302C may correspond to Figure 1 Database object 105 is shown.

[0042] 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 rather may simply be pointers to locations within a cache included in shared memory 103 that contain the actual data. In a similar manner, links 304 and 305 may include pointers to locations within a cache included in shared memory 103 that correspond to objects 302A-302C.

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

[0044] When a new object is added to chain 300, the new object is added at head position 306. Links 304 and 305 are adjusted to reflect the position of the newly added object. When an object is removed from chain 300, links 304 and 305 are changed to relink the other objects in objects 302A-302C around the position vacated by the newly removed object. When a given one of objects 302A-302C is used, chain 300 is locked and links 304 and 305 are adjusted to move the given one of objects 302A-302C toward head position 306.

[0045] In various embodiments, when an object needs to be removed from a chain, the oldest object can be selected and eliminated. A timestamp-based age calculation scheme can be employed. A global timestamp counter can be maintained by the chain set 105. Whenever a new object is added to a given chain in the chain set 105, the counter can be incremented. The object itself can maintain a local timestamp that 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 of its chain.

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

[0047] Lock 303 may include data indicating whether the chain is currently locked by a particular process. In some cases, lock 303 may include not only data indicating that chain 300 is locked, but also data identifying the process that has been granted the lock. 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 described as being included in chain 300, in other embodiments, lock 303 may be stored in a lookup table or other suitable structure rather than in chain 300.

[0048] As mentioned previously, different types of database objects can be stored in different caches within the shared memory. Figure 4 , an embodiment of a shared memory 103 having multiple caches is described in FIG. As shown in the figure, the shared memory 103 includes a function cache 401 and a plan cache 402. It should be noted that although Figure 4 In the embodiment depicted in FIG, two caches are depicted, but in other embodiments, any suitable number of caches may be employed. It should also be noted that the amount of memory allocated to function cache 401 and plan cache 402 may be based at least in part on the amount of available memory associated with shared memory 103. In some cases, the respective amounts of memory associated with function cache 401 and plan cache 402 may be different.

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

[0050] Plan cache 402 can be 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. In various embodiments, chain set 406 is used to track the use of database objects stored in plan cache 402. Similar to chain set 405, chain set 406 can include multiple chains, each chain corresponding to a set of unique identifiers introduced by a different release of the application.

[0051] By organizing database objects stored in a type of cache using multiple chains, the impact of modifying a particular chain can be further mitigated. For example, a given process that modifies an object in one chain within chain set 405, thereby exclusively locking that chain, does not prevent other processes from modifying or accessing other database objects attached to other chains within chain set 405, thereby maximizing concurrency and throughput during database operations. Furthermore, by distributing database objects across multiple chains, the time required to locate a particular database object within a particular chain is reduced compared to a scenario where all database objects were organized in only one chain.

[0052] Go to Figure 5 , illustrates an exemplary environment in which a multi-tenant database and cache system can be implemented. Note that the disclosed multi-tenant system is included for illustrative purposes and is not intended to limit the scope of the 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.

[0053] like Figure 5 As shown, one or more user systems 512A-512C can interact with a multi-tenant database system (MTS) 500 via a network 514. The users of these user systems 512A-512C can be users of different capacities, and the capacity of a particular one of the user systems 512A-512C can be determined by the current user. For example, when a salesperson interacts with MTS 500 using a particular one of the user systems 512A-512C, the capacity of that particular user system can be allocated to the salesperson. However, when an administrator interacts with MTS 500 using the same user system, the capacity is allocated to the administrator.

[0054] The network 514 can 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 interconnected network of networks is often referred to as the "Internet," with a capital "I," which will be used in many examples herein and is an example of a TCP / IP (Transmission Control Protocol and Internet Protocol) network. However, it should be understood that the network of the present invention can utilize any of a variety of other types of networks.

[0055] User systems 512A-512C may communicate with MTS 500 using TCP / IP, and at higher network layers, other common Internet protocols, such as HTTP, FTP, AFS, WAP, etc. For example, in the case of HTTP, 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 at MTS 500. Such a server may be implemented as the sole network interface between MTS 500 and network 514, but other technologies or alternatives may also be used. In some implementations, the interface between MTS 500 and network 514 includes a load sharing function, such as a round-robin HTTP request distributor, to balance the load and evenly distribute incoming HTTP requests across multiple servers. Preferably, each of the multiple servers has access to the MTS's data, at least for users accessing the servers.

[0056] In some embodiments, Figure 5 The illustrated system implements a web-based customer relationship management (CRM) system. For example, in some embodiments, the MTS 500 includes an application server configured to implement and execute a CRM software application and to provide relevant data, code, forms, web pages, and other information to and from user systems 512A-512C, and to store and retrieve relevant data, objects, and web page content in a database system. In embodiments of a multi-tenant system, tenant data is preferably configured so that one tenant's data is kept separate from the data of other tenants, such that one tenant cannot access another tenant's data unless such data is explicitly shared.

[0057] Figure 5An arrangement of elements of MTS 500 is shown, including a network interface 520, storage 522 for tenant data, storage 524 for system data accessible to MTS 500 and possibly multiple tenants, program code 526 for implementing various functions of MTS 500 (e.g., locking a particular chain), and a process space 528 for executing MTS system processes and tenant-specific processes (e.g., running applications as part of an application service).

[0058] Figure 5 Several elements of the system shown may include conventionally known elements and need not be described in detail herein. For example, each user system 512A-512C may be a desktop personal computer, a workstation, a laptop computer, a PDA, a mobile phone, or any WAP-enabled device or any other computing device capable of connecting directly or indirectly to the Internet or other network connection. The user systems 512A-512C may execute an HTTP client, such as a browser program, such as Microsoft Edge. TM Browser, Google Chrome TM A browser, or in the case of a cell phone, PDA, or other wireless device, a WAP-enabled browser, allows users of user systems 512A-512C (e.g., subscribers of a CRM system) to access, process, and view information from MTS 500 and its available pages via network 514. Each user system 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 the browser on a display monitor screen, LCD display, etc., as well as pages, forms, and other information provided by MTS 500 or other systems or servers. As described above, the present invention is applicable to the Internet, which refers to a specific global network of networks. However, it should be understood that other networks may be used in place of the Internet, such as an intranet, an extranet, a virtual private network (VPN), a non-TCP / IP based network, any LAN or WAN, etc.

[0059] In some embodiments, each of the user systems 512A-512C and its components can be configured by an operator using an application (e.g., a browser) that includes computer code that can be executed on one or more processing elements. Similarly, in some embodiments, the MTS 500 (and additional routines of the MTS, where more than one exists) and its components can be configured by an operator using an application that includes computer code that can be executed on one or more processing elements. Thus, the various operations described herein can be performed by executing program instructions stored on a non-transitory computer-readable medium and executed by one or more processing elements. The program instructions can be stored on a non-volatile medium, such as a hard disk, or can be stored in any other known volatile or non-volatile storage medium or device, such as a ROM or RAM, or provided on any medium capable of launching program code, such as a compact disc (CD) medium, a digital versatile disc (DVD) medium, a floppy disk, etc. Additionally, the entire program code or portions thereof may be transmitted and downloaded from a software source (e.g., via the Internet) or from another server using any well-known communication media and protocols (e.g., TCP / IP, HTTP, HTTPS, Ethernet, etc.), or transmitted via any other well-known conventional network connection (e.g., an extranet, VPN, LAN, etc.). It should also be understood that the computer code used to implement various aspects of the present invention may be implemented in any programming language capable of being executed on a server or server system, such as C, C++, HTML, Java, JavaScript, or any other scripting language, such as VBScript.

[0060] 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 MTS 500. Thus, in this embodiment, MTS 500 provides security mechanisms to keep the data of each tenant separate unless the data is shared. If more than one MTS is used, they can be located very close to each other (e.g., in a server farm located in a single building or campus), or they can be distributed in locations far away from each other (e.g., one or more servers located in city A and one or more servers located in city B). As used herein, an MTS can include one or more logically and / or physically connected servers distributed locally or across one or more geographical locations. In addition, the term "server" includes computer systems, including processing hardware and processing space, as well as associated storage systems and database applications, as are 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, a database with redundant online or offline backups or other redundancy, etc., and may include a distributed database or storage network and associated processing intelligence.

[0061] Go to Figure 6 , a flowchart depicting an embodiment of a method for accessing an object in a shared memory of a computer system is shown. The method can be applied to various computer systems including computer system 100, and the method begins at block 601.

[0062] The method includes maintaining, by a computer system, a chain set having a plurality of chains, wherein each chain in the plurality of chains specifies an ordering of database objects stored in a cache (block 602). In some cases, each chain may specify a respective ordering of database objects associated with a corresponding release of a software application. For example, a first chain in the plurality of chains may specify an ordering of a first plurality of database objects associated with a first release of the software application, and a second chain in the plurality of chains may specify 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.

[0063] The method also includes monitoring, by the computer system, the respective states of the plurality of database objects (block 603). In various embodiments, monitoring can include tracking when an application uses a given database object. Additionally, monitoring can include noting when a given database object has been removed from a cache or when a new database object has been added to the cache.

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

[0065] The method also includes updating, by the computer system, the particular chain without preventing other chains in the plurality of chains from being accessed during the update (block 605). Because the ordering of database objects is managed across multiple chains, locking the particular chain only affects a subset of the entire set of database objects. By locking the particular chain, database objects associated with other chains can still be accessed, thereby improving overall system performance.

[0066] In various embodiments, the method further includes updating comprising locking the specific chain, changing the locked specific chain to reflect the changed state of the specific object, and, after updating, unlocking the specific chain (block 606). In various embodiments, locking the specific chain may comprise setting a lock data field to a specific value indicating that the specific chain is currently in use. Unlocking the specific chain may comprise setting the lock data field to another value indicating that the specific chain is no longer in use.

[0067] In some cases, changing the locked specific chain may include removing the specific database object from the chain. Alternatively, changing the locked specific chain may include adding the specific database object to the chain. In some cases, changing the locked specific chain may include modifying the position of the specific database object in the sort order specified in the locked specific chain. The method ends at block 607.

[0068] In some cases, a more global update to the chains included in a chainset is required. During such a global change, the chainset itself is locked, thereby restricting access to the chains until the specific global change is complete. For example, a chainset needs to be locked when existing chains in the chainset are removed (in a process called "garbage collection"), or when new chains are added to the chainset.

[0069] When a link becomes empty, it doesn't need to be immediately removed from its associated link set, as the storage space allocated for the empty link may not be needed until a new link is added. This allows garbage collection and the addition of new links to be performed together, using a single lock on the link set. By performing garbage collection when a new link is added, the likelihood of lock contention on the link set is reduced, thereby improving the overall performance of the computer system. Furthermore, by not immediately removing empty links, the overhead associated with performing such removal operations is avoided. More importantly, when database objects are added to an empty link, the overhead associated with creating a new link is avoided, effectively reusing the empty link.

[0070] Figure 7A flow chart depicting an embodiment of a method for performing garbage collection is shown. The method may be applied to a system including Figure 1 In various computer systems of the computer system, the method begins at box 701.

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

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

[0073] Figure 8 An example is depicted in which three processes concurrently access database objects in shared memory. As shown, shared memory 804 includes chain set 802 and cache 806. Chain set 802 includes chains 803A and 803B, while cache 806 includes database objects 805A-805C. Chain 803A tracks the use of database objects 805A and 805B, while chain 803B tracks the use of database object 805C. It should be noted that in various embodiments, shared memory 804 can correspond to shared memory 103, chain set 802 can correspond to chain set 105, and cache 806 can correspond to cache 104. It should also be noted that processes 801A-801C can be generated by application 101 executing on the computer system.

[0074] 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 to move it closer to the head of chain 803A. To perform the promotion of database object 805A, process 801A obtains a lock on chain 803A and begins the process of changing the position of database object 805A within chain 803A.

[0075] While process 801A is updating chain 803A, process 801B accesses database object 805B. Similar to how database object 805A was accessed, the location of database object 805B must also be updated within chain 803A. When process 801B attempts to acquire a lock on chain 803A, it is unable to do so because process 801A currently holds the lock. Once process 801A has finished updating chain 803A, its lock is released, and process 801B can acquire the lock on chain 803A and perform its update. Because database objects 805A and 805B are both tracked by the same chain, updates cannot be performed in parallel, and one process must wait to perform its update.

[0076] Conversely, while process 801A is updating chain 803A, process 801C accesses database object 805C. Since chain 803B is tracking the use of database object 805C, process 801C needs to obtain a lock on chain 803C to update the location of database object 805C within chain 803B. Since a different chain is used to track the use of database object 805C than to track the use of database object 805A, updates to chains 803A and 803B can be performed in parallel, thereby improving system performance.

[0077] While the above examples describe promoting database objects within their respective chains, in other embodiments, other changes in the state of database variables may result in steps similar to those described above. For example, chain 803A may be locked due to the addition of a new database object, while chain 803B is locked to perform promotion of a database object within chain 803B.

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

[0079] Despite Figure 9In the embodiment of FIG, workstations 902A to 902D and storages 907A to 907C are depicted as being coupled to a common network, but in other embodiments, workstations 902A to 902D and storages 907A to 907C may be coupled to each other via multiple networks. Figure 9 The embodiment depicts four workstations, but in other embodiments, any suitable number of workstations may be employed.

[0080] In one embodiment, storage 907A-907C can represent any type of mass storage device, such as a hard disk system, an optical media drive, a tape drive, random access memory disk storage, etc. Thus, program instructions comprising application 101 can be stored in any of storage 907A-907C and loaded into the local system memory of any of the workstations during execution. In various embodiments, storage 907A-907C can include portable storage media that can be used directly or removed from computer system 900. Such portable storage media, local system memory, and mass storage can be referred to as non-transitory computer-readable storage media.

[0081] As an example, Figure 9 As shown, application 101 is shown as being stored in storage 907A, while database 102 is stored in storage 907C. In one embodiment, application 101 can be invoked by being executed by any of workstations 902A-902D. Program instructions associated with application 101 can be executed directly from storage 907A or transferred to the local system memory of one of workstations 902A-902D for subsequent execution. One or more processors on a given workstation of workstations 902A-902D can execute the program instructions associated with application 101, or the program instructions can be executed in a distributed manner across multiple workstations of workstations 902A-902D as needed.

[0082] Implementations of the subject matter of this application include, but are not limited to, the following Examples 1-20.

[0083] 1. A method comprising:

[0084] Maintaining, by a computer system, a chain set having a plurality of chains, wherein each chain in the plurality of chains specifies an ordering of database objects stored in a cache;

[0085] The computer system monitors the respective states of the plurality of database objects;

[0086] In response to determining that a state of the particular database object has changed, selecting, by the computer system, a particular chain of the plurality of chains corresponding to the particular database object; and

[0087] Updating a particular chain by a computer system without preventing other chains in a plurality of chains from being accessed during the updating, wherein the updating comprises:

[0088] Lock a specific chain;

[0089] Changing a specific chain that is locked to reflect the changed state of a specific database object; and

[0090] After the update, unlock the specific chain.

[0091] 2. The method of embodiment 1, wherein changing the locked specific chain includes adding the specific database object to the chain.

[0092] 3. The method of embodiment 1, wherein changing the locked particular chain comprises removing the particular database object from the chain.

[0093] 4. The method of embodiment 1, wherein the ordering of the database objects stored in the cache is based at least in part on the relative frequencies of use of the database objects.

[0094] 5. The method of embodiment 1, further comprising: in response to determining by the computer system that a new chain is to be added to the chain set:

[0095] Lock chain set;

[0096] Adding new chains to the chain set; and

[0097] Unlock chain set.

[0098] 6. The method of embodiment 5, further comprising: in response to determining that the number of chains included in the chain set is greater than a threshold, performing, by the computer system, a garbage collection operation on the chain set.

[0099] 7. A non-transitory computer-readable medium having programming instructions stored thereon, the programming instructions being capable of causing a computer system to perform operations comprising: maintaining, by the computer system, a chain set having a plurality of chains, wherein each chain in the plurality of chains specifies an ordering of database objects stored in a cache;

[0100] The computer system monitors the respective states of the plurality of database objects;

[0101] In response to determining that a state of the particular database object has changed, selecting, by the computer system, a particular chain of the plurality of chains corresponding to the particular database object; and

[0102] Updating a particular chain by a computer system without preventing other chains in a plurality of chains from being accessed during the updating, wherein the updating comprises:

[0103] Lock a specific chain;

[0104] Changing a specific chain that is locked to reflect the changed state of a specific database object; and

[0105] After the update, unlock the specific chain.

[0106] 8. The non-transitory computer-readable storage medium of embodiment 7, wherein changing the locked specific chain comprises adding the specific database object to the chain.

[0107] 9. The non-transitory computer-readable storage medium of embodiment 7, wherein changing the locked particular chain comprises removing the particular database object from the chain.

[0108] 10. The non-transitory computer-readable storage medium of embodiment 7, wherein the ordering of the database objects stored in the cache is based at least in part on the relative frequency of use of the database objects.

[0109] 11. The non-transitory computer-readable storage medium of embodiment 7, further comprising: in response to determining by the computer system that a new chain is to be added to the chain set:

[0110] Lock chain set;

[0111] Adding new chains to the chain set; and

[0112] Unlock chain set.

[0113] 12. The non-transitory computer-readable storage medium of embodiment 11, further comprising: in response to determining that the number of chains included in the chain set is greater than a threshold, performing, by the computer system, a garbage collection operation on the chain set.

[0114] 13. A non-transitory computer-readable storage medium according to embodiment 7, wherein a first chain in the plurality of chains specifies an ordering of a first plurality of database objects in a set of database objects associated with a set of identifiers introduced by a first release of the software application, and wherein a second chain in the plurality of chains specifies an ordering of a second plurality of database objects in a set of database objects associated with another set of identifiers introduced by the first release or the second release of the software application.

[0115] 14. A computer system comprising:

[0116] one or more memories, the one or more memories storing instructions during operation, and

[0117] One or more computing resources that, during operation, receive instructions from the one or more memories and execute the instructions to cause the computer system to perform operations, the operations comprising:

[0118] Maintaining, by a computer system, a chain set having a plurality of chains, wherein each chain in the plurality of chains specifies an ordering of database objects stored in a cache;

[0119] The computer system monitors the respective states of the plurality of database objects;

[0120] In response to determining that a state of the particular database object has changed, selecting, by the computer system, a particular chain of the plurality of chains corresponding to the particular database object; and

[0121] Updating a particular chain by a computer system without preventing other chains in a plurality of chains from being accessed during the updating, wherein the updating comprises:

[0122] Lock a specific chain;

[0123] Changing a specific chain that is locked to reflect the changed state of a specific database object; and

[0124] After the update, unlock the specific chain.

[0125] 15. The computer system of embodiment 14, wherein changing the locked specific chain includes adding the specific database object to the chain.

[0126] 16. The computer system of embodiment 14, wherein changing the locked particular chain comprises removing the particular database object from the chain.

[0127] 17. The computer system of embodiment 14, wherein the ordering of database objects stored in the cache is based at least in part on relative frequencies of use of the database objects.

[0128] 18. The computer system of embodiment 14, further comprising: in response to determining by the computer system that a new chain is to be added to the chain set:

[0129] Lock chain set;

[0130] Adding new chains to the chain set; and

[0131] Unlock chain set.

[0132] 19. The computer system of embodiment 18, further comprising: in response to determining that the number of chains included in the chain set is greater than a threshold, performing, by the computer system, a garbage collection operation on the chain set.

[0133] 20. A computer system according to embodiment 14, wherein a first chain in the plurality of chains specifies an ordering of a first plurality of database objects in a set of database objects associated with a set of identifiers introduced by a first release of the software application, and wherein a second chain in the plurality of chains specifies an ordering of a second plurality of database objects in a set of database objects associated with another set of identifiers introduced by the first release or the second release of the software application.

[0134] Although specific embodiments have been described above, these embodiments are not intended to limit the scope of the disclosure, even if only a single embodiment is described with respect to a particular feature. The examples of features provided in the disclosure are intended to be illustrative and not restrictive unless otherwise indicated. The above description is intended to cover such alternatives, modifications, and equivalents as may be apparent to those skilled in the art having the benefit of the disclosure.

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

Claims

1. A method comprising: Maintaining, by a computer system, a chain set having a plurality of chains, wherein each chain in the plurality of chains specifies an ordering of database objects stored in a cache; monitoring, by the computer system, respective states of a plurality of database objects; In response to determining that a state of a particular database object has changed, selecting, by the computer system, a particular chain of the plurality of chains corresponding to the particular database object, wherein selecting the particular chain of the plurality of chains is based on a version of an application that utilizes the particular database object; and Updating, by the computer system, the particular chain without preventing other chains of the plurality of chains from being accessed during the updating, wherein the updating comprises: locking said specific chain; changing the locked particular chain to reflect the changed state of the particular database object; and After the update, the specific chain is unlocked. 2 . The method of claim 1 , wherein changing the locked specific chain comprises adding the specific database object to the chain. 3 . The method of claim 1 , wherein changing the locked particular chain comprises removing the particular database object from the chain. The method of claim 1 , wherein the ranking of database objects stored in the cache is based at least in part on relative frequencies of use of the database objects.

5. The method of claim 1 , further comprising, in response to determining by the computer system that a new chain is to be added to the chain set: locking the chain set; adding the new chain to the chain set; and Unlocks the chain set. 6 . The method of claim 5 , further comprising performing, by the computer system, a garbage collection operation on the chain set in response to determining that the number of chains included in the chain set is greater than a threshold.

7. A non-transitory computer-readable storage medium having stored thereon programming instructions, the programming instructions being capable of causing a computer system to perform operations, the operations comprising: maintaining, by the computer system, a chain set having a plurality of chains, wherein each chain in the plurality of chains specifies an ordering of database objects stored in a cache; monitoring, by the computer system, respective states of a plurality of database objects; In response to determining that a state of a particular database object has changed, selecting, by the computer system, a particular chain of the plurality of chains corresponding to the particular database object, wherein selecting the particular chain of the plurality of chains is based on a version of an application that utilizes the particular database object; and Updating, by the computer system, the particular chain without preventing other chains of the plurality of chains from being accessed during the updating, wherein the updating comprises: locking said specific chain; changing the locked particular chain to reflect the changed state of the particular database object; and After the update, the specific chain is unlocked. 8 . The non-transitory computer-readable storage medium of claim 7 , wherein changing the locked particular chain comprises adding the particular database object to the chain. 9 . The non-transitory computer-readable storage medium of claim 7 , wherein changing the locked particular chain comprises removing the particular database object from the chain. 10 . The non-transitory computer-readable storage medium of claim 7 , wherein the ranking of database objects stored in the cache is based at least in part on relative frequencies of use of the database objects.

11. The non-transitory computer-readable storage medium of claim 7, wherein the operations further comprise, in response to a determination by the computer system that a new chain is to be added to the chain set: locking the chain set; adding the new chain to the chain set; and Unlocks the chain set. 12 . The non-transitory computer-readable storage medium of claim 11 , wherein the operations further comprise performing, by the computer system, a garbage collection operation on the chain set in response to determining that the number of chains included in the chain set is greater than a threshold.

13. The non-transitory computer-readable storage medium of claim 7 , wherein a first chain in the plurality of chains specifies an ordering of a first plurality of database objects in a set of database objects associated with a set of identifiers introduced by a first release of a software application, and wherein a second chain in the plurality of chains specifies an ordering of a second plurality of database objects in a set of database objects associated with another set of identifiers introduced by the first release or a second release of the software application.

14. A computer system comprising: one or more memories that store instructions during operation; and one or more computing resources that, during operation, receive instructions from the one or more memories and execute the instructions to cause the computer system to perform operations comprising: maintaining, by the computer system, a chain set having a plurality of chains, wherein each chain in the plurality of chains specifies an ordering of database objects stored in a cache; monitoring, by the computer system, respective states of a plurality of database objects; In response to determining that a state of a particular database object has changed, selecting, by the computer system, a particular chain of the plurality of chains corresponding to the particular database object, wherein selecting the particular chain of the plurality of chains is based on a version of an application that utilizes the particular database object; and Updating, by the computer system, the particular chain without preventing other chains of the plurality of chains from being accessed during the updating, wherein the updating comprises: locking said specific chain; changing the locked particular chain to reflect the changed state of the particular database object; and After the update, the specific chain is unlocked.

15. The computer system of claim 14, wherein changing the locked particular chain comprises adding the particular database object to the chain.

16. The computer system of claim 14, wherein changing the locked particular chain comprises removing the particular database object from the chain.

17. The computer system of claim 14, wherein the ranking of database objects stored in the cache is based at least in part on relative frequencies of use of the database objects.

18. The computer system of claim 14, wherein the operations further comprise, in response to a determination by the computer system that a new chain is to be added to the chain set: locking the chain set; adding the new chain to the chain set; and Unlocks the chain set.

19. The computer system of claim 18, wherein the operations further comprise performing, by the computer system, a garbage collection operation on the chain set in response to determining that the number of chains included in the chain set is greater than a threshold.

20. The computer system of claim 14, wherein a first chain in the plurality of chains specifies an ordering of a first plurality of database objects in a set of database objects associated with a set of identifiers introduced by a first release of a software application, and wherein a second chain in the plurality of chains specifies an ordering of a second plurality of database objects in a set of database objects associated with another set of identifiers introduced by either the first release or the second release of the software application.

Citation Information

Patent Citations

  • Multi-tiered caching mechanism for the storage and retrieval of content multiple versions

    CN1774703A

  • Cached data replication for cache recovery

    US20160328301A1