Replicated database distribution for workload balancing after cluster reconfiguration

By dividing the database into primary partitions and secondary partitions in the MPP database system, and evenly distributing them in the computer network, the problems of workload balancing and insufficient data availability in the existing technology are solved, and the problem of node failure or node addition is realized. Efficient workload balancing and data redundancy.

CN112507023BActive Publication Date: 2024-09-06HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011354844.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2014-12-19
Filing Date
2015-12-15
Publication Date
2024-09-06
Estimated Expiration
2035-12-15

AI Technical Summary

Technical Problem

Existing MPP database systems have deficiencies in workload balancing and data availability. Especially during node failure and redundancy recovery, workload balancing is not fully designed, resulting in performance degradation.

Method used

By dividing the database into multiple primary partitions and slave partitions, and evenly distributed in the computer network, using partitioners, replicators and initial allocators to copy the primary partition into slave partitions, ensuring that each slave partition is stored with its corresponding primary partition On different nodes, the primary partition of the failed node can be upgraded to a secondary partition to maintain workload balance and data availability.

Benefits of technology

It achieves workload balancing and data redundancy when nodes fail or are added, improves the high availability and performance of the MPP database system, and significantly improves the fault tolerance of large-scale parallel processing database systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112507023B_ABST
    Figure CN112507023B_ABST
Patent Text Reader

Abstract

A computer-implemented method for distributing multiple data partitions among a group of computer nodes, comprising: dividing a database into multiple primary partitions; storing the primary partitions on multiple nodes associated with a computer network; replicating the primary partitions to create multiple secondary partitions and storing the secondary partitions on the nodes, wherein the primary and secondary partitions are roughly evenly distributed among the nodes, each secondary partition is stored on a different node from its corresponding primary partition, each secondary partition and the node storing the secondary partition have a diversity, the primary partition can be used to serve the system workload, and one or more secondary partitions corresponding to one or more primary partitions of a failed node can be used to upgrade to a primary state after a failure in one of the computer nodes to maintain workload balance and data availability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates generally to distributed databases and, more particularly, to placing replicated partitions of a distributed relational database on networked computer nodes. Background Art

[0002] Databases are used to store information and the relationships between information. Some databases are stored in distributed file systems on multiple computers connected via a network or multiple interconnected networks. Typically, a database is divided into partitions of equal, similar, or unequal size, and one or more partitions of information data are stored in storage devices associated with multiple servers connected via a network system.

[0003] In some existing distributed file systems, such as the typical Hadoop distributed file system (HDFS) or a typical peer-to-peer (P2P) distributed file system, a single database file is divided into data blocks, which are distributed to multiple computer nodes in order to maintain data redundancy and achieve workload balancing. Some existing distributed file systems utilize a relatively large number of nodes, including thousands of nodes, which change over time as additional nodes are dynamically added to and removed from the cluster. The computer nodes in these systems are usually composed of commodity hardware, such as personal computers (PCs), and may include user systems. For large-scale, loosely coupled distributed systems oriented to throughput, such as HDFS and P2P distributed file systems, existing methods can achieve significant data redundancy and relatively high data availability.

[0004] Other existing distributed file systems include massively parallel processing (MPP) database management systems, which distribute data to a group or groups of servers with relatively high performance, such as data warehouses, and expand outward by running various computing transactions in parallel on multiple servers. MPP database systems usually include fewer nodes than HDFS or P2P distributed file systems, and the number of nodes in MPP database systems is generally relatively more stable than HDFS or P2P. Therefore, sometimes the performance of MPP databases is controlled by slower nodes in a cluster of parallel processing computers. As a result, workload balancing sometimes becomes a key factor in achieving high throughput and low latency at the same time. In a high-performance server-based distributed file system, assuming that the data on each node receives similar access to computing resources, the uniform distribution of data between the distributed server nodes can generally balance the workload.

[0005] A typical MPP database cluster uses a "non-shared" storage architecture, in which storage hardware, such as disk drives, is not shared between the nodes of the cluster. In an MPP database system, data location information is not available at runtime. In addition, MPP database clusters increasingly utilize commodity hardware resources, such as PCs. Therefore, if a single server in the cluster fails, the data stored on the failed server becomes unavailable to the cluster. The design of a high-availability MPP database system requires that the cluster be able to tolerate server failures and provide continuous service without data loss. The replication of data in multiple servers has been combined with a failover process to enable it to continue in the event of a single server failure in order to achieve a general level of tolerance for server failures.

[0006] In addition, workload balancing is not typically given a high design priority, especially during node failures and redundancy recovery. For example, consistent hashing algorithms are often used to locate distributed and replicated data in peer-to-peer distributed file systems. In consistent hashing algorithms, the output range of a hash function is treated as a fixed circular space or ring (e.g., the largest hash value is wrapped around the smallest hash value). Each system node is assigned a value within this space to represent the node's position on the ring. A unique position on the ring is generated by associating an identifier or key with the hash data item to assign each data item to a node in the ring, and then "walking" or moving clockwise around the ring to find the first server with a greater position than the data item.

[0007] That is, each node is responsible for the area between the node and its previous node on the ring. Then, when a node fails, the corresponding workload is forwarded to the next server on the ring. Similarly, when a new node is attached to the ring, the node only shares the workload of the adjacent servers in the ring, resulting in an unbalanced workload. Although such an unbalanced workload can be reasonably tolerated in a cluster comprising thousands of nodes, the same level of workload imbalance can have a significant negative impact on performance in an MPP database. Since both throughput and latency are of considerable importance, some existing file distribution methods have disadvantages when used in an MPP database system. Summary of the invention

[0008] According to a general aspect, a method includes: dividing a database into a plurality of primary partitions; storing the primary partitions on a plurality of nodes associated with a computer network, wherein the primary partitions are approximately evenly distributed between the nodes and the primary partitions can be used to serve system workloads; replicating the primary partitions to create a plurality of slave partitions; storing the slave partitions on the nodes, wherein the slave partitions are approximately evenly distributed between the nodes, each slave partition is stored on a different node from its corresponding primary partition, each slave partition has a diversity with the node storing the slave partition, and one or more slave partitions corresponding to one or more primary partitions of a failed node can be used to upgrade to a master state after a failure in the computer node to maintain workload balance and data availability.

