Detecting function chains that violate constraints

By introducing UDF chain tracking structures and monitor processes into the database system, lengthy or circular function chains are detected and blocked, resource contention and deadlock problems are solved, and the latest data members are achieved by caching shared package data members. Value access improves the efficiency and accuracy of database operations.

CN117520387BActive Publication Date: 2024-10-18HEWLETT PACKARD ENTERPRISE DEV LP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211302322.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-24
Publication Date
2024-10-18
Estimated Expiration
2042-10-24

AI Technical Summary

Technical Problem

It is difficult for the existing technology to effectively detect and block lengthy function nesting chains and function loop chains, leading to resource contention and deadlock problems, and there are erroneous results in shared access to package data members.

Method used

By introducing the UDF chain tracking structure into the database system, the monitor process analyzes the key-value pairs in the tracking structure regularly or in response to events, determines whether the function chain violates length and cycle constraints, and blocks calls when constraints are violated to ensure the effectiveness of resources. Utilize, while ensuring data consistency by caching shared package data members.

Benefits of technology

Effectively detect and block lengthy function chains and circular chains, avoid resource contention and deadlocks, ensure that the latest values ​​of data members can be accessed by relevant functions, and improve the efficiency and accuracy of database operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117520387B_ABST
    Figure CN117520387B_ABST
Patent Text Reader

Abstract

The present disclosure relates to detecting chains of functions that violate constraints. In some examples, a system determines whether a chain of functions violates a constraint based on: accessing a tracking structure populated with entries when a corresponding server process started during execution of a database operation calls a function, wherein each entry in the tracking structure identifies a corresponding called function associated with a corresponding program instance; and using the tracking structure to detect related functions that form the chain, wherein the related functions are identified as related if they are associated with the same program instance. In response to determining that the chain of functions violates the constraint, the system blocks calling additional functions to be added to the chain.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates generally to the field of databases. Background Art

[0002] A database query may be submitted to a database system to perform operations on the relational tables of the database system. Examples of database queries include Structured Query Language (SQL) queries. Summary of the invention

[0003] One of the exemplary aspects of the present disclosure relates to a non-transitory machine-readable storage medium, comprising instructions that, when executed, cause a system to perform the following operations: determine whether a chain of functions violates a constraint based on the following items: access a tracking structure filled with entries when a corresponding server process (process) started during the execution of a database operation calls the function, wherein each entry in the entries of the tracking structure identifies a corresponding called function associated with a corresponding program instance, and use the tracking structure to detect related functions forming the chain, if the related functions are associated with the same program instance, the related functions are identified as related; and in response to determining that the chain of functions violates the constraint, block calling another function to be added to the chain. BRIEF DESCRIPTION OF THE DRAWINGS

[0004] Some embodiments of the disclosure are described with respect to the following figures.

[0005] Figure 1 is a block diagram of a distributed system including a database manager, a UDF server process for executing corresponding user-defined functions (UDFs), and a monitor process according to some examples.

[0006] Figure 2 Illustrated is a nested chain of UDFs violating length constraints according to some examples.

[0007] Figure 3 A UDF loop chain according to some examples is illustrated.

[0008] Figure 4 is a flow chart of a process for detecting constraint violations according to some examples.

[0009] Figure 5 is a block diagram of a storage medium storing machine-readable instructions according to some examples.

[0010] Figure 6 is a block diagram of a distributed system according to some examples.

[0011] Figure 7 is a flow chart of a process according to a further example.

[0012] Throughout the drawings, the same reference numerals refer to similar, but not necessarily identical, elements. The drawings are not necessarily drawn to scale, and the dimensions of some parts may be exaggerated to more clearly illustrate the examples shown. In addition, the drawings provide examples and / or implementations consistent with the description; however, the description is not limited to the examples and / or implementations provided in the drawings. DETAILED DESCRIPTION

[0013] Database queries submitted to the database system for processing may call various functions to perform corresponding specified tasks. In some examples, the functions that may be triggered may include user defined functions (UDF). "UDF" may refer to a function developed by a user (or user group) or another entity such as a program or machine, which is not part of a database programming language (e.g., structured query language (SQL)), but can be customized to perform specific actions on data.

[0014] In other examples, the function that can be triggered can include a native function of a database programming language (e.g., SQL). The native function can perform a predefined task, such as a function that sums values, a function that calculates the average of values, etc.

[0015] A database query may call a first function (e.g., a first UDF), which in turn may call a second function (e.g., a second UDF), which in turn may call a third function (e.g., a third UDF), and so on. A function being called by another function is called a nested function call. The length of the nested function call can be any length.

