CN-122019553-A - Processing method and device for index change operation of distributed database
Abstract
The specification discloses a method and a device for processing index change operation of a distributed database. According to the scheme, the distributed database comprises a main node and a target node, index data in the distributed database has corresponding data index information, wherein the data index information comprises a logic index address and a corresponding physical storage address, the storage space corresponding to the physical storage address stores the index data, based on the data index information, in the process of executing index change operation of the distributed database, the main node sends an index change command to the target node, so that the target node acquires the corresponding index data and the logic index address of the index data according to the index change command, and stores the acquired index data again, then a first type corresponding relation between the physical storage address and the logic index address which are redistributed to the index data is established, and finally, the index change operation of the distributed database is executed based on the corresponding relation.
Inventors
- XU QUANQING
- Hu Tianxun
- YANG CHUANHUI
Assignees
- 北京奥星贝斯科技有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260112
Claims (14)
- 1. A method for processing index change operation of a distributed database, where the distributed database includes a master node and a target node, and index data in the distributed database has corresponding data index information, where the data index information includes a logical index address and a corresponding physical storage address, and a storage space corresponding to the physical storage address stores the index data, and the method includes: the master node sends an index change command to the target node; the target node acquires corresponding index data and a logic index address of the index data according to the index change command, and re-stores the acquired index data and establishes a first type corresponding relation between a physical storage address re-allocated for the index data and the logic index address; and the target node executes the index change operation of the distributed database based on the corresponding relation.
- 2. The method of claim 1, wherein the index data is recorded in an index table, and wherein the logical index address of the index data is a row identification of the index data in the index table.
- 3. The method of claim 1, wherein the index data has a logical index address that is an offset of a physical storage address of the index data relative to a uniform starting physical storage address.
- 4. The method of claim 1, wherein the index data includes logical index addresses of other index data to which the index data refers, or wherein the index data includes logical addresses of table data to which the index data refers.
- 5. The method of claim 4, the method further comprising: when the index data contains the logic address of the table data referenced by the index data, the target node establishes a second type corresponding relation between the physical storage address allocated for the table data and the logic address of the table data contained in the index data; the target node executes the index change operation of the distributed database based on the corresponding relation, and specifically comprises the following steps: And the target node executes the index change operation of the distributed database based on the first class corresponding relation and the second class corresponding relation.
- 6. The method of claim 1, wherein the master node sends an index change command to the target node, specifically comprising: the master node determines an index key range of an index to be processed for executing the index change operation of the distributed database; Aiming at the target node and other nodes in the distributed database, which need to execute the index change operation of the distributed database, the main node divides the index key range into sub-index key ranges corresponding to all nodes; And sending an index change command to the target node according to the sub-index key range corresponding to the target node.
- 7. The method of claim 1, wherein checkpoint files generated during execution of the distributed database index change operation by the target node are stored in designated storage nodes, the designated storage nodes comprising the master node, shared storage nodes contained in the distributed database.
- 8. The method of claim 7, the method further comprising: when the main node monitors that the target node is abnormal, the main node reselects other nodes from the distributed database to replace the target node, and sends a recovery index change command to the other nodes; The other nodes acquire the check point file according to the received recovery index change command; And performing data playback according to the check point file to obtain index data when the target node is abnormal, and continuously executing the index change operation of the distributed database based on the index data obtained by playback.
- 9. A method for processing a distributed database index creation operation, where the distributed database includes a master node and a target node, and index data in the distributed database has corresponding data index information, where the data index information includes a logical index address and a corresponding physical storage address, and a storage space corresponding to the physical storage address stores the index data, the method includes: the master node sends an index creation command to the target node; The target node executes distributed database index creation operation according to the index creation command to create index data and data index information corresponding to the index data and returns the index data; The master node receives the index data created by the target node and the logical index address of the index data, and re-stores the obtained index data, and establishes a first type corresponding relation between the physical storage address re-allocated for the index data and the logical index address.
- 10. A processing apparatus for a distributed database index change operation, the distributed database including a master node and a target node, index data in the distributed database having corresponding data index information, the data index information including a logical index address and a corresponding physical storage address, the storage space corresponding to the physical storage address storing the index data, the apparatus comprising: a sending module, configured to send an index change command to the target node through the master node; The updating module is used for acquiring corresponding index data and a logic index address of the index data through the target node according to the index change command, and re-storing the acquired index data and establishing a first type corresponding relation between a physical storage address re-allocated for the index data and the logic index address; And the execution module is used for executing the index change operation of the distributed database based on the corresponding relation through the target node.
- 11. A processing apparatus for a distributed database index creation operation, the distributed database including a master node and a target node, index data in the distributed database having corresponding data index information, the data index information including a logical index address and a corresponding physical storage address, the storage space corresponding to the physical storage address storing the index data, comprising: a sending module, configured to send an index creation command to the target node through the master node; The creation module is used for executing distributed database index creation operation according to the index creation command through the target node so as to create index data and data index information corresponding to the index data and returning the index data; And the updating module is used for receiving the index data created by the target node and the logic index address of the index data through the master node, re-storing the acquired index data, and establishing a first type corresponding relation between the physical storage address re-allocated for the index data and the logic index address.
- 12. An electronic device comprising a processor, a memory for storing processor executable instructions, wherein the processor is configured to implement the steps of the method of any one of claims 1-9 by executing the executable instructions.
- 13. A computer readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the steps of the method of any of claims 1 to 9.
- 14. A computer program product comprising computer programs/instructions which, when executed by a processor, implement the steps of the method of any of claims 1 to 9.
Description
Processing method and device for index change operation of distributed database Technical Field One or more embodiments of the present disclosure relate to the field of computer technology, and in particular, to a method and an apparatus for processing a distributed database index change operation. Background At present, because the execution of the data definition language (Data Definition Language, DDL) transaction not only needs to modify metadata, but also often involves scanning, converting and rewriting of massive data, a great burden is brought to a master node in a distributed system, and the response performance of online service is further affected. Therefore, to ease the burden on the master node in the distributed system, data definition language (Data Definition Language, DDL) transactions (e.g., adding or deleting columns in the data table, changing the data type of any field in the data table, etc.) for changing the table structure of the data table in the database may be placed on other nodes for execution (e.g., backup nodes of the master node, bidding nodes, etc.). However, unlike data definition language transactions, which are used to change the table structure of a data table in a database, in the data table, each row of data is independent of each other, the modification of the table structure (e.g., adding columns) can be generally performed row by row, there is no coupling relationship between rows, and the indexes (e.g., B-tree index, hash index, bitmap index, etc.) are tightly connected overall structures, and, taking a B-tree index as an example, index between index nodes included in an index are related to each other by pointers to physical storage addresses of each other on a storage medium, so as to form a tree structure with a state and clear dependency relationship, which results in that the pointers are only valid in the original storage environment, and the indexes need to maintain their overall topology by the pointers. Therefore, when the data definition language transaction for changing the index of the data table in the database is offloaded to other nodes for execution, the index is transmitted to a storage environment of a new service node, and the new service node can reassign a physical storage address to the index based on the use condition of the storage space, so that the pointer in the index node contained in the index is invalid, and further the logic fracture of the index and even the data consistency of the whole index are thoroughly destroyed, therefore, the DDL transaction for changing the index of the data table in the database is difficult to be offloaded to other nodes for execution. Disclosure of Invention In view of this, one or more embodiments of the present disclosure provide the following technical solutions: according to a first aspect of one or more embodiments of the present disclosure, a method for processing an index change operation of a distributed database is provided, where the distributed database includes a master node and a target node, index data in the distributed database has corresponding data index information, the data index information includes a logical index address and a corresponding physical storage address, and a storage space corresponding to the physical storage address stores index data, and the method includes: the master node sends an index change command to the target node; the target node acquires corresponding index data and a logic index address of the index data according to the index change command, and re-stores the acquired index data and establishes a first type corresponding relation between a physical storage address re-allocated for the index data and the logic index address; and the target node executes the index change operation of the distributed database based on the corresponding relation. According to a second aspect of one or more embodiments of the present specification, there is provided a method of processing a distributed database index creation operation, the distributed database including a master node and a target node, index data in the distributed database having corresponding data index information including a logical index address and a corresponding physical storage address, the storage space corresponding to the physical storage address storing the index data, the method comprising: the master node sends an index creation command to the target node; The target node executes distributed database index creation operation according to the index creation command to create index data and data index information corresponding to the index data and returns the index data; The master node receives the index data created by the target node and the logical index address of the index data, and re-stores the obtained index data, and establishes a first type corresponding relation between the physical storage address re-allocated for the index data and the logical index address. According to a third a