[0009] According to another general aspect, a computer program product for distributing multiple data partitions among a group of computer nodes includes: a non-transitory tangible computer-readable storage medium, the medium containing computer-readable instructions, the computer-readable instructions adapted to be executed to implement partitioning a database into multiple primary partitions, storing the primary partitions on multiple nodes associated with a computer network, wherein the primary partitions are approximately evenly distributed among the nodes and the primary partitions can be used to serve system workloads, replicating the primary partitions to create multiple slave partitions, and storing the slave partitions on the nodes, wherein the slave partitions are approximately evenly distributed among the nodes, each slave partition is stored on a different node with its corresponding primary partition, each slave partition has a diversity with the node storing the slave partition, and one or more slave partitions corresponding to one or more primary partitions of a failed node can be used to upgrade to a master state after a failure in one of the computer nodes to maintain workload balance and data availability.

[0010] According to another general aspect, a device for distributing multiple data partitions among a group of computer nodes includes: a partitioner for dividing a database into multiple primary partitions; a replicator for replicating the primary partitions to create multiple slave partitions; an initial distributor for storing the primary partitions and the slave partitions on multiple nodes associated with a computer network, wherein the primary partitions and the slave partitions are roughly evenly distributed among the nodes, the primary partition can be used to serve the system workload, each slave partition is stored on a different node from its corresponding primary partition, each slave partition and the node storing the slave partition have a diversity, and one or more slave partitions corresponding to one or more primary partitions of a failed node can be used to upgrade to a master state after a failure in one of the computer nodes to maintain workload balance and data availability.

[0011] The details of one or more embodiments of the invention are set forth in the accompanying drawings and the detailed description that follows. Other features, objects, and advantages of the invention will be apparent from the detailed description and drawings, and from the claims. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Figure 1 is a schematic diagram depicting a device for distributing data partitions among a group of computer nodes.

[0013] Figure 2 It is a diagram that describes the partitioning and distribution of database data partitions among a group of computer nodes.

[0014] Figure 3 It is a table showing the distribution of master partitions and slave partitions among a group of computer nodes.

[0015] Figure 4 Is a table showing the redistribution of primary and secondary partitions after a node failure.

[0016] Figure 5 is an array representing the rank of each compute node in a cluster.

[0017] Figure 6 is a table showing the redistribution of master and slave partitions after adding a node to the cluster.

[0018] Figure 7 is a flow chart illustrating a method of initializing distributed data partitions among a group of computer nodes.

[0019] Figure 8 is a flow chart illustrating a method of redistributing data after a node failure.

[0020] Fig. 9 is a flow chart illustrating a method of redistributing data partitions after adding a node to the cluster. DETAILED DESCRIPTION

[0021] Figure 1 1 shows an embodiment of the present invention, and details an apparatus 10 for partitioning, replicating and distributing information data associated with a database among multiple interconnected servers. For example, the apparatus 10 can be implemented in one or more relational database management system coordinator nodes, data nodes, or any combination of these nodes. The apparatus 10 includes an input / output device 23, a memory 22, and a processor 24 interconnected by a data link 26. The memory 22 includes a partitioner 12, a replicator 14, an initial distributor 16, a failover distributor 18, and an insertion distributor 20.

[0022] The use of the apparatus 10 may result in improved workload balancing while maintaining data redundancy and providing high data availability relative to existing file distribution systems. In particular, the use of the apparatus 10 may result in improved workload balancing relative to existing placement methods after a single computer node failure or multiple node failures, or after other changes in system capacity, such as the insertion of an additional node. As a result, the apparatus 10 may provide significant advantages in massively parallel processing (MPP) database systems.

[0023] The partitioner 12 may divide or partition the information data associated with the database into various data groups or partitions of equal, similar or unequal size. For example, the partitioner 12 may utilize a hash function to operate on a key value associated with each data item or information segment in the database to create a unique identifier that further associates the data item or information segment with a single partition. In a preferred embodiment, the sizes of the partitions are fairly similar or nearly equal.

[0024] The replicator 14 can replicate any or all of the partitions to create backup copies of the one or more partitions. The replicator 14 can also replicate any or all of the partitions to create additional backup copies of the one or more partitions. The initial distributor 16 implements the placement of data partitions on multiple computer nodes when the distributed database is initialized. If a computer node fails, the failover distributor 18 can redistribute the data partitions between the surviving nodes to achieve workload balance. Similarly, if a node is attached to a cluster of computers, the insertion distributor 20 can redistribute the data partitions from the existing nodes to the newly added nodes to maintain workload balance.

[0025] The input / output device 23, the memory 22 and the processor 24 may be part of a general computer device, such as a personal computer (PC), a server or a mainframe computer. The peripheral components may include program code stored on a computer-readable medium, such as source code, object code or executable code, which may be loaded into the memory 22 and executed by the processor 24 to implement the functions of the device 10. Therefore, in various embodiments, the functions of the device 10 may be performed on any suitable processor, such as a server, a mainframe computer, a PC, a PDA, a collection of network servers or a collection of PCs, etc. In addition, when a modified or improved version of the device 10 is developed, for example, to revise or add templates or country-specific information, the software associated with the processor may be updated.

[0026] In various embodiments, the device 10 may be coupled to a communications network, which may include any feasible combination of devices and systems capable of linking computer-based systems, such as the Internet, an intranet or extranet, a local area network (LAN), a wide area network (WAN), a direct cable connection, a private network, a public network, an Ethernet-based system, a token ring network, a value-added network, a telephone-based system, for example, including T1 or E1 equipment, an Asynchronous Transfer Mode (ATM) network, a wired system, a wireless system, a fiber optic system, any number of distributed processing networks or systems, etc.