[0016] In some cases, a function nesting chain may include a function loop, where the function nesting chain starts with a first function and has another function that calls the first function. A function nesting chain including a function loop is referred to as a function loop chain.

[0017] In a system that executes functions, the presence of lengthy function nested chains or function loop chains may lead to resource contention. Examples of resources that are subject to contention due to the execution of function nested chains include any one or some combination of the following: processing resources (e.g., hardware processors, multiple hardware processors, cores of multi-core processors, multiple cores of multi-core processors, etc.), storage resources (e.g., memory, disk-based storage devices, solid-state drives, etc.), and / or communication resources (network interface controllers, switches or routers, etc.). In addition, resources may include virtual resources, such as virtual machines, containers, etc.

[0018] Additionally, database operations performed in response to database queries may modify data in a table, which may include rows. When a row in a table is modified (e.g., a row is inserted, a row is deleted, or a row is updated), a lock may be placed on the row being modified. Executing a function loop chain of row modifications that results in a lock being placed on a row may result in a deadlock, where a lock placed on a table row may prevent a function in the function loop chain from performing further processing.

[0019] According to some embodiments of the present disclosure, techniques or mechanisms are provided for detecting the presence of lengthy function nested chains (a "lengthy" function nested chain is a chain that includes more than a specified number of functions) and / or function loop chains. In response to detecting a lengthy function chain or a function loop chain, the system can prevent further addition of functions to be added to the chain.

[0020] A further problem associated with function nesting chains is that data members associated with a package may not be shared by functions in the function nesting chain. A "package" may be defined by package data, which identifies data members that are part of the package and the UDFs in the package. The package data is in the form of a data structure with a specified format. A "data member" may refer to any variable or parameter. If a data member of a package (or more specifically, the latest value of a data member) is not available to any UDF in the package, the UDFs in the UDF nesting chain may produce incorrect results, such as when calculating based on an old version of the data member. According to some embodiments of the present disclosure, related functions of a package may share access to data members that are part of a package. In some examples, data members of a package may be stored in a cache for sharing by related functions.

[0021] Figure 1 1 is a block diagram of a distributed system 102 in which database operations may be performed. A "distributed system" refers to a system having multiple computing nodes, where each "computing node" may refer to a computer, a processor, a core of a multi-core processor, or any other type of processing circuit. Distributed system 102 is a distributed database system capable of accessing data in response to database queries.

[0022] The distributed system 102 includes a database management system (DBMS) program 104 that can process database queries such as SQL queries. SQL refers to a database programming language that allows management of data stored in a relational database management system (RDBMS). In other examples, database queries based on other languages ​​can be used.

[0023] The DBMS program 104 includes a database query compiler 106 that can parse a database query 108 into a query plan 110. For example, a database query may include SQL statements that may be submitted separately by a requester or may be part of a package of SQL statements. The query plan 110 generated by the database query compiler 106 may include a set of instructions that describe various tasks to be performed for the database operation invoked by the database query 108.

[0024] In some examples, a coordinator process 112 may be initiated in the distributed system 102 to perform database operations according to the query plan 110. For example, the coordinator process 112 may be used to coordinate resource usage of the distributed system 102. Resources may include processing resources, storage resources, and / or communication resources. The coordinator process 112 may initiate various auxiliary processes 113 to perform specific tasks associated with the database operations of the query plan 110.

[0025] A "helper process" may refer to a process in the distributed system 102 that performs tasks delegated to the helper process by the coordinator process 112. Multiple helper processes 113 may be executed in parallel, such as on different processors or processor cores. In other examples, the coordinator process 112 does not use a helper process.

[0026] In some examples, a function may be triggered to perform a corresponding action as part of a query plan 110. In some examples, the triggered function may include a UDF or a native function.

[0027] Functions, including UDFs and / or native functions, can perform any of a variety of different types of actions on data, such as calculating mathematical calculations on data values, generating output values ​​based on various input data values, determining whether a data value meets a criteria, and the like.

[0028] In some cases, there may be nested calls of functions. For example, a first UDF may be called by a trigger as part of a database query, the first UDF may call a second UDF, the second UDF may call a third UDF, and so on. Figure 2 An example is shown in which 7 UDFs are called one after another in a UDF nesting chain. Figure 2In the example of , a trigger 202 in a database query calls a first UDF 204, which calls a second UDF 206, which calls a third UDF 208, which calls a fourth UDF 210, which calls a fifth UDF 212, which calls a sixth UDF 214, and which calls a seventh UDF 216. The length of the nested calls of UDFs can be any length. Figure 2 In the example, the length of the UDF nesting chain is 7 (7 UDFs are called).

[0029] A "trigger" in a database query may refer to any part (eg, clause, predicate, etc.) of a function such as a UDF or native function that calls a database query.

