Container framework for user-defined functions

By processing user-defined functions in isolated containers on the cloud computing platform, using libraries and dynamic resource adjustments defined by auxiliary programming languages, the problems of inefficiency and security risks of user-defined functions in existing database systems are solved, and a better implementation is achieved. Efficient and safe handling.

CN112424765BActive Publication Date: 2024-09-10VMWARE INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201880095563.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-07-20
Publication Date
2024-09-10
Estimated Expiration
2038-07-20

AI Technical Summary

Technical Problem

Existing database systems are inefficient when processing user-defined functions and present security risks that can lead to overloading of computing resources and malicious code corrupting data.

Method used

Implement a distributed database system on a cloud computing platform by allocating dedicated UDF containers in isolated containers to process user-defined functions, utilizing libraries defined in auxiliary programming languages ​​for processing, and dynamically adjusting computing resource allocation through the coordinator to isolate User-defined functions and primary segment hosts.

Benefits of technology

It improves the execution efficiency and security of user-defined functions, reduces the impact of computing resource overload and malicious code on the database, and ensures the normal operation and data security of the database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112424765B
    Figure CN112424765B
Patent Text Reader

Abstract

Method, system, and computer program encoded on a computer storage medium for processing a user-defined function in a container. An example system receives a query written in a primary query language that calls a user-defined function. The system allocates a primary segment host to process the portion of the query written in the primary query language and allocates a first container to process the call to the user-defined function. The primary segment host provides the user-defined function and one or more parameters in the call to the user-defined function to the first container. The first container executes the user-defined function. The primary segment host receives an initial result of the call to the user-defined function computed by the first container. The primary segment host computes a final result of the query using the initial result. In response to receiving the query, the primary segment host provides a final result of the query.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0001] This specification relates to database systems.

[0002] Databases organize data into tables with columns and rows. A unique key identifies each row in each table. A particular row represents an instance of a particular entity, and the columns in that row store values ​​attributed to that instance. Rows in one table can be linked to rows in another table by including a column in one of the two tables that is the unique key used to link the rows.

[0003] The database can be divided into multiple segments. Segments are queried through corresponding segment instances, which are computer programs executed by physical or virtual computing nodes called segment nodes. Each segment node has its own storage and processing capabilities. Under the direction of the host, each segment instance can process part of the query from the client. The host can collect the results from each segment instance and return the final results to the client.

[0004] A user can write database queries in a query language. A query language is a computer programming language that can be used to create and update databases and to retrieve and manipulate data from these databases. A query language typically includes a set of defined operations to support this functionality. Typically, a segment instance of a particular database is specifically configured to process queries in a particular query language. These particular query languages ​​are referred to herein as primary query languages.

[0005] In addition to using predefined operations in the primary query language, database users can also create and use custom functions written in the primary query language. Some databases can also process queries that contain functions written in auxiliary programming languages, which are programming languages ​​different from the primary query language of those databases. This specification refers to such custom functions and functions written in auxiliary programming languages ​​as user-defined functions. Although some databases can process user-defined functions, doing so may be inefficient. That is, executing user-defined functions consumes a disproportionate amount of computing resources, such as memory or processing power, relative to executing queries written in the primary query language, which can disrupt the normal operation of other users' databases. In addition, user-defined functions may not have been fully tested and may contain malicious code that can disable the database or destroy data. Summary of the invention

[0006] This specification describes a distributed database system implemented on a cloud computing platform that can process user-defined functions in isolated containers. Containers are isolated user space instances implemented through operating system-level virtualization. Containers share computing resources, such as memory or processing power, of the computing systems that host the containers. The computing system can dynamically adjust the allocation of computing resources between containers.

[0007] The database system may receive a query from a client device. The query may be written in a primary query language that supports calls to user-defined functions that may be written in other programming languages. If the query is written entirely in the primary query language and does not contain calls to user-defined functions, one or more segment instances implemented by one or more primary segment hosts may fully process the query. A primary segment host may be a physical or virtual computing node. For example, a primary segment host may be a physical computer, a virtual machine, a container, or some combination of the three.