[0027] The address data collection system 10 may be coupled to a communications network via a local data link 26, which system, in various embodiments, may include any combination of devices and associated software or firmware for coupling to a processor-based system, such as a modem, a network interface card, a serial bus, a parallel bus, a LAN or WAN interface, a wireless or fiber optic interface, etc., together with any associated transmission protocols as may be necessary or required by the design.

[0028] One embodiment of the present invention may, for example, convey information to a user and request user input through an interactive, menu-driven, visual display-based user interface or graphical user interface (GUI). The user interface may be executed, for example, on a personal computer (PC) with a mouse and keyboard, and the user may directly manipulate the GUI to interactively input information. Direct manipulation may include using a pointing device such as a mouse or stylus to select from a variety of optional fields, including optional menus, drop-down menus, tabs, buttons, bullets, check boxes, text boxes, etc. Nevertheless, various embodiments of the present invention may include any number of user interface schemes that use or do not use the additional functions of a mouse or buttons or keys, including, for example, a trackball, a touch screen, or a voice control system to replace this interface scheme.

[0029] Reference Figure 2 , database table 28 can be obtained by Figure 11 to divide the database table 28 into various partitions 30 including a plurality of rows 32 of fields from a database table 28. In this example, the partitioner 12 may use a hash function to operate on an identification number (ID) 34 associated with each row 32 to create a unique identifier, which further associates each row 32 of the database table 28 with one of the partitions 28 in the hash bucket. Records of approximately equal size in the database table 28 may be approximately evenly distributed among the partitions 30 to create partitions 30 of approximately equal size. The partitions 30 may then be placed, or distributed, among a plurality of nodes 38 of a computer cluster associated with the database.

[0030] In general, a storage partition that is currently serving a system workload at any given time, or that is currently available to serve a system workload, can be designated as a "primary" partition. A storage backup copy that is not currently serving a workload, or that is not currently available to serve a workload, can be designated as a "slave" partition. At any given time, any single primary partition can correspond to multiple slave partitions or replicas.

[0031] In general, each partition can be distributed to the computer nodes in one of the following three situations: 1) when the database is initialized; 2) after one or more nodes fail; or 3) when one or more additional nodes or nodes are inserted into the cluster. The partition placement or distribution algorithm distributes the partitions among the nodes in a manner that balances the workload among the nodes and provides a high level of data availability. To this end, in general, the master partitions and slave partitions are roughly evenly distributed among the computer nodes. The even distribution of the master partitions generally helps with workload balancing, while the even distribution of the slave partitions helps with workload balancing during failover after one or more node failures.

[0032] To promote workload balancing and provide k-safe data availability (i.e., the ability to tolerate k simultaneous node failures based on K slave partitions for each master partition), the placement algorithm generally follows the following four criteria:

[0033] The master and slave replicas of any partition are located on different nodes;

[0034] The primary partitions are basically evenly distributed among the nodes;

[0035] The slave partitions are basically evenly distributed among the nodes;

[0036] ·Distribution from partitions to maximize diversity.

[0037] The first criterion is generally to avoid or minimize data loss when one or more nodes fail. The second and third criteria generally promote workload balancing. The fourth criterion promotes workload balancing during failover after one or more nodes fail. Here, diversity refers to the degree to which the master partitions corresponding to the slave partitions on a particular node are evenly distributed among other nodes. Although the placement algorithm attempts to comply with all four criteria as much as possible, strict compliance with the second, third, and fourth criteria is not an absolute requirement.

[0038] Thus, during database initialization, once information from the database has been grouped into partitions, the initial allocator 16 can store or place each partition in one of a plurality of computer nodes associated with the database according to the partition placement algorithm described herein. Subsequent queries requiring access to a database record can be forwarded to the node storing the partition containing the record.

[0039] Reference Figure 3 As a specific example of partition placement during database initialization, Table 40 shows the placement of master partitions 42 and slave partitions 44 between nodes 46 of a server cluster associated with the database. Records in the database table are divided into thirty-two partitions numbered 1 to 32. The master and slave copies of each partition are distributed between eight computer nodes named N1 to N8. In order to achieve workload balancing, each node 46 is assigned four master partitions 42 and four slave partitions 44.

[0040] Thus, for example, using a circular placement algorithm to evenly distribute primary partitions 42 among the nodes, node N1 is assigned four primary partitions numbered 1, 9, 17, and 25; node N2 is assigned four primary partitions numbered 2, 10, 18, and 26; node N3 is assigned four primary partitions numbered 3, 11, 19, and 27; node N4 is assigned four primary partitions numbered 4, 12, 20, and 28; node N5 is assigned four primary partitions numbered 5, 13, 21, and 29; node N6 is assigned four primary partitions numbered 6, 14, 22, and 30; node N7 is assigned four primary partitions numbered 7, 15, 23, and 31; and node N8 is assigned four primary partitions numbered 8, 16, 24, and 32.

[0041] Then, the slave partitions 44 are evenly distributed among the nodes 46 using an improved circular placement algorithm. Each slave partition 44 is assigned to a node other than the node storing the corresponding master partition. For example, the slave partition corresponding to the master partition 1 stored on the node N1 is stored on the node N5. In addition, each slave partition 44 corresponding to the master partition 42 stored on a single node is preferably stored on a separate node 40. For example, the slave partitions corresponding to the master partitions 1, 9, 17 and 25 stored on the node N1 are stored on four separate nodes: N5, N6, N7 and N8. Similarly, the slave partitions 44 are preferably placed so that each master partition 42 corresponding to the slave partitions 44 stored on a single node is stored on a separate node 46. For example, the master partitions 42 corresponding to the slave partitions 5, 12, 19 and 26 stored on the node N1 are stored on four separate nodes: N5, N4, N3 and N2.