[0030] Figure 3 An example of a UDF loop chain is shown in Figure 3 In the example of , trigger 302 calls first UDF 304, which calls second UDF 306, which calls third UDF 308, and the third UDF calls first UDF 304. Since third UDF 308 calls first UDF 304, Figure 3 The nested chain of UDFs shown forms a UDF loop.

[0031] In the distributed system 102, the existence of a lengthy function nesting chain (a function chain whose length exceeds a length threshold) or a function loop chain may cause resource contention. In some examples, a UDF server process is started to execute the corresponding UDF. For example, Figure 1 A UDF server process 116-A for executing UDF A, a UDF server process 116-B for executing UDF B, ..., and a UDF server process 116-X for executing UDF X are shown. The multiple UDF server processes 116-A to 116-X may compete for resources 114 of the distributed system 102. The resources 114 may include any one or some combination of processing resources, storage resources, communication resources, virtual resources, etc.

[0032] Each UDF server process 116-A, 116-B ... 116-X defines an isolated computing environment for executing the corresponding UDF. Thus, for example, UDF A executed in UDF server process 116-A is isolated from UDF B executed in UDF server process 116-B. Each UDF server process can be implemented as a Java virtual machine (JVM), a container, or any other virtual environment. Each invocation of a given UDF (whether by a trigger in a database query or by another UDF) results in another invocation of the given UDF by the corresponding UDF server process.

[0033] Resource contention among the UDF server processes 116 -A through 116 -X may result in inefficient execution of database operations involving execution of the respective UDFs A through X. For example, if a resource requested by a first UDF server process is unavailable or heavily utilized due to execution of a second UDF server process, the first UDF server process may not be able to execute its respective UDF in a timely manner.

[0034] According to some embodiments of the present disclosure, in order to support the detection of lengthy UDF nested chains or UDF loop chains, the UDF chain tracking structure 122 can be stored in the cache 120. A "cache" can be implemented using a collection of memory devices (a single memory device or multiple memory devices). In some examples, the cache 120 may include a remote dictionary server (Redis) that provides an open source protocol for in-memory data structure storage of in-memory key-value pairs. In other examples, the cache 120 may store data according to other formats or protocols.

[0035] The UDF chain tracking structure 122 includes entries that each identify a corresponding UDF in a nested chain of UDFs. The UDF chain tracking structure 122 is associated with a corresponding program instance, which is an instance of a program such as an application, a utility, or another type of program. If the distributed system 102 is performing database operations on multiple program instances (the multiple program instances may be different instances of the same program or instances of different programs), the cache 120 may store multiple UDF chain tracking structures associated with different program instances. In other examples, one UDF chain tracking structure 122 may be used to store entries for multiple program instances.

[0036] The entries of the UDF chain tracking structure 122 are populated as UDFs are called and their corresponding UDF server processes (e.g., 116-A to 116-X) are started during the execution of database operations. The UDF chain tracking structure 122 contains information about related UDFs, where UDFs are related if they are associated with the same program instance (e.g., are called in response to the same program instance).

[0037] In some examples, monitor process 124 (including machine-readable instructions) can monitor UDF chain tracking structure 122 to determine whether a nested chain of UDFs violates a constraint.

[0038] In some examples, the monitor process 124 is separate from the UDF server processes 116-A to 116-X, the coordinator process 112, and the auxiliary process 113. In other examples, the monitor process 124 (or multiple instances of the monitor process 124) can be part of any one or more of the UDF server processes 116-A to 116-X and / or any one or more of the coordinator process 112 and / or the auxiliary process 113.

[0039] A UDF nesting chain violates the constraint if one or both of the following exist: (1) the length of the UDF nesting chain exceeds the specified length (where the "length" of a function nesting chain is equal to the number of functions in the function nesting chain), or (2) the UDF nesting chain (or more generally, the function nesting chain) is cyclic.

[0040] In the above, constraints include length constraints and loop constraints. As used herein, the term "constraint" may refer to a single constraint or multiple constraints.

[0041] Monitor UDF nested chains for constraint violations

[0042] refer to Figure 1 and Figure 4 , depicts processes performed by components of distributed system 102.

[0043] In response to a call to a given UDF ("UDF k," where k is one of A, B, ... X) by a UDF server process (one of 116-A through 116-X), the UDF server process may record (at 402) a key-value pair of the called UDF k in the UDF chain tracking structure 122. The UDF server process may call UDF k in response to a call made by a database query or a call in another UDF.