[0008] If the query includes a call to a user-defined function, the system may allocate one or more containers to handle the user-defined function. This specification refers to these allocated containers as UDF containers.

[0009] The UDF container is distinct from the primary segment host. That is, the UDF container is not the primary segment host, and the primary segment host is not and does not implement the UDF container. The system can isolate the UDF container from the primary segment host, for example, by allocating separate computing resources to the UDF container.

[0010] The system can configure the UDF container specifically to handle user-defined functions. For example, the system can configure each UDF container to have a library that defines operations in a secondary programming language and in which user-defined functions are written. Such a library can facilitate efficient execution of user-defined functions.

[0011] After the system allocates and initializes the UDF container, the system can instruct the primary segment host to provide the user-defined function and one or more database segments to the UDF container. The UDF container can then process the user-defined function, for example, by retrieving specific data from the database segment. When the user-defined function is executed, the UDF container can provide the result to the primary segment host. Thereafter, the primary segment host can forward the result to the client device that sent the query.

[0012] The subject matter described in this specification can be implemented in certain embodiments to achieve one or more of the following advantages: The system described herein can process user-defined functions more efficiently and securely in isolated UDF containers than on the primary segment host.

[0013] User-defined functions often use computing resources inefficiently. This is because database systems are often optimized to process queries written in a specific query language. Executing user-defined functions in isolated UDF containers with separate computing resources ensures that user-defined functions do not use all of the database's computing resources. This reduces the occurrence of overload events that can affect query speed and consistency.

[0014] The UDF container can also contain libraries that define operations in auxiliary programming languages. This allows the system to process queries with calls to user-defined functions written in these auxiliary programming languages ​​without reconfiguring the segment instances of the database and converting the operations defined in the auxiliary programming language into statements in the primary query language, which is a time-intensive process.

[0015] User-defined functions can also contain malicious or exploit code that could cripple the database or corrupt its data. The system can mitigate the risk of malicious code by executing user-defined functions in isolated UDF containers that cannot access segment instances or database segments on the primary segment host. As a result, malicious code cannot interfere with the normal operation of the database. Because UDF containers are isolated from the database system, they also prevent user-defined functions from accessing unauthorized file systems.

[0016] The details of one or more embodiments of the subject matter of this specification are set forth in the accompanying drawings and the description below. Other features, aspects and advantages of the subject matter will become apparent from the description, drawings, and claims. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 is a diagram of an example cloud computing platform.

[0018] Figure 2 is a diagram of an example container pool.

[0019] Figure 3 is a flow chart of an example process for executing a user-defined function in an isolated container.

[0020] Like reference numbers and names throughout the various drawings represent like elements. DETAILED DESCRIPTION

[0021] Figure 1 is a diagram of an example cloud computing platform 100. Cloud computing platform 100 provides computing resources and services that can implement a distributed database, including physical computers, virtual machines, containers, and software.

[0022] Client devices, including client device 102, can access a database implemented on cloud computing platform 100 through a wired or wireless network 104. Network 104 can be a local area network (LAN) that connects computers in a limited area, such as a home, school, laboratory, or office building. Local area networks include Ethernet and Wi-Fi networks. The network can also be a larger network, including a wide area network (WAN) or the Internet. Client device 102 can create, update, or query a database.

[0023] The cloud computing platform 100 includes one or more master segment hosts 110a-110n. The master segment hosts 110a-110n are computing resources that implement one or more segment instances of a database, such as physical computers, virtual machines, containers, or some combination of these. In some implementations, each master segment host is a physical computer or virtual machine that hosts multiple containers. In such an implementation, each container implements a corresponding segment instance of the database. In this specification, these containers are referred to as master containers.