[0042] This placement algorithm generally ensures that after a node fails, at least one of each pair of corresponding master and slave partitions 42, 44 remains on a surviving node. If additional partition replicas are stored according to the same criteria for the corresponding master partition and each corresponding slave partition, then the system can tolerate the same number of nodes failing simultaneously as the number of replicas of the slave partitions stored. Thus, if two replicas of the slave partition are stored, then the system can tolerate the simultaneous failure of two nodes without losing data. That is, the storage of k replicas of the slave partitions provides k-safe data availability.

[0043] In general, when a node leaves or joins a distributed file system cluster, data partitions need to be redistributed or moved between nodes in order to maintain or restore proper workload balance. It is very important that the partition distribution continues to meet the above four criteria after the redistribution is completed.

[0044] Since a single partition may contain a large amount of data, ranging from several gigabytes (GB) to several terabytes (TB), the redistribution process may consume a very large amount of network and storage bandwidth, temporarily affecting query performance. Therefore, minimizing the number of partitions in redistribution is as important as workload balancing.

[0045] When a server node fails or is disconnected or otherwise disconnected from the network, in order to restore data redundancy, the minimum number of partitions to be redistributed is generally equal to the total number of partitions stored on the failed or disconnected node. The primary partition stored on the failed or disconnected node can no longer serve requests for the workload. Therefore, in response to detecting a node failure, the slave partitions stored on other currently running nodes corresponding to the primary partitions stored on the failed or disconnected node are promoted to primary status. This situation is called "failover".

[0046] Subsequent requests for the primary partition corresponding to the failed node are forwarded to the node storing the corresponding slave partition. New replicas of the slave partitions that have been promoted to primary status are created to restore data redundancy after the failover. The workload remains properly balanced in the failover situation because the affected slave partitions are evenly distributed across the remaining nodes during the redistribution period.

[0047] The placement algorithm described in this application can roughly balance the workload in a failover situation when slave partitions are promoted to primary state and placed in surviving nodes after a node failure. The redistributed workload should be evenly shared by all nodes. The placement algorithm described in this application minimizes the number of partitions during the redistribution process and maintains a level of data redundancy while achieving workload balance during and after redistribution.

[0048] Reference Figure 4 As a specific example of partition placement during redistribution following a node failure or leaving the cluster, Table 50 illustrates the placement of master partitions 52 and slave partitions 54 among nodes 56 of a server cluster associated with a database. Figure 3 The master and slave replicas of the 32 partitions in the configuration are Figure 3 After the node N8 of the fails or leaves the cluster, it has been redistributed among the remaining seven computer nodes 56 named N1 to N7. In order to achieve workload balance, each node 56 is distributed with four or five master partitions 52 and four or five slave partitions 54.

[0049] Because in Figure 3 The master partitions numbered 8, 16, 24, and 32 stored on node N8 are no longer available after node N8 fails or the cluster network of node N8 is disconnected, and the corresponding slave partitions stored on nodes N4, N5, N6, and N7 are upgraded to the master state. As a result, nodes N1, N2, and N3 continue to store the data before node N8 fails or is disconnected. Figure 3 The same four primary partitions in the configuration, and after redistribution, nodes N4, N5, N6 and N7 store five primary partitions respectively: among them, node N1 continues to store four primary partitions numbered 1, 9, 17 and 25; node N2 continues to store four primary partitions numbered 2, 10, 18 and 26; node N3 continues to store four primary partitions numbered 3, 11, 19 and 27; node N4 is assigned five primary partitions numbered 4, 8, 12, 20 and 28; node N5 is assigned five primary partitions numbered 5, 13, 16, 21 and 29; node N6 is assigned five primary partitions numbered 6, 14, 22, 24 and 30; node N7 is assigned five primary partitions numbered 7, 15, 23, 31 and 32.

[0050] Node N8 is no longer included in the cluster and currently does not store any partitions, while queries directed to partitions numbered 8, 16, 24, and 32 are redirected or failed over from node N8 to nodes N4, N5, N6, and N7, respectively. As long as the four partitions numbered 8, 16, 24, and 32 have been promoted to the primary state, all database data continues to be available to database users.

[0051] When the four failover partitions have just been promoted from slave to master status, no partition redistribution is involved. However, the newly designated master partitions numbered 8, 16, 24, and 32 initially have no corresponding slave partitions. In addition, the slave partitions numbered 4, 11, 18, and 25 previously stored on node N8 are no longer available. As a result, eight slave partitions (numbered 4, 8, 11, 16, 18, 24, 25, and 32) need to be copied and redistributed to other nodes in order to maintain data redundancy. This is the minimum number of partitions to be redistributed because it is the number of partitions previously stored on node N8 before the failure of node N8.

[0052] Again, the improved circular placement algorithm is used to evenly distribute the slave partitions among the surviving nodes. Each slave partition is preferentially assigned to a node other than the node storing the corresponding master partition. For example, the slave partition corresponding to the master partition 8 stored on the node N4 is stored on the node N6. The slave partition numbered 8 is preferably not placed on the node N4, because the corresponding master partition numbered 8 is located on the node N4.

[0053] In addition, each slave partition corresponding to a master partition stored on a single node is preferably stored on a separate node. For example, slave partitions corresponding to master partitions 4, 8, 12, 20, and 28 stored on node N4 are stored on five separate nodes: N5, N6, N1, N2, and N3. Similarly, slave partitions are preferably placed so that each master partition corresponding to a slave partition stored on a single node is stored on a separate node. For example, each master partition corresponding to slave partitions 3, 10, 16, and 17 is stored on four separate nodes: N3, N2, N5, and N1.

[0054] The redistribution is primarily driven by the enforcement of four criteria for the placement algorithm, namely, maximizing diversity or the degree to which the master partitions corresponding to the slave partitions on a particular node are evenly distributed among other nodes. For example, in the improved round-robin method, if the first node encounters diversity with respect to the method, it may be selected for placement of the slave partition being considered.