[0044] The UDF chain tracking structure 122 has multiple entries, each of which contains corresponding key-value pairs, such as Figure 1 KV1, KV2…KVN (N≥2) depicted in Figure 1 Entries of the UDF chain tracking structure 122 are shown containing corresponding key-value pairs, but in other examples, entries of the UDF chain tracking structure 122 may contain data related to different forms of UDFs.

[0045] The key-value pairs in the entries of the UDF chain tracking structure 122 contain a key and an associated value. The key contains a program instance value that identifies the program instance associated with the call of the UDF. The program instance value may be in the form of a process ID. As an example, a program P may issue a database query in a UDF nested chain, which triggers the call of a first UDF, which in turn calls a second UDF, which in turn calls a third UDF, and so on. The UDF k in the above example may be one of the UDFs in the UDF nested chain.

[0046] The key may also contain a UDF identification value, which is used to identify the UDF k-1 that calls UDF k. The value of the key-value pair is the UDF identification value, which is used to identify the called UDF k.

[0047] As an example, the key-value pairs added to the UDF chain tracking structure 122 in response to invoking UDF k may be in the following form:

[0048] {key=100INT(k-1), value=INT(k)}.

[0049] In the above example key-value pairs, INT(k) is the UDF identification value of the called UDF k, 100 is the process ID of the program instance, and INT(k-1) is the UDF identification value of UDF k-1 that calls UDF k. In some examples, the process ID (such as 100) can be a random number or any other value that can uniquely identify the program instance. The UDF identification value can also be a random number or any other value that can uniquely identify the UDF.

[0050] Note that if UDF k is called by a trigger in a database query instead of another UDF, the key of the key-value pair added to call UDF k may include some predefined value indicating that the calling entity is a trigger instead of another UDF.

[0051] Because the UDF is invoked by the corresponding UDF server process associated with the program instance having process ID 100 , a corresponding key-value pair is added to the entry of the UDF chain structure 122 , where each key in the key-value pair tracks the included process ID 100 .

[0052] The monitor process 124 may determine (at 404) whether the UDF nested chain violates the length constraint. In some examples, the monitor process 124 may analyze the key-value pairs in the entries of the UDF chain tracking structure 122 periodically (e.g., once every specified time interval) or in response to another event (e.g., detection of high resource usage, detection of a slowdown in database operations of the distributed system 102, etc.). In such examples, the monitor process 124 determines whether the UDF nested chain represented by the set of key-value pairs in the entries of the UDF chain tracking structure 122 violates the length constraint.

[0053] The monitor process 124 may determine whether the length of the UDF nested chain represented by the set of key-value pairs violates a length constraint (i.e., the length is at or greater than a length threshold). The monitor process 124 may retrieve an entry from the UDF chain tracking structure 122 containing a key with a public process ID (used to identify a given program instance). The monitor process 124 may determine the length of the UDF nested chain based on the key-value pairs in the retrieved entry, where the length is determined by identifying which UDFs call other UDFs based on the key-value pairs. An example set of key-value pairs retrieved from the UDF chain tracking structure 122 is provided below:

[0054] {key=100INT(1), value=INT(2)},

[0055] {key=100INT(2), value=INT(3)},

[0056] {key=100INT(3), value=INT(4)},

[0057] {key=100INT(4), value=INT(5)},

[0058] {key=100INT(5), value=INT(6)},

[0059] {key=100INT(6), value=INT(7)}.

[0060] The above key-value pair set indicates that the UDF with the UDF identifier value INT(1) calls the UDF with the UDF identifier value INT(2), the UDF with the UDF identifier value INT(2) calls the UDF with the UDF identifier value INT(3), and so on.

[0061] Based on the key-value pairs in the entries of the UDF chain tracking structure 122, the monitor process 124 can determine that the length of the UDF chain (from INT(1) to INT(7)) is 7. If the length threshold is 6 (for example), the monitor process 124 can detect that the UDF nested chain in the above example is at the length threshold, and therefore, the UDF nested chain violates the length constraint.

[0062] Note that even if the length threshold is 7 in the above example, the monitor process 124 will still determine that a UDF nesting chain of length 7 violates the length constraint because adding additional UDFs to the UDF nesting chain would cause the length threshold to be exceeded.

[0063] In response to determining that the UDF nested chain violates the length constraint, the monitor process 124 adds (at 406) a "sentinel" key-value pair 126 to the entry of the UDF chain tracking structure 122. The sentinel key-value pair 126 provides a violation indication that the UDF nested chain violates the constraint. The key of the sentinel key-value pair 126 includes a program instance value (e.g., 100 in the above example), and the value of the sentinel key-value pair 126 includes a specified value (e.g., some predefined number or string) indicating that the UDF nested chain violates the constraint.