[0024] As mentioned above, containers are isolated user space instances implemented through operating system-level virtualization. Containers share the computing resources of their respective computing systems. The computing system can dynamically adjust the allocation of computing resources between containers, and different levels of computing resources can be allocated to different containers running on the same physical computer.

[0025] The primary container is responsible for implementing segment instances that process queries written in the primary query language.

[0026] The cloud computing platform 100 also includes one or more UDF containers 120a-120m that can handle user-defined functions. A user-defined function is a function called by a query written in a primary query language and whose definition is specified by user input. In other words, a user-defined function is not a built-in function of the primary query language. User-defined functions can be defined using statements in different auxiliary programming languages. The UDF containers 120a-120m provide an isolated computing environment in which such user-defined functions are securely processed.

[0027] The UDF containers 120a-120m may have libraries that define operations in auxiliary programming languages. These libraries facilitate efficient processing of user-defined functions written in those auxiliary programming languages. The coordinator 130 (described in more detail below) may also allocate additional computing resources to the UDF containers 120a-120m without reducing the amount of computing resources allocated to the main container.

[0028] The cloud computing platform 100 also includes an orchestrator 130. The orchestrator 130 may receive queries from client devices, create query plans, and manage the master segment hosts 110a-110n and the UDF containers 120a-120m.

[0029] When the coordinator 130 receives a query from a client device 102, the coordinator 130 creates a distributed query plan based on the master program 132. The master program 132 defines how the database query should be processed. The master program 132 may also define how resources should be allocated between different master containers hosted on the master segment hosts 110a-110n. The coordinator 130 sends the query plan to the segment hosts 110a-110n. If the query is written entirely in the master query language, the segment instances can completely process the query plan.

[0030] If the query instead includes a call to a user-defined function written in an auxiliary programming language, the coordinator 130 may additionally allocate one or more UDF containers to handle the call to the user-defined function. Typically, the coordinator 130 allocates a UDF container in response to a request from one or more main containers of a segment instance that implements a database. The segment instance may identify that the query includes a user-defined function based on one or more identifiers in the query. In response to the request, the coordinator 130 allocates one or more UDF containers to handle the user-defined function. In some implementations, the coordinator 130 allocates one UDF container for each main container that makes a request. In other implementations, the coordinator allocates one UDF container for each user-defined function, or one UDF container for each task in a user-defined function. After the coordinator 130 allocates and initializes the UDF container, the main container may pass the user-defined function and any database segments required to process the user-defined function to the UDF container. The UDF container may then process the user-defined function.

[0031] For example, the system may receive a query written in the Python programming language that contains the following function:

[0032] defsquared(s):

[0033] return s*s

[0034] sqlContext.udf.register(squaredWithPython,squared)

[0035] This function is a user-defined function because it is not a built-in function in the main query language. Instead, the user must write and define the function using the auxiliary programming language Python. The segment instance can classify the function as a user-defined function based on the fact that the function is written in the auxiliary programming language (as indicated in the last line of the code) or based on the fact that it is explicitly registered as a user-defined function. Thereafter, the main container that implements the segment instance can request the coordinator 130 to provide a UDF container in which to process the user-defined function. The coordinator 130 can then allocate one or more UDF containers that are configured to process user-defined functions written in Python.

[0036] The coordinator 130 also includes a scheduler 134. The scheduler 134 can select a primary segment host to host an unscheduled segment instance. To this end, the scheduler 134 can track the resource utilization of each primary segment host to ensure that the workload that exceeds the available computing resources is not scheduled. The scheduler 134 can also select the computing resource allocation for the primary container based on the policy directive defined in the main program 132. The coordinator 130 can communicate with the primary segment host to execute those resource allocation decisions. For example, the coordinator 130 can instruct the primary segment host to create or delete a container, or modify the computing resource allocation between containers.

[0037] The coordinator 130 also includes a pool manager 136. The pool manager 136 can manage a pool of containers that can be used as UDF containers. When the coordinator 130 receives a request from a main container, the pool manager 136 can promote an available container to an active UDF container. The pool manager 136 performs similar functions to the scheduler 134, but for UDF containers instead of main containers.