[0055] So, for example, Figure 4As shown in , during the redistribution after the failure of node N8, since there is diversity with respect to the slave partition on node N6, the newly created slave partition numbered 8 is placed on node N6. This slave partition is preferably not placed on node N1, since there is no diversity with respect to the slave partition on node N1, since the slave partition numbered 12 located on node N1 corresponds to the master partition on node N4, wherein the master partition numbered 8 is placed on N4.

[0056] Similarly, the slave partition numbered 8 is preferably not placed on nodes N2, N3, or N5 because there is no diversity with respect to that slave partition, since the slave partitions numbered 20, 28, and 4 located on nodes N2, N3, and N5, respectively, correspond to the master partitions on node N4. This approach is a greedy algorithm because the placement of a single slave partition is based entirely on the diversity with respect to that slave partition. Therefore, the result may not be globally optimal.

[0057] During redistribution, an additional criterion may be imposed on the partition placement algorithm based on the number of partitions that are transferred to or from a single node during redistribution, which is called the node's rank. Therefore, in order to balance the workload during redistribution, an array may be created to represent the current rank value associated with each node in the database cluster. This array may be modified to reflect each move or transfer of partitions to and from each node in the cluster. Thus, the rank array records the number of partitions transferred from each corresponding node.

[0058] As a specific example, in Figure 3 Configuration and Figure 4 During redistribution of data partitions in the configuration of , eight slave partitions are replicated and distributed among the seven surviving nodes. Each partition placement affects two nodes: one node that sends the partition and another node that receives the partition. Therefore, in this example, a total of eight partitions are sent and eight partitions are received. From the perspective of a single node, there are a total of sixteen send and receive operations, each of which results in an increment of the rank value associated with the affected node.

[0059] To balance the workload during redistribution, the maximum allowed rank of a node eligible to receive a slave partition is preferably equal to the sum of the total number of partition transfer operations divided by the number of surviving nodes plus 1 (rounded to the nearest integer):

[0060]

[0061] In this example, the maximum level is 3, as shown below:

[0062]

[0063] When selecting a node for placement of a slave partition, preferably only those nodes are considered that have not currently reached the maximum rank value.

[0064] Now refer to Figure 5 , in this example, an exemplary rank array 60 is shown as time 62 passes (advances vertically) during the redistribution placement process. Initially, all nodes have a rank of zero. Then, as redistribution occurs, the rank array element corresponding to each affected node is incremented each time a node is selected to place a slave partition, because the element corresponds to the node where the replicated partition is located.

[0065] So, for example, in Figure 5 In the first redistribution placement step 64 shown in , when the master partition numbered 8 in node N4 is replicated and the slave partition numbered 8 is placed in node N6, the elements corresponding to N4 and N6 are both incremented to a value of one. Subsequently, in placement step 6, when determining the placement of slave partition 11, although the partition will be eligible for placement in node N4, the corresponding rank value has reached the maximum value of three for redistribution. As a result, N5 is selected instead for placement of slave partition 11.

[0066] When a new server node is connected to the network, newly associated with the cluster, or the capacity of the cluster otherwise changes, data partitions generally need to be redistributed to restore workload balance among the current cluster of computer nodes. The minimum number of partitions to be redistributed to restore data redundancy can be calculated based on the total number of master and slave partitions and the number of nodes in the cluster.

[0067] For example, the minimum number of master partitions to be transferred to the newly added node can be calculated as the average number of master partitions on each node, and the same number of slave partitions can also be transferred to the newly added node. Alternatively, the minimum total number of partitions to be transferred to the newly added node can be calculated as the total number of partitions on each node, and these can be divided substantially evenly between the master and slave partitions.

[0068] The specific master and slave partitions to be moved to the newly inserted node are preferably determined using the diversity of each partition in the original distribution before the additional node is inserted. The diversity for the master partition is considered to be the same as the diversity of the corresponding slave partition, or equivalently, the diversity of the corresponding slave partition is also used for the corresponding master partition. Therefore, the disclosed method, or placement algorithm, builds an array representing the diversity of each partition. Partitions that lack diversity or have a diversity equal to zero are given priority for transfer to the newly added node in order to increase the diversity of these partitions.

[0069] Reference Figure 6As a specific example of partition placement during redistribution following a capacity change results when an additional node is inserted into the cluster, table 70 shows the placement of master partitions 72 and slave partitions 74 among nodes 76 of a group of servers associated with the database. Figure 3 The master and slave copies of the thirty-two partitions in the configuration shown in have been redistributed between nine computer nodes 76 currently designated as N1 to N9 after node N9 is added to the cluster. To achieve workload balancing, each node is distributed with three or four master partitions and three or four slave partitions. The minimum number of partitions is six, including three master partitions and three slave partitions, which are placed on node N9.

[0070] The minimum number of three primary partitions are transferred to the newly added node N9, and the primary partitions are distributed substantially evenly among all current cluster nodes using a round-robin placement algorithm. The last or highest numbered primary partition comes from Figure 3 Each of the first three nodes in the configuration shown in FIG. 1 , such as the master partition numbered 25 from node N1, the master partition numbered 26 from node N2, and the master partition numbered 27 from node N3, are transferred to the newly added node N9 to form the minimum number of master partitions on the newly added server. In addition, the last or highest numbered slave partition from Figure 3 Each of the subsequent three nodes in the configuration shown in , such as the slave partition numbered 29 from node N4, the slave partition numbered 30 from node N5, and the slave partition numbered 31 from node N6, is transferred to the newly added node N9 to form the minimum number of slave partitions on the newly added server.

[0071] As a result, before node N9 is added to the cluster, each Figure 3 Nodes N4, N5, N6, and N7 shown in the configuration continue to store four identical primary partitions, and after redistribution, each of nodes N1, N2, N3, and N8 stores three primary partitions: three primary partitions numbered 1, 9, and 17 are distributed on node N1; three primary partitions numbered 2, 10, and 18 are distributed on node N2; three primary partitions numbered 3, 11, and 19 are distributed on node N3; node N4 continues to store four primary partitions numbered 4, 12, 20, and 28; node N5 continues to store four primary partitions numbered 5, 13, 21, and 29; node N6 continues to store four primary partitions numbered 6, 14, 22, and 30; node N7 continues to store four primary partitions numbered 7, 15, 23, and 31; and node N8 continues to store four primary partitions numbered 8, 16, 24, and 32. The newly added node N9 distributes three primary partitions numbered 25, 26, and 27.