[0064] In some examples, before invoking a new UDF, the UDF server process can check for the sentinel key-value pair 126 by reading the UDF chain tracking structure 122. The UDF server process can search for the presence of the sentinel key-value pair 126 in the UDF chain tracking structure 122, such as by searching for a specified value or searching for a flag or other special header that indicates an entry that contains a sentinel key-value pair.

[0065] If the UDF server process determines that the sentinel key-value pair 126 exists, the UDF server process may block calling another UDF associated with the same program instance (eg, the program instance with process ID 100).

[0066] although Figure 1 The UDF chain tracking structure 122 is shown with one sentinel key-value pair 126 , but in other examples, the monitor process 124 may have added multiple sentinel key-value pairs to the UDF chain tracking structure 122 to indicate corresponding UDF nested chains that violate constraints.

[0067] The foregoing mentions an example where the monitor process 124 analyzes entries of the UDF chain tracking structure 122 periodically or in response to another event. In some cases, it is possible that when the trace monitor process 124 analyzes entries of the UDF chain structure 122, the length of the UDF nested chain may be greater than a length threshold.

[0068] In other examples, the monitor process 124 may determine (at 404) whether the UDF nesting chain violates a length constraint in response to a request to call another UDF for a program instance (e.g., a program instance with process ID 100). In such an example, the monitor process 124 may be part of a UDF server process, and the monitor process 124 in the UDF server process may check the entries of the UDF chain tracking structure 122 in response to the request to call another UDF (and before calling the other UDF) to determine whether adding the other UDF to the UDF nesting chain will violate the length constraint. If not, the UDF server process may allow the other UDF to be called. However, if adding the other UDF to the UDF nesting chain will violate the length constraint, the UDF server process will block calling the other UDF. In addition, if adding the other UDF to the UDF nesting chain will violate the length constraint, the monitor process 124 adds (at 406) a sentinel key-value pair 126 to the UDF chain tracking structure 122.

[0069] Similarly, the monitor process 124 in the UDF server process can prevent the occurrence of a UDF circular chain. The monitor process 124 determines (at 408) whether adding an additional UDF in response to a request to call a UDF violates a circular constraint. To do this, the monitor process 124 retrieves a key-value pair from the UDF chain tracking structure 122 and determines an existing UDF nested chain.

[0070] Another example set of key-value pairs obtained from the UDF chain tracking structure 122 is provided below:

[0071] {key=100INT(1), value=INT(2)},

[0072] {key=100INT(2), value=INT(3)}.

[0073] The existing UDF nesting chain in this example is INT(1)->INT(2)->INT(3).

[0074] Another UDF may have a UDF identification value of INT(1) and may be called by a UDF with a UDF identification value of INT(3). Adding this additional UDF to the UDF nesting chain will cause a UDF loop because the UDF chain will start at INT(1) and end at INT(1), which violates the loop constraint.

[0075] If adding another UDF to the existing UDF nesting chain will cause a loop, the monitor process 124 will provide (at 410) a loop constraint violation indication, which causes the UDF server process to block calling the other UDF. The loop call of the UDF can be detected by the UDF server process before it occurs because the UDF server process knows the UDF identification value of the UDF to be called, and based on the reconstructed existing UDF nesting chain, the UDF server process can detect the loop.

[0076] If neither the length constraint nor the loop constraint is violated, calling another UDF is allowed.

[0077] Shared access to package data members

[0078] According to some embodiments of the present disclosure, UDFs in a nested chain of UDFs associated with the same program instance may share access to data members of a package that also identifies related UDFs that are part of the package. Data members of a package modified by any UDF of the package may be visible to other (multiple) UDFs of the package.

[0079] Figure 1 A packet data structure 130 is shown stored in cache 120. In some examples, packet data structure 130 includes entries with key-value pairs corresponding to data members of the packet. The data members include data members DM1, DM2 ... DMP (P ≥ 2). More generally, a packet may include only a single data member or multiple data members.

[0080] Each key-value pair of the package data structure 130 includes a key including the name of a data member and a value which is the current value of the data member identified by the key. The key may also include an identifier of the package. Thus, in the example, the key in each key-value pair in the package data structure 130 includes an identifier of the package and the name of the corresponding data member. In the package data structure 130, KV-DM1 is a key-value pair for data member DM1, KV-DM2 is a key-value pair for data member DM2, and KV-DMP is a key-value pair for data member DMP.

[0081] In an example, UDF A executed by UDF server process 116 -A may modify the value of data member DMP in package data structure 130 , and once the value of data member DMP is modified by UDF A, UDF B and UDF X may access the modified value.

[0082] The UDF server processes that execute the corresponding UDFs may run on different computing nodes of the distributed system 102. The cache 120 is a distributed cache that can be accessed by the UDF server processes across different computing nodes.