[0038] The cloud computing platform 100 also includes a permanent storage 140. The permanent storage 140 can store backup copies of database segments, thereby ensuring high availability of the database. The permanent storage 140 can also store the configuration of the database data in the primary segment hosts 110a-110n of the database. In other words, the permanent storage 140 can specify which segment hosts store which database segments. More specifically, it can specify which containers execute which segment instances. Changes in the data configuration in the segment hosts are reflected in the permanent storage 140. For example, certain segment instances can be exchanged between primary segment hosts or between containers. Such changes will be reflected in the permanent storage 140. The permanent storage 140 can similarly store the configuration of the UDF containers 120a-120m. The permanent storage 140 can also store user-defined functions in the event that the UDF container fails. If the allocated UDF container does fail, the coordinator 130 can allocate a new UDF container to replace it.

[0039] Persistent storage 140 may be implemented as one or more RAID arrays that provide high availability storage. A RAID array consists of multiple independent storage disks that provide some combination of read and / or write speed, redundancy, and increased storage space.

[0040] Figure 2 2 is a diagram of an exemplary container pool 200. The container pool 200 includes one or more available containers 210a-210n. The available containers 210a-210n do not actively process user-defined functions.

[0041] If the coordinator 130 receives a request to process a user-defined function from a primary container (e.g., primary container 230), the coordinator 130 may check the container pool 200 to see if it has any available containers. If so, the coordinator 130 may assign an available UDF container (e.g., UDF container 220) to the primary container that made the request (step A). ​​The primary container and the assigned UDF container may be connected (step B), and the primary container may provide the user-defined function and database data to the UDF container so that the UDF container can process the user-defined function. Although Figure 2 Only a single main container and a single UDF container are depicted, but the process can be performed for each main container that requests to process a user-defined function.

[0042] The coordinator 130 may reallocate computing resources, such as memory and processing power, between available containers and allocated UDF containers as needed. For example, the coordinator 130 may allocate fewer computing resources to available containers than to allocated UDF containers. When the coordinator 130 allocates available containers, it may allocate additional computing resources to the allocated containers. In some cases, the allocated UDF containers may require additional computing resources. In this case, the coordinator 130 may destroy the available containers and reallocate computing resources from the destroyed containers to the allocated UDF containers. If, for example, the computing resource utilization of the allocated UDF containers and the available containers does not exceed the limit, the coordinator 130 may also add other containers to the container pool 200.

[0043] After the UDF container 220 processes the user-defined function and provides the result to the main container 230 , the coordinator 130 may deactivate the UDF container 220 and add it back to the container pool 200 (step C).

[0044] The coordinator 130 may initialize multiple UDF containers before the distributed database system receives a query, so as to reduce the delay when the main container requests the UDF container.

[0045] Figure 3 3 is a flow chart of an example process 300 for executing a user-defined function in one or more isolated UDF containers. For convenience, the process will be described as being performed by a distributed database system on a cloud computing platform, or by one or more components of a distributed database system. The distributed database system includes reference Figure 1 Describes the components.

[0046] The system receives a query written in a primary query language (310). The query includes a call to a user-defined function. A user-defined function is a function that is not explicitly defined in the primary query language, but is instead written and defined by a user. The user-defined function may be defined in a secondary programming language that is different from the primary query language used to write the query.

[0047] The system assigns one or more primary segment hosts to process one or more portions of a query written in a primary query language (320). In some implementations, the primary segment hosts are primary containers. In such implementations, each primary container implements a segment instance that can process a portion of a query.

[0048] The system also allocates one or more UDF containers to handle calls to the user-defined functions (330). Typically, the system allocates one or more UDF containers in response to requests from one or more main containers that received the portion of the query that included the user-defined function. The system can allocate a UDF container to each main container that made a request.