[0072] Each placement complies with the applicable criteria for the placement algorithm described in the present invention. Thus, each master partition numbered 25, 26, and 27 distributed to the newly added node N9 is different from each slave partition numbered 39, 30, and 31 distributed to the newly added node N9. In addition, each node N1 to N9 stores three or four master partitions, together with three or four slave partitions. In addition, each master partition corresponding to the slave partition numbered 29, 30, and 31 stored on the newly added node N9 is stored on a separate node N5, N6, and N7, respectively, wherein each master partition maintains a subset of the corresponding slave partitions.

[0073] Now refer to Figure 7 , showing a Figure 1 Flowchart of the partition placement algorithm described in the present invention used by the apparatus 10 when initializing a database. The process begins at box 70 "Starting Partition Placement". In box 72, a node number variable (e.g., "N") is set equal to the number of a node in a group of servers associated with the database, a partition number variable (e.g., "M") is set equal to the number of data partitions created from records in the database, and a master / slave variable (e.g., "IsPrimary=true") is set to indicate that the partition currently under consideration is a master partition. In box 74, two counting variables, the first indicating the node number currently under consideration (e.g., "i") and the second indicating the partition number currently under consideration (e.g., "j"), are set equal to the value "1".

[0074] In box 76, a determination is made as to whether the partition currently under consideration is a master partition. If so, the skew variable is set equal to the value "0" in box 78. Otherwise, if the partition currently under consideration is not a master partition but a slave partition, the skew variable is set equal to the value "3" in box 80. In both cases, the program proceeds from box 78 or 80 to box 82, where a determination is made as to whether the number of partitions currently under consideration is less than or equal to the number of partitions previously set in box 72. If it is not a master partition (i.e., the number of partitions currently under consideration is greater than the number of partitions previously set in box 72), the master / slave variable in box 84 is set to indicate that the partition currently under consideration is not a master partition but a slave partition, and the program continues at box 74 as described above.

[0075] On the other hand, if it is determined in block 82 that the number of partitions currently under consideration is less than or equal to the number of partitions previously set in block 72, then a further determination is made in block 86 as to whether the partition currently under consideration is a master partition. If it is not a master partition, but instead the partition currently under consideration is a slave partition, an analysis is performed in block 88 to determine whether a corresponding master partition containing the same data is stored on the node currently under consideration. If this is not the case, but the corresponding master partition is stored on another node, an analysis is performed in block 90 as to the relevant diversity of other slave partitions stored on the node currently under consideration.

[0076] Diversity refers to the degree to which the master partitions corresponding to the slave partitions on a particular node are evenly distributed among the other nodes. Complete or maximum diversity means that each master partition corresponding to the slave partition on a particular node is stored on a separate single node in the cluster. That is, both master partitions corresponding to the slave partition stored on a particular node are stored on any single node in the cluster.

[0077] The analysis performed at box 90 may, for example, determine the presence of diversity ("diversity = 1") when there is no master node corresponding to any slave node stored on the node under consideration, as well as the master partition of the slave partition being considered for placement, which is also stored on the same node. Otherwise, for example, diversity may be determined to be non-existent ("diversity = 0"). This approach is a greedy algorithm because it determines the placement of a particular slave partition based only on the diversity of the particular slave partition. Therefore, the result may not be globally optimal. In an optional embodiment, the analysis performed at box 90 may, for example, further determine that diversity exists when there are no two master partitions corresponding to the slave partition on the node under consideration stored on any single node in the cluster.

[0078] If the diversity determination is not present in block 90, or, on the other hand, if the corresponding primary partition to be stored on the same node is determined in block 88, then the node number variable in block 92 is incremented by one and the program continues to block 88. Otherwise, if the diversity determination is present in block 90, or if the determination in block 82 is that the number of partitions currently under consideration is greater than the number of partitions previously set in block 72, then the primary or secondary partition under consideration is placed in block 94 on the node having a number resulting from performing a modulo operation on the sum of the value stored in the node number variable plus the value stored in the skew variable compared to the value stored in the node number variable:

[0079] Placement = (number of nodes considered + skew variable value) mod (number of nodes in the cluster)

[0080] =(i+tilt) mod N

[0081] Now refer to Figure 8 , showing a Figure 1 Flowchart of the apparatus 10 used in order to implement the partition placement algorithm described in the present invention after a node fails or is disconnected from the network in a database. Before executing the partition placement algorithm after a node fails or is disconnected, the slave partitions corresponding to the master partitions previously stored on the failed or disconnected node should be promoted to the master state on the same node where those slave partitions are stored. The following process is then performed with respect to each newly promoted master partition and with respect to each slave partition previously stored on the failed or disconnected node when these partitions are replicated.

[0082] The partition placement procedure begins at box 100, "Start Failover Redistribution." In box 102, two counting variables, the first indicating the node number currently being considered (e.g., "i") and the second indicating the partition number currently being considered (e.g., "j"), are set equal to the value "1".

[0083] An analysis is performed in block 104 to determine whether a corresponding master partition containing the same data as the slave node currently under consideration is stored on the node currently under consideration. If this is not the case, but the corresponding master partition is stored on another node, an analysis of the diversity associated with other slave partitions stored on the node currently under consideration is performed in block 106, the diversity being linked to block 90 as described above. The above-mentioned diversity analysis may determine the presence of diversity ("diversity = 1"), for example, in the case where no master node corresponding to any slave node stored on the node under consideration is also stored on the same node as the master partition of the slave partition under consideration for placement.