[0083] When a new UDF of a package is called resulting in the creation of a new UDF server process, the relevant data members DM1 to DMP of the package can be accessed by the new UDF.

[0084] If the package does not include a large number of data members (for example, the number of data members is less than a number threshold, such as less than 50, or less than 40, or less than 30, or less than 20, or less than 10, or less than 5, etc.), the package data structure 130 may include as many key-value pairs as the data members. When a data member is modified, the corresponding key-value pair is also modified accordingly, so that all related UDFs of the package can see the latest data member value.

[0085] In some cases, a data member is updated only once and becomes read-only after the update. In this case, the key-value pair of the data member remains unchanged and can be looked up using the key in the key-value pair.

[0086] In other examples, a pack may include a large number of data members (e.g., the number of data members is greater than a number threshold, such as greater than 100, or greater than 50, or greater than 40, or greater than 30, or greater than 20, or greater than 10, or greater than 5, etc.) In such examples, the data members may be serialized into a data representation, which allows the data members to be retrieved in a more efficient manner than storing separate key-value pairs separately in a single entry of the pack data structure 130.

[0087] For example, data members can be serialized into a data member array, a data member tree, etc. A data member array or a data member tree is an example of a packet data structure 130. Different entries of a data member array can be indicated by different offsets in the array. In such an example, each entry of the array includes the value of the corresponding data member. The "key" for accessing an entry can be the offset of the entry. In a further example, if the packet data structure 130 includes a data member tree, the nodes of the tree contain the values ​​of the corresponding data members, and the "key" is the index of the node.

[0088] In other examples, the data member may include a large object. The size of the large object may be greater than a size threshold, for example, greater than 1 million bytes (MB), or greater than 5MB, or greater than 10MB, or greater than 50MB, or greater than 100MB, etc. A UDF that updates a large object may update only a small portion of the large object (e.g., a small number of bytes). The UDF may send only a small portion of the update to the cache 120 to update the corresponding portion of the packet data structure 130 in the cache 120. In this way, the large object can be efficiently updated appropriately in the cache 120, so that the UDF that updates the large object does not have to send the entire updated large object to the packet data structure 130 in the cache 120.

[0089] Further examples

[0090] Figure 5 is a block diagram of a non-transitory machine-readable or computer-readable storage medium 500 having stored thereon machine-readable instructions that, when executed, cause a system (e.g., Figure 1 A distributed system 102) performs various tasks.

[0091] The machine readable instructions include constraint violation determination instructions 502 for determining whether a function chain violates a constraint, including a length constraint and / or a loop constraint.

[0092] The constraint violation determination instructions 502 include tracking structure access instructions 504 for accessing a tracking structure populated with entries when a corresponding server process invokes a function initiated during execution of a database operation. Each entry in the tracking structure identifies a corresponding invoked function associated with a corresponding program instance. An example of a tracking structure is Figure 1 The UDF chain tracking structure 122. Functions can be UDFs and / or native functions.

[0093] The constraint violation determination instructions 502 include related function detection instructions 506 for detecting related functions forming a function chain using a trace structure, and related functions are determined to be related if the related functions are associated with the same program instance.

[0094] Machine readable instructions include other function call blocking instructions 508, which are used for blocking the calling of other functions to be added to the chain in response to determining that the function chain violates constraints. For example, the constraint can be a length constraint and / or a loop constraint. If the chain including the relevant function indicated by the tracking structure is at or exceeds a length threshold, other function call blocking instructions 508 can block calling other functions. If adding other functions will cause the function chain to exceed the length threshold, other function call blocking instructions 508 can block calling other functions. If adding other functions will cause the function cycle in the function chain, other function call blocking instructions 508 can block calling other functions.

[0095] In some examples, each of the entries of the trace structure includes a program instance value (eg, a process ID) identifying a corresponding program instance, wherein related functions are identified as related using the program instance value in the trace structure.

[0096] In some examples, different program instance values ​​in the tracking structure identify different program instances for which the function was called.

[0097] In some examples, a violation indication entry (eg, Figure 1 Sentinel key-value pairs 126).

[0098] In some examples, the related functions are part of a package, which further includes data members accessible to the related functions.

[0099] In some examples, the machine-readable instructions store the data member in a package data structure in a cache to share the data member between related functions executing in a corresponding server process.

[0100] In some examples, the data members are stored in the package data structure as key-value pairs, each of the key-value pairs in the package data structure including a key including an identifier of the package and a value representing a corresponding one of the data members.

[0101] In some examples, the key-value pairs in the pack data structure are arranged as a node tree in the cache, and each node of the tree is identified by an index and represents a corresponding data member value.