[0049] Allocating a UDF container to handle a call to a user-defined function may involve selecting a UDF container from a pool of available containers. In particular, allocating a UDF container to handle a call to a user-defined function may involve identifying and selecting a container that is specifically configured to handle functions in a secondary programming language in which the user-defined function is written. For example, if the user-defined function is written in Python, the system may allocate a UDF container that is configured to include a Python library that will help facilitate execution of the user-defined function.

[0050] The allocated UDF container is isolated from the main container on the primary segment host. That is, the UDF container does not share computing resources with the main container.

[0051] The master segment host provides the user-defined function and one or more arguments in the call to the user-defined function to the UDF container (340). The arguments in the call to the user-defined function may include the database segment on which the user-defined function will operate.

[0052] The UDF container executes the user defined function using the parameters in the call to the user defined function, e.g., using the database segment in the call (350). While the UDF container executes the user defined function, the segment instance implemented by the primary segment host processes other portions of the query, e.g., portions of the query written in the primary query language that do not include the user defined function.

[0053] After the UDF container processes the user-defined function, the master segment host receives the initial result of the call to the user-defined function computed by the UDF container (360). The master segment host uses the initial result to compute the final result of the query (370) and provides the final result of the query in response to receiving the query (380).

[0054] After providing the primary segment host with the initial results of executing the call to the user-defined function, the system can release the UDF container to the pool of available containers.

[0055] Embodiments of the subject matter described in this specification may be implemented as one or more computer programs, i.e., one or more modules of computer program instructions encoded on a tangible, non-transitory storage medium to be executed by a data processing device or to control the operation of the data processing device. Alternatively or additionally, the program instructions may be encoded on an artificially generated propagation signal, for example, a machine-generated electrical, optical, or electromagnetic signal, which is generated to encode information for transmission to a suitable receiver device for execution by a data processing device. The computer storage medium may be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, or a combination of one or more of them or a portion thereof. A computer storage medium is not a propagated signal.

[0056] The term "data processing apparatus" covers all kinds of apparatus, devices and machines for processing data, including, for example, a programmable processor, a computer or multiple processors or computers. The data processing apparatus may include special-purpose logic circuits, such as an FPGA (field programmable gate array), an ASIC (application-specific integrated circuit) or a GPU (graphics processing unit). In addition to hardware, the apparatus may also include code that creates an execution environment for a computer program, for example, code constituting processor firmware, a protocol stack, a database management system, an operating system, or a combination of one or more of them.

[0057] A computer program may be written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may also be referred to or described as a program, software, software application, application, module, software module, engine, script, or code; and may be deployed in any form, including as a stand-alone program or as a module, component, engine, subroutine, or other unit suitable for execution in a computing environment, which may include one or more computers interconnected by a data communications network in one or more locations.

[0058] A computer program may, but need not, correspond to a file in a file system. A computer program may be stored in a portion of a file that holds other programs or data, such as one or more scripts stored in a markup language document, in a single file dedicated to the program in question, or in multiple coordinated files, such as files storing one or more modules, subroutines, or code portions.

[0059] The processes and logic flows described in this specification can be performed by one or more computers executing one or more computer programs to perform operations by operating on input data and generating output. The processes and logic flows can also be performed by a special purpose logic circuit (e.g., FPGA, ASIC or GPU) or by a combination of a special purpose logic circuit and one or more programmed computers.

[0060] Computers suitable for executing computer programs may be based on general or special purpose microprocessors, or both, or on any other type of central processing unit. Typically, the central processing unit will receive instructions and data from a read-only memory or a random access memory, or both. The essential elements of a computer are a central processing unit for executing instructions and one or more memory devices for storing instructions and data. The central processing unit and the memory may be supplemented by, or incorporated in, special purpose logic circuits.