[0084] If the analysis in box 106 determines that diversity exists with respect to the slave partition currently under consideration, then an analysis is performed in box 108 regarding the current rank associated with the node currently under consideration, as described above. The rank analysis may, for example, determine that the node is eligible for partition placement if the current value of its rank is less than a maximum acceptable value. If the analysis in box 108 determines that the rank of the node under consideration has not yet reached an acceptable maximum rank, then the slave partition under consideration is placed on the node under consideration in box 110. In block 112, the node number and partition number count variables are incremented by an increment value of 1 in box 114, and the program continues in box 104 with the next replicated partition.

[0085] Otherwise, if the analysis in box 104 determines that the corresponding primary partition is stored on the same node, or if it is determined that diversity does not exist in box 106, or if it is determined that the level of the node under consideration has reached the maximum acceptable value in box 108, then the node number count variable (i) is increased by the increment value 1 in box 112, and the program continues in box 104 by considering the placement of the slave partition on the next node.

[0086] Now refer to Fig. 9 , showing a Figure 1 Flowchart of the apparatus 10 used to implement the partition placement algorithm described in the present invention after an additional node has been inserted into the database cluster. The following procedure is performed with respect to the minimum number of master partitions to be transferred to the newly added node and with respect to the minimum number of slave partitions to be transferred to the newly added node. The process begins at box 120, "Start Insert Redistribution". In box 122, slave partition "j" is selected to be moved to the newly added node "i" based on the lack of diversity of the slave partitions at the initial position or the current position.

[0087] For example, the specific master and slave partitions to be moved to the newly inserted node may preferably be determined using the diversity of each node before the additional node is inserted. The diversity for the master partition is considered to be the same as the diversity of the corresponding slave partition, or equivalently, the diversity of the corresponding slave partition is also used for the corresponding master partition. Thus, for example, an array may be created to represent the diversity of each node, and those partitions whose nodes lack diversity or have a diversity equal to zero may be given priority for transfer to the newly added node in order to increase the diversity of those nodes. Alternatively, a round-robin algorithm ( Fig. 9 ) can be used to determine the placement of master and slave partitions on newly added nodes.

[0088] In block 124, if a master partition is being considered for transfer to the newly added node, a determination is made as to whether a corresponding slave partition containing the same data as the currently considered slave node is stored on the newly added node. Accordingly, if a slave partition is being considered for transfer to the newly added node, a determination is made as to whether a corresponding master partition containing the same data as the currently considered slave node is stored on the newly added node.

[0089] If this is not the case, and the corresponding master or slave partition is stored on another node, an analysis is performed in block 126 as to whether diversity exists with respect to the selected partition and other partitions stored on the newly added node. If the analysis in block 126 determines that diversity exists with respect to the partition currently under consideration, an analysis is performed in block 128 as to the current rank associated with the newly added node, as described above. The rank analysis may, for example, determine that the newly added node is eligible for partition placement if the current value of its rank is less than a maximum acceptable value.

[0090] If the analysis in block 128 determines that the rank of the newly added node has not yet reached an acceptable maximum rank, then the partition under consideration in block 130 is placed on the newly added node, and the process continues by selecting another master partition or slave partition to be considered for transfer to the newly added node in block 122. Otherwise, if the analysis in block 124 determines that the corresponding master partition or slave partition is stored on the newly added node, or if it is determined that diversity does not exist in block 126, or if it is determined that the rank of the newly added node has not yet reached a maximum acceptable value in block 128, then the process continues by selecting another master partition or slave partition to be considered for transfer to the newly added node in block 122.

[0091] Aspects of the present invention are described with reference to flowcharts or block diagrams, wherein each block or any combination of blocks may be implemented by computer program instructions. The instructions may be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to implement the production of a machine or article, and when executed by the processor, the instructions create a method for implementing the functions, actions or events specified in each block or combination of multiple blocks.

[0092] In this regard, each box in the flow chart or block diagram may correspond to a module, segment or part of code including one or more executable instructions for implementing the specified logical function (s). It should also be noted that in some alternative embodiments, the function associated with any box may occur out of the order indicated in the figure. For example, two boxes shown in succession may actually be executed roughly at the same time, or boxes may sometimes be executed in the opposite order.

[0093] Persons of ordinary skill in the art will appreciate that aspects of the present invention may be embodied as devices, systems, methods, or computer program products. Therefore, aspects of the present invention, generally referred to herein as circuits, modules, components, or systems, may be embodied in hardware, software (including firmware, resident software, microcode, etc.), or in any combination of software and hardware, including computer program products embodied in a computer-readable medium having computer-readable program code.

[0094] In this regard, any combination of one or more computer readable media may be utilized, including, but not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any suitable combination of the foregoing. More specific examples of computer readable storage media include the following non-exhaustive list: portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, portable compact disk read-only memory (CD-ROM), optical storage devices, network-attached storage (NAS), storage area network (SAN), magnetic tape, or any suitable combination of the foregoing. In the context of the present invention, computer readable storage media may include any tangible medium capable of containing or storing program instructions used by or in connection with a data processing system, device, or apparatus.

[0095] The computer program code for realizing the operation of various aspects of the present invention can be written with any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, Smalltalk or C++, and traditional procedural programming languages ​​such as "C", FORTRAN, COBOL or Pascal. The program code can be executed completely on a personal computer as an independent software package, partially on a client computer and partially on a remote server computer, and completely on a cluster of remote servers or computers or distributed computer nodes. Generally speaking, the cluster of remote computers, servers or distributed computer nodes can be connected to a personal (user) computer through any type of network, including a local area network (local area network, referred to as LAN), a wide area network (wide area network, referred to as WAN), an Internet access point, or any combination thereof.