[0102] In some examples, the key-value pairs in the pack data structure are arranged as an array in the cache, and each entry of the array is identified by an offset and represents a corresponding data member value.

[0103] Figure 6 is a block diagram of a distributed system 602 according to a further example. The distributed system 602 includes a cache 604 for storing a tracking structure 606. An example of the tracking structure 606 is Figure 1 The UDF chain tracking structure 122.

[0104] The distributed system 602 includes a plurality of computing nodes 608 for executing respective server processes 610, 620 that call respective functions 612, 622 for database operations. Examples of the server processes 610 include Figure 1 The UDF server processes 116-A to 116-X of FIG. 612 may be UDFs and / or native functions.

[0105] In response to first server process 610 calling first function 612, first server process 610 adds first entry 614 to tracking structure 606 in cache 604. First entry 614 identifies a program instance associated with first function 612 and includes an identifier of first function 612.

[0106] Distributed system 602 includes a monitor process 616 for analyzing entries of tracking structure 606 to determine whether a function chain called for a program instance violates a constraint. The entries include a first entry 614 and a second entry 618, wherein the second entry identifies a program instance associated with a second function 622 and includes an identifier of the second function 622.

[0107] Figure 7is a flow chart of a process 700 according to some examples, which may be performed by a distributed system (e.g., Figure 1 102 or Figure 6 602) in execution.