[0061] Typically, the computer will also include or be operably coupled to receive data from one or more mass storage devices or transfer data to one or more mass storage devices. The mass storage device can be, for example, a magnetic disk, a magneto-optical disk or an optical disk, or a solid-state drive. However, the computer does not have to have such a device. In addition, the computer can be embedded in another device, for example, a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a global positioning system (GPS) receiver, or a portable storage device, such as a universal serial bus (USB) flash drive, to name a few.

[0062] To provide interaction with a user, embodiments of the subject matter described in this specification may be implemented on a computer having a display device, such as an LCD (liquid crystal display) monitor, or configured to communicate with the computer to display information to the user, and the user may provide input to the computer through an input device, such as a keyboard and a pointing device, such as a mouse, trackball, or touchpad. Other types of devices may also be used to provide interaction with a user. For example, the feedback provided to the user may be any form of sensory feedback, such as visual feedback, auditory feedback, or tactile feedback; and input from the user may be received in any form, including sound, voice, or tactile input. In addition, the computer may interact with the user by sending documents to and receiving documents from the device used by the user. For example, by sending a web page to a web browser on a user's device in response to a request received from the web browser, or interacting with an application running on a user's device (such as a smartphone or electronic tablet). Moreover, the computer may interact with the user by sending a text message or other form of message to a personal device (e.g., a smartphone running a messaging application) and receiving a response message from the user.

[0063] Embodiments of the subject matter described in this specification may be implemented in a computing system that includes a back-end component, for example, as a data server, or includes a middleware component (e.g., an application server), or includes a front-end component, such as a client computer with a graphical user interface, a web browser or an application through which a user can interact with an implementation of the subject matter described in this specification, or any combination of one or more such back-end, middleware, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include local area networks (LANs) and wide area networks (WANs), such as the Internet.

[0064] The computing system may include a client and a server. The client and the server are usually far away from each other and usually interact through a communication network. The relationship between the client and the server is generated by a computer program running on a corresponding computer and having a client-server relationship with each other. In some embodiments, the server, for example, sends data (e.g., an HTML page) to a user device for the purpose of displaying data to a user interacting with a device as a client and receiving user input therefrom. Data generated at the user device, such as the result of user interaction, can be received from the device at the server.

[0065] In addition to the above embodiments, the following embodiments are also innovative:

[0066] Embodiment 1 is a method comprising:

[0067] receiving, by a distributed database system installed on a cloud computing platform, a query written in a primary query language, wherein the query invokes a user-defined function;

[0068] assigning one or more primary segment hosts hosted on the cloud computing platform to process one or more portions of the query written in the primary query language;

[0069] allocating one or more first containers to process calls to user-defined functions in the query;

[0070] providing, by the one or more primary segment hosts, the user-defined function and one or more parameters in a call to the user-defined function to the one or more first containers assigned to handle the call to the user-defined function;

[0071] executing, by the one or more first containers assigned to handle the call to the user-defined function, the user-defined function using the parameters of the call in the user-defined function;

[0072] receiving, by the one or more primary segment hosts, an initial result of the call to the user-defined function computed by the one or more first containers;

[0073] computing, by the one or more primary segment hosts, a final result for the query using the initial result of the call to the user-defined function; and

[0074] In response to receiving the query, providing the final result of the query.

[0075] Embodiment 2 is the method of embodiment 1, wherein allocating the first container to handle the call to the user-defined function comprises:

[0076] The first container is selected from a pool of available containers.

[0077] Embodiment 3 is the method described in embodiment 2, further comprising:

[0078] After providing an initial result of executing the call to the user-defined function to the primary segment host, releasing the first container to the pool of available containers.

[0079] Embodiment 4 is the method described in any one of Embodiments 2-3, further comprising:

[0080] When the resource utilization of the first container exceeds a limit, removing the corresponding container from the available container pool; and

[0081] Resources are reallocated from the removed container to the first container.

[0082] Embodiment 5 is the method described in any one of embodiments 2-4, wherein one or more containers in the available container pool are initialized before the distributed database system receives the query.

