Partition splitting management method and device applied to distributed database
By building the target partition within the same consensus protocol group in a distributed database and sharing log flow, the problem of complex partitioning and difficult to guarantee data consistency is solved, and efficient partitioning and reducing the complexity of consensus protocols is achieved.
Patent Information
- Application Number
- CN202411246654.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-05
- Publication Date
- 2025-01-10
AI Technical Summary
In distributed databases, the partition splitting process is complex and increases the complexity of consensus protocols, especially because of the need to split the partitioned log stream, which leads to inefficiency and data consistency difficult to guarantee.
By building the destination partition within the same consensus protocol group and sharing the log stream, the source partition and the destination partition belong to the same log stream, thereby avoiding the classification of the log stream, simplifying the partition splitting process, and reducing the complexity of the consensus protocol.
It improves the efficiency of partition splitting, reduces the complexity of partition splitting in consensus protocol groups, and ensures data consistency during partition splitting.
Smart Images

Figure CN119293121A_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to the field of database technology, and more particularly, to a partition splitting management method and device applied to a distributed database. Background Art
[0002] With the rapid development of the Internet and informatization, the generation of data is growing explosively, so the requirements for databases and their management are getting higher and higher. The data tables in the database can be divided into different partitions to improve data management efficiency, such as the efficiency of data query; and with the continuous service of the business, the amount of data in each partition becomes uneven. A single hotspot partition will cause a performance bottleneck for reading and writing, and a large number of small partitions and empty partitions will cause space fragmentation. At this time, partition splitting and partition merging are usually performed to make the partitions on the table more uniform, thereby providing higher performance.
[0003] However, in the related technology, the partition log stream also needs to be split when the partition is split, that is, a log stream is constructed for each destination partition, and the logs belonging to different destination partitions in the log stream of the source partition are transferred to the corresponding log streams respectively. This makes the partition splitting operation more complicated, especially in the distributed database scenario, which will increase the complexity of the consensus protocol. Summary of the invention
[0004] In view of this, one or more embodiments of the present specification provide a partition splitting management method and device applied to a distributed database.
[0005] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions:
[0006] According to a first aspect of one or more embodiments of this specification, a partition splitting management method applied to a distributed database is proposed, the method comprising:
[0007] Receive a split instruction for a source partition, and construct multiple destination partitions in the consensus protocol group where the source partition is located, wherein the consensus protocol group includes at least one database instance, each database instance has a log stream for recording data operation logs of all partitions in the database instance, and the data of multiple database instances in the consensus protocol group are the same and share the same log stream;
[0008] Dividing the data in the source partition into the multiple destination partitions according to the split instruction;
[0009] If all data in the source partition is partitioned, the source partition is deleted.
[0010] In one or more embodiments of the present specification, the receiving a split instruction for a source partition and constructing a plurality of destination partitions in the consensus protocol group where the source partition is located includes:
[0011] A split instruction for a source partition is received, and a plurality of destination partitions are constructed in the consensus protocol group where the source partition is located according to the number of destination partitions indicated in the split instruction.
[0012] In one or more embodiments of the present specification, the receiving a split instruction for a source partition and constructing a plurality of destination partitions in the consensus protocol group where the source partition is located includes:
[0013] Receive a split instruction for a source partition, build multiple destination partitions in a leader instance in the consensus protocol group where the source partition is located, and write the operation of building the multiple destination partitions into a log stream;
[0014] The log stream is shared to other database instances in the consensus protocol group according to the consensus protocol of the consensus protocol group, so that other database instances can locally construct the multiple destination partitions by replaying the log stream.
[0015] In one or more embodiments of the present specification, the receiving a split instruction for a source partition and constructing a plurality of destination partitions in the consensus protocol group where the source partition is located includes:
[0016] If a split instruction for a source partition is received, and there is no partition migration operation on the source partition, multiple destination partitions are constructed within the consensus protocol group where the source partition is located.
[0017] In one or more embodiments of the present specification, dividing the data in the source partition into the multiple destination partitions according to the split instruction includes:
[0018] According to the mapping relationship between the data indicated in the split instruction and the target partition, each data in the source partition is divided into the corresponding target partition.
[0019] In one or more embodiments of the present specification, dividing the data in the source partition into the multiple destination partitions according to the split instruction includes:
[0020] The data in the memory table of the source partition is flushed to the ordered string table of the source partition, and the data in the ordered string table of the source partition is divided into the multiple destination partitions.
[0021] In one or more embodiments of the present specification, the method further includes:
[0022] A data write instruction for the source partition is received, and the data indicated by the data write instruction is written into the corresponding destination partition.
[0023] In one or more embodiments of the present specification, the receiving a data write instruction for the source partition, and writing the data indicated by the data write instruction into the corresponding destination partition, includes:
[0024] A data write instruction for the source partition is received, and according to a mapping relationship between the data indicated in the split instruction and the target partition, the data indicated by the data write instruction is written into the corresponding target partition.
[0025] In one or more embodiments of the present specification, the method further includes:
[0026] If the data in the source partition is not completely partitioned and a partition migration operation for the source partition is received, prohibiting the partition migration operation;
[0027] If the data in the source partition is not completely partitioned, and a partition migration operation for any destination partition is received, the partition migration operation is delayed until the source partition is deleted.
[0028] According to a first aspect of one or more embodiments of this specification, a partition split management device applied to a distributed database is provided, the device comprising:
[0029] A construction module, configured to receive a split instruction for a source partition, and construct multiple destination partitions in a consensus protocol group where the source partition is located, wherein the consensus protocol group includes multiple database instances, each database instance has a log stream that records transactions in all partitions, and multiple database instances in the consensus protocol group share the same log stream;
[0030] A partitioning module, used for partitioning the data in the source partition into the multiple destination partitions according to the splitting instruction;
[0031] The deletion module is used to delete the source partition if all data in the source partition has been partitioned.
[0032] In one or more embodiments of the present specification, the building blocks are used to:
[0033] A split instruction for a source partition is received, and a plurality of destination partitions are constructed in the consensus protocol group where the source partition is located according to the number of destination partitions indicated in the split instruction.
[0034] In one or more embodiments of the present specification, the building blocks are used to:
[0035] Receive a split instruction for a source partition, build multiple destination partitions in a leader instance in the consensus protocol group where the source partition is located, and write the operation of building the multiple destination partitions into a log stream;
[0036] The log stream is shared to other database instances in the consensus protocol group according to the consensus protocol of the consensus protocol group, so that other database instances can locally construct the multiple destination partitions by replaying the log stream.
[0037] In one or more embodiments of the present specification, the building blocks are used to:
[0038] If a split instruction for a source partition is received, and there is no partition migration operation on the source partition, multiple destination partitions are constructed within the consensus protocol group where the source partition is located.
[0039] In one or more embodiments of this specification, the partitioning module is used to:
[0040] According to the mapping relationship between the data indicated in the split instruction and the target partition, each data in the source partition is divided into the corresponding target partition.
[0041] In one or more embodiments of this specification, the partitioning module is used to:
[0042] The data in the memory table of the source partition is flushed to the ordered string table of the source partition, and the data in the ordered string table of the source partition is divided into the multiple destination partitions.
[0043] In one or more embodiments of the present specification, the device further includes a writing module, configured to:
[0044] A data write instruction for the source partition is received, and the data indicated by the data write instruction is written into the corresponding destination partition.
[0045] In one or more embodiments of the present specification, the writing module is used to:
[0046] A data write instruction for the source partition is received, and according to a mapping relationship between the data indicated in the split instruction and the target partition, the data indicated by the data write instruction is written into the corresponding target partition.
[0047] In one or more embodiments of the present specification, the apparatus further includes a migration processing module, configured to:
[0048] If the data in the source partition is not completely partitioned and a partition migration operation for the source partition is received, prohibiting the partition migration operation;
[0049] If the data in the source partition is not completely partitioned, and a partition migration operation for any destination partition is received, the partition migration operation is delayed until the source partition is deleted.
[0050] According to a third aspect of one or more embodiments of this specification, a computer program product is provided, comprising a computer program / instruction, which implements the steps of the method described in the first aspect when executed by a processor.
[0051] According to a fourth aspect of one or more embodiments of this specification, an electronic device is provided, including:
[0052] processor;
[0053] a memory for storing processor-executable instructions;
[0054] The processor implements the method as described in the first aspect by running the executable instructions.
[0055] According to a fifth aspect of one or more embodiments of the present specification, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method described in the first aspect are implemented.
[0056] The technical solutions provided by the embodiments of this specification may have the following beneficial effects:
[0057] In the partition splitting management method applied to a distributed database provided in the embodiments of the present specification, the consensus protocol group of the distributed database is composed of database instances rather than partitions, and each database instance in the consensus protocol group has a log stream for recording transaction logs of all partitions therein, and the data of different database instances in the consensus protocol group are the same and share the same log stream; and the method constructs a destination partition in the same consensus protocol group when the partition is split, so that the source partition and the destination partition belong to the same consensus protocol group, and the log streams of the source partition and the destination partition belong to the same log stream, that is, the log stream shared in the consensus protocol group, then the partition splitting no longer involves the classification of the log stream, thereby improving the efficiency of the partition splitting and reducing the complexity of the consensus protocol group regarding the partition splitting. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 It is a structural diagram of a distributed database provided by an exemplary embodiment.
[0059] Figure 2 It is a flowchart of a partition splitting management method applied to a distributed database provided by an exemplary embodiment.
[0060] Figure 3 It is a diagram of a distributed database architecture provided by an exemplary embodiment.
[0061] Figure 4 It is a structural schematic diagram of a device provided by an exemplary embodiment.
[0062] Figure 5 It is a block diagram of a partition split management device applied to a distributed database provided by an exemplary embodiment. DETAILED DESCRIPTION
[0063] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0064] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.
[0065] In the distributed database in the related technology, the data table has multiple partitions, and different copies of each partition form a partition consensus protocol group. The partition consensus protocol group shares a log stream for recording all operation logs in the partition, and the sharing of the log stream in the partition depends on the consensus protocol of the partition consensus protocol group. When a partition is split, the source partition is replaced by multiple destination partitions, and the data in the source partition is transferred to multiple destination partitions for storage. As for the log stream of the source partition, it will also be split into multiple log streams corresponding to multiple destination partitions, which makes the partition splitting process more complicated, and requires the above consensus protocol to ensure data consistency during the above partition splitting process, which undoubtedly makes the consensus protocol very complicated.
[0066] Based on this, at least one embodiment of the present specification provides a partition splitting management method applied to a distributed database, which can simplify the partition splitting process in the distributed database, while avoiding the partition splitting adding complexity to the consensus protocol of the consensus protocol group, thereby improving the efficiency of the partition splitting and ensuring data consistency during the partition splitting process.
[0067] This method can be applied to Figure 1The distributed database based on the LSM-Tree storage engine shown is, for example, applied to a leader instance of the distributed database, and the distributed database includes at least one database instance.
[0068] Please refer to the attached Figure 2 , which exemplarily shows the process of the partition splitting management method applied to a distributed database, including steps S201 to S203.
[0069] In step S201, a split instruction for a source partition is received, and multiple target partitions are constructed in the consensus protocol group where the source partition is located, wherein the consensus protocol group includes at least one database instance, each database instance has a log stream for recording data operation logs of all partitions in the database instance, and the data of multiple database instances in the consensus protocol group are the same and share the same log stream.
[0070] The consensus protocol group provides services such as electing a leader instance and sharing logs through consensus protocols such as Paxos or Raft. The data of different database instances in the consensus protocol group are the same, and the log stream is shared. In the database instance, the data in the data table is divided into different partitions for storage, but the operation logs on all the data in the data table are recorded in the same log stream, that is, the log stream used to record the data operation logs of all partitions in the database instance. For example, a data table with a key range of [1,200) in the database instance is divided into two partitions with a key range of [1,100) and a key range of [101,200) for storage. The operation logs on all the data in the data table are recorded in the log stream of the database instance with the key as the identifier, but the partition where the data is located is not identified.
[0071] Please refer to the attached Figure 3 , which exemplarily shows the architecture of a distributed database to more vividly demonstrate the relationship between concepts such as database instances, consensus protocol groups, log streams, and partitions. Figure 3 The distributed database in has three availability zones, Zone1, Zone2 and Zone3; there are two database instances, instance 1 and instance 2, in availability zone Zone1, there are two database instances, instance 3 and instance 4, in availability zone Zone2, there are two database instances, instance 5 and instance 6, in availability zone Zone3; instance 1, instance 3 and instance 5 form a Paxos group, each database instance in the Paxos group has partition A, partition B, and log stream 1 for recording operation logs on all data in partition A and partition B; instance 2, instance 4 and instance 6 form a Paxos group, each database instance in the Paxos group has partition C, partition D, and log stream 2 for recording operation logs on all data in partition C and partition D.
[0072] Exemplarily, this step can be performed in the following manner: receiving a split instruction for a source partition, and constructing multiple destination partitions in the consensus protocol group where the source partition is located according to the number of destination partitions indicated in the split instruction. For example, if the split instruction indicates that the source partition is to be split into two destination partitions, then two destination partitions are constructed in the consensus protocol group where the source partition is located.
[0073] Another example is that this step can be performed in the following manner: receiving a split instruction for a source partition, building multiple destination partitions in the leader instance within the consensus protocol group where the source partition is located, and writing the operation of building multiple destination partitions into a log stream; then, sharing the log stream to other database instances within the consensus protocol group according to the consensus protocol of the consensus protocol group, so that other database instances can locally build the multiple destination partitions by replaying the log stream.
[0074] With the above attachment Figure 3 Taking the distributed database architecture shown as an example, instance 1, instance 3 and instance 5 are composed of a Paxos group and instance 1 is elected as the leader instance. If a split instruction is received to split partition A into two partitions, two destination partitions can be built on instance 1, and through log sharing, instance 3 and instance 5 can also build two destination partitions when replaying logs. The names of the two destination partitions are also the same as the names of the two destination partitions on instance 1.
[0075] With the above attachment Figure 3 Taking the distributed database architecture shown as an example, instance 2, instance 4 and instance 6 are elected as the leader instance in the Paxos group. If a split instruction is received to split partition C into two partitions, two destination partitions can be built on instance 2, and through log sharing, instance 4 and instance 6 can also build two destination partitions when replaying logs. The names of the two destination partitions are also the same as the names of the two destination partitions on instance 2.
[0076] In step S202, data in the source partition is divided into the plurality of target partitions according to the split instruction.
[0077] Exemplarily, according to the mapping relationship between the data indicated in the split instruction and the destination partition, each data in the source partition is respectively divided into the corresponding destination partition, for example, each data in the source partition is respectively copied (duplicated) to the corresponding destination partition. For example, a source partition with a key range of [1,100) is split into a destination partition 1 with a key range of [1,50) and a destination partition 2 with a key range of [51,100). Then, in this step, the data in the source partition in the key range [1,50) can be divided into the destination partition 1, and the data in the source partition in the key range [51,100) can be divided into the destination partition 2.
[0078] As another example, the data in the memory table (MemTable) of the source partition is flushed to the ordered string table (SSTable) of the source partition, and the data in the ordered string table of the source partition is divided into the multiple destination partitions. For example, in the process of flushing the data in the memory table (MemTable) of the source partition to the ordered string table (SSTable) of the source partition, the source partition can be stopped from writing, that is, the write operation is rejected.
[0079] In addition, it should be understood that in the process of dividing the data in the source partition into the multiple destination partitions, a data write instruction for the source partition is received, and the data indicated by the data write instruction can be written into the corresponding destination partition. For example, a data write instruction for the source partition is received, and according to the mapping relationship between the data indicated in the split instruction and the destination partition, the data indicated by the data write instruction is written into the corresponding destination partition.
[0080] For example, in the process of splitting a source partition with a key range of [1,100) into a destination partition 1 with a key range of [1,50) and a destination partition 2 with a key range of [51,100) , if the source partition receives a data write instruction for the key range [1,50) , the data write instruction can be forwarded to the destination partition 1, so that the destination partition 1 writes the data indicated by the data write instruction into the memory table (MemTable) of the destination partition 1.
[0081] In step 203, if all data in the source partition has been partitioned, the source partition is deleted.
[0082] In the partition splitting management method applied to a distributed database provided in the embodiments of the present specification, the consensus protocol group of the distributed database is composed of database instances rather than partitions, and each database instance in the consensus protocol group has a log stream for recording transaction logs of all partitions therein, and the data of different database instances in the consensus protocol group are the same and share the same log stream; and the method constructs a destination partition in the same consensus protocol group when the partition is split, so that the source partition and the destination partition belong to the same consensus protocol group, and the log streams of the source partition and the destination partition belong to the same log stream, that is, the log stream shared in the consensus protocol group, then the partition splitting no longer involves the classification of the log stream, thereby improving the efficiency of the partition splitting and reducing the complexity of the consensus protocol group regarding the partition splitting.
[0083] In some embodiments of the present disclosure, Figure 2 The illustrated step S201 may include: if a split instruction for a source partition is received, and there is no partition migration operation on the source partition, constructing multiple destination partitions within the consensus protocol group where the source partition is located.
[0084] In other words, if a split instruction for a source partition is received, it is necessary to determine whether there is a partition migration operation on the source partition before building the destination partition. If not, multiple destination partitions are built within the consensus protocol group where the source partition is located. This can avoid mutual interference between the partition migration operation and the partition split on the source partition, further ensuring data consistency.
[0085] In some embodiments of the present disclosure, the partition splitting management method applied to a distributed database also includes: if the data within the source partition is not completely divided and a partition migration operation for the source partition is received, prohibiting the partition migration operation; if the data within the source partition is not completely divided and a partition migration operation for any destination partition is received, delaying the partition migration operation until the source partition is deleted.
[0086] This can avoid interference between partition migration operations and partition splitting on the source partition, further ensuring data consistency.
[0087] Figure 4 is a schematic structural diagram of a device provided by an exemplary embodiment. Figure 4At the hardware level, the device includes a processor 402, an internal bus 404, a network interface 406, a memory 408, and a non-volatile memory 410, and may also include hardware required for other tasks. One or more embodiments of this specification may be implemented based on software, such as the processor 402 reading the corresponding computer program from the non-volatile memory 410 into the memory 408 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0088] Please refer to Figure 5 The partition split management device applied to a distributed database can be applied to Figure 4 The device shown in the figure is used to implement the technical solution of this specification. The partition split management device applied to a distributed database may include:
[0089] A construction module 501 is used to receive a split instruction for a source partition, and to construct multiple destination partitions in a consensus protocol group where the source partition is located, wherein the consensus protocol group includes multiple database instances, each database instance has a log stream that records transactions in all partitions, and multiple database instances in the consensus protocol group share the same log stream;
[0090] A partitioning module 502, configured to partition the data in the source partition into the plurality of destination partitions according to the split instruction;
[0091] The deletion module 503 is used to delete the source partition if all the data in the source partition has been partitioned.
[0092] In one or more embodiments of the present specification, the building blocks are used to:
[0093] A split instruction for a source partition is received, and a plurality of destination partitions are constructed in the consensus protocol group where the source partition is located according to the number of destination partitions indicated in the split instruction.
[0094] In one or more embodiments of the present specification, the building blocks are used to:
[0095] Receive a split instruction for a source partition, build multiple destination partitions in a leader instance in the consensus protocol group where the source partition is located, and write the operation of building the multiple destination partitions into a log stream;
[0096] The log stream is shared to other database instances in the consensus protocol group according to the consensus protocol of the consensus protocol group, so that other database instances can locally construct the multiple destination partitions by replaying the log stream.
[0097] In one or more embodiments of the present specification, the building blocks are used to:
[0098] If a split instruction for a source partition is received, and there is no partition migration operation on the source partition, multiple destination partitions are constructed within the consensus protocol group where the source partition is located.
[0099] In one or more embodiments of this specification, the partitioning module is used to:
[0100] According to the mapping relationship between the data indicated in the split instruction and the target partition, each data in the source partition is divided into the corresponding target partition.
[0101] In one or more embodiments of this specification, the partitioning module is used to:
[0102] The data in the memory table of the source partition is flushed to the ordered string table of the source partition, and the data in the ordered string table of the source partition is divided into the multiple destination partitions.
[0103] In one or more embodiments of the present specification, the device further includes a writing module, configured to:
[0104] A data write instruction for the source partition is received, and the data indicated by the data write instruction is written into the corresponding destination partition.
[0105] In one or more embodiments of the present specification, the writing module is used to:
[0106] A data write instruction for the source partition is received, and according to a mapping relationship between the data indicated in the split instruction and the target partition, the data indicated by the data write instruction is written into the corresponding target partition.
[0107] In one or more embodiments of the present specification, the apparatus further includes a migration processing module, configured to:
[0108] If the data in the source partition is not completely partitioned and a partition migration operation for the source partition is received, prohibiting the partition migration operation;
[0109] If the data in the source partition is not completely partitioned, and a partition migration operation for any destination partition is received, the partition migration operation is delayed until the source partition is deleted.
[0110] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.
[0111] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0112] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0113] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0114] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0115] The above is a description of a specific embodiment of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0116] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0117] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0118] It should be understood that although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of this specification, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0119] The above description is merely a preferred embodiment of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present specification shall be included in the scope of protection of one or more embodiments of the present specification.
Claims
1. A partition splitting management method applied to a distributed database, the method comprising: Receive a split instruction for a source partition, and construct multiple destination partitions in the consensus protocol group where the source partition is located, wherein the consensus protocol group includes at least one database instance, each database instance has a log stream for recording data operation logs of all partitions in the database instance, and the data of multiple database instances in the consensus protocol group are the same and share the same log stream; Dividing the data in the source partition into the multiple destination partitions according to the split instruction; If all data in the source partition is partitioned, the source partition is deleted.
2. According to the partition splitting management method applied to a distributed database according to claim 1, the receiving of a splitting instruction for a source partition and constructing a plurality of destination partitions in the consensus protocol group where the source partition is located comprises: A split instruction for a source partition is received, and a plurality of destination partitions are constructed in the consensus protocol group where the source partition is located according to the number of destination partitions indicated in the split instruction.
3. According to the partition splitting management method applied to a distributed database according to claim 1 or 2, the receiving of a splitting instruction for a source partition and constructing a plurality of destination partitions in the consensus protocol group where the source partition is located comprises: Receive a split instruction for a source partition, build multiple destination partitions in a leader instance in the consensus protocol group where the source partition is located, and write the operation of building the multiple destination partitions into a log stream; The log stream is shared with other database instances in the consensus protocol group according to the consensus protocol of the consensus protocol group, so that other database instances can locally construct the multiple destination partitions by replaying the log stream.
4. According to the partition splitting management method applied to a distributed database according to claim 1, the receiving of a splitting instruction for a source partition and constructing a plurality of destination partitions in the consensus protocol group where the source partition is located comprises: If a split instruction for a source partition is received, and there is no partition migration operation on the source partition, multiple destination partitions are constructed within the consensus protocol group where the source partition is located.
5. The partition splitting management method for a distributed database according to claim 1, wherein the step of dividing the data in the source partition into the plurality of destination partitions according to the splitting instruction comprises: According to the mapping relationship between the data indicated in the split instruction and the target partition, each data in the source partition is divided into the corresponding target partition.
6. According to the partition splitting management method applied to a distributed database according to claim 1 or 5, the step of dividing the data in the source partition into the plurality of destination partitions according to the splitting instruction comprises: The data in the memory table of the source partition is flushed to the ordered string table of the source partition, and the data in the ordered string table of the source partition is divided into the multiple destination partitions.
7. The partition splitting management method applied to a distributed database according to claim 1, further comprising: A data write instruction for the source partition is received, and the data indicated by the data write instruction is written into the corresponding destination partition.
8. The partition splitting management method for a distributed database according to claim 7, wherein the receiving a data write instruction for the source partition and writing the data indicated by the data write instruction into the corresponding destination partition comprises: A data write instruction for the source partition is received, and according to a mapping relationship between the data indicated in the split instruction and the target partition, the data indicated by the data write instruction is written into the corresponding target partition.
9. The partition splitting management method applied to a distributed database according to claim 1, further comprising: If the data in the source partition is not completely partitioned and a partition migration operation for the source partition is received, prohibiting the partition migration operation; If the data in the source partition is not completely partitioned, and a partition migration operation for any destination partition is received, the partition migration operation is delayed until the source partition is deleted.
10. A partition split management device applied to a distributed database, the device comprising: A construction module, configured to receive a split instruction for a source partition, and construct multiple destination partitions in a consensus protocol group where the source partition is located, wherein the consensus protocol group includes multiple database instances, each database instance has a log stream that records transactions in all partitions, and multiple database instances in the consensus protocol group share the same log stream; A partitioning module, used for partitioning the data in the source partition into the multiple destination partitions according to the splitting instruction; The deletion module is used to delete the source partition if all the data in the source partition has been partitioned.
11. The partition splitting management device applied to a distributed database according to claim 10, wherein the construction module is used for: Receive a split instruction for a source partition, build multiple destination partitions in a leader instance in the consensus protocol group where the source partition is located, and write the operation of building the multiple destination partitions into a log stream; The log stream is shared to other database instances in the consensus protocol group according to the consensus protocol of the consensus protocol group, so that other database instances can locally construct the multiple destination partitions by replaying the log stream.
12. The partition splitting management device applied to a distributed database according to claim 10, wherein the construction module is used for: If a split instruction for a source partition is received, and there is no partition migration operation on the source partition, multiple destination partitions are constructed within the consensus protocol group where the source partition is located.
13. The partition splitting management device for a distributed database according to claim 10, wherein the partitioning module is used for: The data in the memory table of the source partition is flushed to the ordered string table of the source partition, and the data in the ordered string table of the source partition is divided into the multiple destination partitions.
14. The partition split management device for a distributed database according to claim 10, further comprising a writing module, configured to: A data write instruction for the source partition is received, and the data indicated by the data write instruction is written into the corresponding destination partition.
15. The partition split management device for a distributed database according to claim 10, further comprising a migration processing module, configured to: If the data in the source partition is not completely partitioned and a partition migration operation for the source partition is received, prohibiting the partition migration operation; If the data in the source partition is not completely partitioned, and a partition migration operation for any destination partition is received, the partition migration operation is delayed until the source partition is deleted.
16. A computer program product comprising a computer program / instructions, which when executed by a processor implement the steps of the method according to any one of claims 1 to 9.
17. An electronic device comprising: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 9 by running the executable instructions.
18. A computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 9.
Citation Information
Cited By
Partition splitting management method and apparatus applied to distributed database
WO2026052071A1