[0108] Process 700 includes calling (at 702) a method for executing a command in multiple server processes (e.g., Figure 1 The first UDF in the first server process may call a second UDF for execution in a second server process. Each corresponding server process in the plurality of server processes defines an isolated computing environment for executing the corresponding UDF.

[0109] Process 700 further includes, when the UDF is called and executed by the server process, sending the UDF to the cache (e.g., Figure 1 120) in the tracking structure (e.g., Figure 1 The method further comprises adding (at 704) key-value pairs to an entry of a UDF chain tracking structure 122 of the first server process, wherein each respective one of the key-value pairs includes a key identifying a program instance associated with the corresponding UDF and a value identifying the corresponding UDF. The key may include a process ID of the program instance, and an identifier of the UDF. Adding the key-value pairs to the tracking structure includes the first server process adding a first key-value pair to a first entry of the tracking structure in response to calling the first UDF, and the second server process adding a second key-value pair to a second entry of the tracking structure in response to calling the second UDF.

[0110] Process 700 includes a process (e.g., Figure 1 124) determines (at 706) whether the UDF chain violates a constraint based on the key-value pair. In some examples, the constraint is a length constraint, and if the length of the UDF chain is at or exceeds a length threshold, the UDF chain violates the length constraint. In other examples, the constraint is a loop constraint, and if there is a UDF loop in the chain, the UDF chain violates the loop constraint.

[0111] Process 700 includes blocking (at 708) by the server process from calling the additional UDF in response to determining that the UDF chain violates the constraint. The server process blocking calling the additional UDF may be a server process launched to execute the additional UDF in response to a request to call the additional UDF during a database operation.

[0112] Storage media (e.g. Figure 5500) may include any one or some combination of the following: a semiconductor memory device, such as a dynamic or static random access memory (DRAM or SRAM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), and a flash memory; a magnetic disk, such as a fixed disk, a floppy disk, and a removable disk; another magnetic medium, including a tape; an optical medium, such as a compact disk (CD) or a digital video disk (DVD), etc.; or another type of storage device. Note that the instructions discussed above may be provided on one computer-readable or machine-readable storage medium, or alternatively, may be provided on multiple computer-readable or machine-readable storage media distributed in a large system with possibly multiple nodes. Such one or more computer-readable or machine-readable storage media are considered to be part of an article (or product). An article or product may refer to any manufactured single component or multiple components. One or more storage media may be located in a machine running machine-readable instructions, or at a remote site, from which machine-readable instructions may be downloaded over a network for execution.

[0113] In the present disclosure, the use of the terms "a", "an" or "the" is intended to include the plural forms as well, unless the context clearly indicates otherwise. Likewise, when used in the present disclosure, the terms "includes / including / comprises / comprising", "have / having" specify the presence of stated elements, but do not exclude the presence or addition of other elements.

[0114] In the foregoing description, many details are set forth to provide an understanding of the subject matter disclosed herein. However, embodiments may be practiced without some of these details. Other embodiments may include modifications and variations of the details discussed above. The appended claims are intended to cover such modifications and variations.

Claims

1. A non-transitory machine-readable storage medium comprising instructions that, when executed, cause a system to: Determines whether a chain of functions violates a constraint based on the following: accessing a trace structure populated with entries when the corresponding server process started during the execution of the database operation calls said function, in, Each of the entries of the trace structure identifies a respective called function associated with a corresponding program instance, and Using the trace structure to detect related functions forming the chain, the related functions being identified as related if the related functions are associated with the same program instance; and In response to determining that the chain of functions violates the constraint, calling of additional functions to be added to the chain is blocked.

2. The non-transitory machine-readable storage medium of claim 1, in, Each of the entries of the trace structure includes a program instance value identifying the corresponding program instance, and wherein the related functions are identified as related using the program instance value in the trace structure.

3. The non-transitory machine-readable storage medium of claim 2, in, The different program instance values ​​in the trace structure identify the different program instances for which the function was called.

4. The non-transitory machine-readable storage medium of claim 1, in, The function is a user defined function (UDF) that is called when processing the database query that triggered the database operation.

5. The non-transitory machine-readable storage medium of claim 1, in, Each of the server processes is to execute a corresponding one of the functions in a separate computing environment.

6. The non-transitory machine-readable storage medium of claim 1, in, When executed, the instructions cause the system to perform the following operations: In response to determining that the lengths of the related functions forming the chain are at or above a length threshold, determining that the chain of functions violates the constraint; and In response to determining that the length of the related functions forming the chain is at or above the length threshold, a violation indication entry is added to the tracking structure.

7. The non-transitory machine-readable storage medium of claim 1, in, When executed, the instructions cause the system to perform the following operations: In response to determining that adding the further function to the related functions in the chain would form a cycle of functions in the chain, it is determined that the chain of functions violates the constraint.

8. The non-transitory machine-readable storage medium of claim 1, in, Each of the entries of the trace structure includes a key-value pair including a key identifying an entity that called the corresponding called function and a value identifying the corresponding called function.

9. The non-transitory machine-readable storage medium of claim 8, in, The key further includes an identifier of the corresponding program instance.

10. The non-transitory machine-readable storage medium of claim 8, in, The entity that called the corresponding called function includes a trigger or another function in a database query.

11. The non-transitory machine-readable storage medium of claim 1, in, The associated function is part of a package, and the package further includes data members that can be accessed by the associated function.

12. The non-transitory machine-readable storage medium of claim 11, in, When executed, the instructions cause the system to perform the following operations: The data member is stored in a package data structure in a cache so as to share the data member among related functions executed in a corresponding server process.

13. The non-transitory machine-readable storage medium of claim 12, in, The data members are stored in the package data structure as key-value pairs, each of the key-value pairs in the package data structure including a key including an identifier of the package and a value representing a corresponding one of the data members.

14. The non-transitory machine-readable storage medium of claim 13, in, The key-value pairs in the packet data structure are arranged as a tree of nodes in the cache, and each node of the tree is identified by an index and represents a corresponding data member value.

15. The non-transitory machine-readable storage medium of claim 13, in, The key-value pairs in the packet data structure are arranged as an array in the cache, and each entry of the array is identified by an offset and represents a corresponding data member value.

16. A method for a distributed system comprising a plurality of computing nodes and a plurality of server processes executed by the plurality of computing nodes, the method include: calling a user defined function (UDF) for execution in a respective one of the plurality of server processes, wherein a first user defined function (UDF) in a first server process calls a second user defined function (UDF) for execution in a second server process, wherein each respective one of the plurality of server processes includes a virtual environment defining an isolated computing environment for executing a respective user defined function (UDF) corresponding to the respective one of the plurality of server processes, and wherein the user defined function (UDF) includes a function developed by an entity and is not part of a database programming language; When the user defined function (UDF) is called and executed by the corresponding server process, adding a key-value pair to an entry of a tracking structure in a cache, wherein each corresponding one of the key-value pairs includes a key identifying a program instance associated with the corresponding user defined function (UDF) that is called and executed and a value identifying the corresponding user defined function (UDF), wherein the adding includes the first server process adding a first key-value pair to a first entry of the tracking structure in response to calling the first user defined function (UDF), and the second server process adding a second key-value pair to a second entry of the tracking structure in response to calling the second user defined function (UDF); determining, by a monitor process based on the key-value pairs in the trace structure, whether a chain of user defined functions (UDFs) violates a constraint, wherein the monitor process includes machine readable instructions for monitoring the trace structure; and In response to determining that the chain of user defined functions (UDFs) violates the constraint, calling additional user defined functions (UDFs) is blocked by the server process.

17. The method of claim 16, in, The key in the corresponding key-value pair further identifies a trigger or another user defined function (UDF) that invoked the corresponding user defined function (UDF).

Citation Information

Patent Citations

  • Cloud Stack platform-based virtual machine creation method, apparatus and device, and storage medium

    CN112286633A

  • Security control method of dynamic link program

    CN112363779A