[0083] Embodiment 6 is the method described in any one of embodiments 2-5, further comprising:

[0084] When resource utilization of the first container and the available containers does not exceed a limit, the container is added to the available container pool.

[0085] Embodiment 7 is the method described in any one of Embodiments 1-6, further comprising:

[0086] If one of the first containers fails, the user-defined functions and database segments are stored in persistent storage.

[0087] Embodiment 8 is the method described in any one of embodiments 1-7, further comprising:

[0088] A new container is allocated to replace the failed first container.

[0089] Embodiment 9 is the method described in any one of embodiments 1-8, wherein the first container does not share computing resources with the primary segment host.

[0090] Embodiment 10 is the method described in any one of embodiments 1-9, wherein the user-defined function is written in a secondary programming language different from the primary query language.

[0091] Embodiment 11 is the method of embodiment 10, wherein allocating the one or more first containers to process the call to the user-defined function includes identifying one or more first containers configured to process functions in the auxiliary programming language.

[0092] Embodiment 12 is a system comprising: one or more computers and one or more storage devices, wherein the storage devices store instructions, which, when executed by the one or more computers, cause the one or more computers to perform the method described in any one of embodiments 1-11.

[0093] Embodiment 13 is one or more computer storage media storing instructions that, when executed by one or more computers, cause the one or more computers to perform the method described in any one of embodiments 1-11.

[0094] Although this specification contains many specific implementation details, these details should not be interpreted as limitations on the scope of any invention or the scope of what is claimed or can be claimed, but should be regarded as descriptions of features specific to a particular embodiment of a particular invention. Certain features described in this specification in the context of separate embodiments may also be implemented in combination in a single embodiment. Conversely, the various features described in the context of a single embodiment may also be implemented in multiple embodiments or in any suitable sub-combination, respectively. Moreover, although the features may be described above as working in certain combinations and even initially claimed, in some cases, one or more features of the claimed combination may be cut out from the combination, and the claims may be directed to sub-combinations or variations of sub-combinations.

[0095] Similarly, although operations are depicted in a particular order in the drawings and recited in the claims, this should not be understood as requiring that such operations be performed in the particular order shown or in a sequential order, or that all of the illustrated operations be performed to achieve the desired result. In some cases, multitasking and parallel processing may be advantageous. In addition, the separation of various system modules and components in the above-described embodiments should not be understood as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated into a single software product or packaged into multiple software products.

[0096] Specific embodiments of the subject matter have been described. Other embodiments are within the scope of the following claims. For example, the actions recited in the claims can be performed in a different order and still achieve the desired results. As an example, the processes depicted in the accompanying drawings do not necessarily require the particular order shown or sequential order to achieve the desired results. In some cases, multitasking and parallel processing may be advantageous.

Claims

1. A distributed database system installed on a cloud computing platform, the cloud computing platform comprising one or more primary segment hosts and one or more first containers, wherein each primary segment host hosts a plurality of primary containers, each primary container implementing a corresponding database segment, the distributed database system being configured to perform operations, the operations comprising: receiving a query written in a primary query language, wherein the query calls a user-defined function; allocating one or more primary segment hosts on the cloud computing platform to process one or more portions of the query written in the primary query language; allocating the one or more first containers to process calls to the user-defined function in the query by selecting the one or more first containers from a pool of available containers; providing, by the one or more primary segment hosts, the user-defined function and one or more parameters in the call to the user-defined function to the one or more first containers assigned to handle the call to the user-defined function; executing, by the one or more first containers assigned to handle the call to the user-defined function, the user-defined function using the parameters of the call in the user-defined function; processing the one or more portions of the query written in the primary query language using the primary container of the one or more primary segment hosts while the one or more first containers are executing the user-defined function; After providing an initial result of executing the call to the user-defined function to the primary segment host, releasing the one or more first containers to the pool of available containers that are not actively processing the user-defined function; receiving, by the one or more primary segment hosts, an initial result of the call to the user-defined function computed by the one or more first containers; computing, by the one or more primary segment hosts, a final result of the query using the initial result of the call to the user-defined function; as well as In response to receiving the query, providing the final result of the query.