[0096] In an exemplary embodiment, a device is used to distribute multiple data partitions among a group of computer nodes. The device includes: a partitioning module for partitioning a database into multiple primary partitions; a primary storage module for storing the primary partitions on multiple nodes associated with a computer network, wherein the primary partitions are roughly evenly distributed among the nodes, and the primary partitions can be used to serve system workloads; a replication module for replicating the primary partitions to create multiple slave partitions; a slave storage module for storing the slave partitions on the nodes, wherein the slave partitions are roughly evenly distributed among the nodes, each slave partition is stored on a different node with its corresponding primary partition, each slave partition has a diversity with the node storing the slave partition, and one or more slave partitions corresponding to one or more primary partitions of a failed node can be used to upgrade to a master state after a node in the computer node fails to maintain workload balance and data availability. In some embodiments, the device may include other or additional modules for completing any one or a combination of the steps described in the embodiments.

[0097] It is understood that various modifications may be made. For example, if the steps of the disclosed techniques are performed in a different order, and / or if the components in the disclosed systems are combined in a different manner, and / or replaced or supplemented by other components, useful results may still be achieved. Therefore, other implementations are within the scope of the following claims.

Claims

1. A method for distributing multiple data partitions among computer nodes, It is characterized in that The method comprises: Divide the database into multiple primary partitions; storing the plurality of primary partitions on a plurality of nodes, the plurality of primary partitions being used to serve system workloads; Copying the plurality of master partitions to create a plurality of slave partitions corresponding to the plurality of master partitions, each master partition having a corresponding slave partition; storing the plurality of slave partitions on the plurality of nodes, wherein each of the plurality of nodes stores the same number of master partitions and slave partitions, and each slave partition and its corresponding master partition are stored on different nodes; When one of the multiple nodes fails, one or more slave partitions corresponding to the one or more master partitions of the failed node are upgraded to a master state; Creating a new slave partition for the one or more slave partitions upgraded to the master state, wherein the created new slave partition is a copy of the one or more slave partitions upgraded to the master state; The created new slave partitions are distributed to multiple nodes, and each new slave partition and its corresponding slave partition upgraded to the master state are stored on different nodes.

2. The method according to claim 1, It is characterized in that Also includes: Creating one or more new slave partitions corresponding to the one or more slave partitions originally stored on the failed node, wherein the created new slave partitions are copies of the one or more slave partitions originally stored on the failed node; The created new slave partitions are distributed to multiple nodes, and each new slave partition and its corresponding master partition are stored on different nodes.

3. The method according to claim 1 or 2, It is characterized in that A query directed to the primary partition of the failed node is redirected to a specific node, where the specific node is a node storing the secondary partition corresponding to the primary partition of the failed node.

4. The method according to any one of claims 1 to 2, It is characterized in that The newly created slave partitions are evenly distributed to multiple nodes.

5. The method according to any one of claims 1 to 2, It is characterized in that Multiple slave partitions corresponding to multiple master partitions stored on one node are stored on different nodes respectively.

6. A computer program product comprising computer instructions, It is characterized in that When the computer instructions are executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.

7. A device for distributing a plurality of data partitions among computer nodes, It is characterized in that The device comprises: Partitioner, used to divide the database into multiple primary partitions; A replicator, for replicating the master partition to create a plurality of slave partitions, each master partition having a corresponding slave partition; An initial distributor is used to store the multiple master partitions and the multiple slave partitions on multiple nodes, wherein the master partitions can be used to serve the system workload, each of the multiple nodes stores the same number of master partitions and slave partitions, and when one of the multiple nodes fails, one or more slave partitions corresponding to the one or more master partitions of the failed node are upgraded to a master state; The replicator is further used to create a new slave partition for the one or more slave partitions upgraded to the master state, wherein the created new slave partition is a copy of the one or more slave partitions upgraded to the master state; The device further comprises: a failover distributor, which is used to distribute the created new slave partitions to a plurality of nodes, and each new slave partition and its corresponding slave partition upgraded to the master state are stored on different nodes.

8. The device according to claim 7, It is characterized in that The replicator is further used to create one or more new slave partitions corresponding to one or more slave partitions originally stored on the failed node, wherein the created new slave partitions are copies of the one or more slave partitions originally stored on the failed node; The failover distributor is also used to distribute the created new slave partitions to multiple nodes, and each new slave partition and its corresponding master partition are stored on different nodes.

9. The device according to claim 8, It is characterized in that A query directed to the primary partition of the failed node is redirected to a specific node, where the specific node is a node storing the secondary partition corresponding to the primary partition of the failed node.

10. The device according to any one of claims 7 to 9, It is characterized in that The newly created slave partitions are evenly distributed to multiple nodes.

11. The device according to any one of claims 7 to 9, It is characterized in that Multiple slave partitions corresponding to multiple master partitions stored on one node are stored on different nodes respectively.

12. A non-transitory computer-readable storage medium having a computer program / instructions stored thereon, It is characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.

13. A method for distributing a plurality of data partitions among computer nodes, It is characterized in that The method comprises: Divide the database into multiple primary partitions; Distributing the plurality of primary partitions to a plurality of nodes, the plurality of primary partitions being used to serve system workloads; Copying the plurality of master partitions to create a plurality of slave partitions corresponding to the plurality of master partitions, each master partition having a corresponding slave partition; Distributing the multiple slave partitions to the multiple nodes, wherein each of the multiple nodes is distributed with the same number of master partitions and slave partitions, and each slave partition and its corresponding master partition are distributed on different nodes; When a new node is added, the multiple master partitions and the multiple slave partitions are redistributed to the multiple nodes and the newly added node. After the redistribution, each node is distributed with the same number of master partitions and slave partitions, and each slave partition and its corresponding master partition are distributed on different nodes.

14. The method according to claim 13, It is characterized in that Also includes: Based on the number of master partitions and slave partitions, as well as the number of nodes, calculate the minimum number of partitions that need to be redistributed.

15. The method according to claim 13 or 14, It is characterized in that Multiple slave partitions corresponding to multiple master partitions stored on one node are stored on different nodes respectively.

16. A non-transitory computer-readable storage medium having a computer program / instructions stored thereon, It is characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 13 to 15 are implemented.

17. A computer program product comprising computer instructions, It is characterized in that When the computer instructions are executed by a processor, the steps of the method according to any one of claims 13 to 15 are implemented.