2. The system according to claim 1, wherein: The operations also include: When resource utilization of the one or more first containers exceeds a limit, removing corresponding containers from the available container pool; and Resources are reallocated from the removed container to the one or more first containers.

3. The system according to claim 1, wherein: Before the distributed database system receives the query, one or more containers in the pool of available containers are initialized.

4. The system according to claim 1, wherein: The operations also include: When resource utilization of the one or more first containers and the available containers does not exceed a limit, adding a container to the available container pool.

5. The system according to claim 1, wherein: The operations also include: If one of the one or more first containers fails, the user-defined functions and database segments are stored in persistent storage.

6. The system according to claim 1, wherein: The operations also include: A new container is allocated to replace a failed first container of the one or more first containers.

7. The system according to claim 1, wherein: The one or more first containers do not share computing resources with the one or more primary segment hosts.

8. The system according to claim 1, wherein: The user-defined functions are written in a secondary programming language different from the primary query language.

9. The system according to claim 8, wherein: Allocating the one or more first containers to handle the call to the user-defined function includes identifying one or more first containers configured to handle functions in the secondary programming language.

10. A method performed in a distributed database system, the distributed database system being installed on a cloud computing platform, the cloud computing platform comprising one or more primary segment hosts and one or more first containers, wherein each primary segment host hosts a plurality of primary containers, each primary container implementing a corresponding database segment, the method comprising: receiving, by the distributed database system, a query written in a primary query language, wherein the query invokes a user-defined function; allocating one or more primary segment hosts on the cloud computing platform to process one or more portions of the query written in the primary query language; allocating the one or more first containers to process calls to the user-defined function in the query by selecting the one or more first containers from a pool of available containers; providing, by the one or more primary segment hosts, the user-defined function and one or more parameters in the call to the user-defined function to the one or more first containers assigned to handle the call to the user-defined function; executing, by the one or more first containers assigned to handle the call to the user-defined function, the user-defined function using the parameters of the call in the user-defined function; processing the one or more portions of the query written in the primary query language using the primary container of the one or more primary segment hosts while the one or more first containers are executing the user-defined function; After providing an initial result of executing the call to the user-defined function to the primary segment host, releasing the one or more first containers to the pool of available containers that are not actively processing the user-defined function; receiving, by the one or more primary segment hosts, an initial result of the call to the user-defined function computed by the one or more first containers; computing, by the one or more primary segment hosts, a final result of the query using the initial result of the call to the user-defined function; as well as In response to receiving the query, providing the final result of the query.

11. The method according to claim 10, further comprising: When resource utilization of the one or more first containers exceeds a limit, removing corresponding containers from the available container pool; as well as Resources are reallocated from the removed container to the one or more first containers.

12. The method according to claim 10, wherein: Before the distributed database system receives the query, one or more containers in the pool of available containers are initialized.

13. The method according to claim 10, further comprising: When resource utilization of the one or more first containers and the available containers does not exceed a limit, adding a container to the available container pool.

14. The method according to claim 10, further comprising: If one of the one or more first containers fails, the user-defined functions and database segments are stored in persistent storage.

15. The method according to claim 10, further comprising: A new container is allocated to replace a failed first container of the one or more first containers.

16. The method according to claim 10, wherein: The one or more first containers do not share computing resources with the one or more primary segment hosts.

17. The method according to claim 10, wherein: The user-defined functions are written in a secondary programming language different from the primary query language.

18. The method according to claim 17, wherein: Allocating the one or more first containers to handle the call to the user-defined function includes identifying one or more first containers configured to handle functions in the auxiliary programming language.

19. A non-transitory computer storage medium storing instructions which, when executed by one or more computers, cause the one or more computers to perform the method of any one of claims 10-18.