# US 2024/0028568 A1 · Data migration method and apparatus, device, distributed system and storage medium

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2024/0028568 A1
- Document ID: US20240028568A1
- Status: Published application
- Kind: A1
- Application number: 18/043,892
- Filed: 2021-09-03
- Published: 2024-01-25
- Earliest claimed: 2020-09-04
- Assignees: Alibaba Cloud Computing Ltd.
- Applicants: Alibaba Cloud Computing Co., Ltd.
- Inventors: Yanxin LUO; Feifei LI; Wei CAO
- Web page: https://patentgrep.com/patent/US20240028568A1

## CPC

- G06F 16/214: {Database migration support}
- G06F 16/2282: {Tablespace storage structures; Management thereof}
- G06F 16/27: Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A data migration method and apparatus, a device, a distributed system and a storage medium are provided. Said method is applied to each data node in a distributed system comprising a plurality of data nodes. Said method comprises: determining, in a current data migration task, a table to be migrated of a current node, and a target data node (S101); and writing incremental data in the table to be migrated into the table to be migrated, and a target data table of the target data node, the incremental data being data obtained by performing, after the data migration task is started, a change operation on data in the table to be migrated (S102).

## Claims

### Claim 1

A data migration method, applied to each data node of a plurality of data nodes comprised in a distributed system, wherein the method comprises:
determining a target data node and a table to be migrated of a data node for a present data migration task; and
writing, to a target data table of the target data node and the table to be migrated, incremental data in the table to be migrated, wherein the incremental data is data obtained by performing, after the data migration task is started, a change operation on data in the table to be migrated.

### Claim 2 (depends on 1)

The method according to claim 1, wherein, after determining the target data node and the table to be migrated of the data node for the present data migration task, the method further comprises:
acquiring, from a database of the data node, metadata of the table to be migrated; and
establishing, according to the metadata, the target data table in a database of the target data node.

### Claim 3 (depends on 1)

The method according to claim 1, further comprising:
writing, to the target data table of the target data node, stock data in the table to be migrated, wherein the stock data is data in the table to be migrated before the data migration task is started.

### Claim 4 (depends on 3)

The method according to claim 3, wherein, before writing, to the target data table of the target data node and the table to be migrated, the incremental data in the table to be migrated, the method further comprises:
recording site information, wherein the site information indicates a value range of a primary key in the table to be migrated before the incremental data is written to the table to be migrated and the target data table;
the writing, to the target data table of the target data node, the stock data in the table to be migrated, comprises:
acquiring the site information of the table to be migrated;
determining, according to the value range of the primary key in the table to be migrated indicated by the site information, the stock data in the table to be migrated; and
reading the stock data in the table to be migrated and writing the stock data to the target data table.

### Claim 5 (depends on 3)

The method according to claim 3, wherein, in a case where both a migration state of the table to be migrated and a migration state of the target data table are a first state, operations of writing the incremental data to the table to be migrated and the target data table are performed;
before writing, to the target data table of the target data node and the table to be migrated, the incremental data in the table to be migrated, the method further comprises:
determining the migration state of the table to be migrated as the first state; and
synchronizing state information indicating the first state with the target data node, so that the target data node determines the migration state of the target data table as the first state.

### Claim 6 (depends on 5)

The method according to claim 5, wherein the incremental data is data obtained by performing, after both the migration state of the table to be migrated and the migration state of the target data table are determined as the first state, the change operation on the data in the table to be migrated; and
the stock data is data in the table to be migrated before both the migration state of the table to be migrated and the migration state of the target data table are determined as the first state.

### Claim 7 (depends on 3)

The method according to claim 3, wherein, in a case where both a migration state of the table to be migrated and a migration state of the target data table are a second state, an operation of writing the stock data to the target data table is performed;
before writing, to the target data table of the target data node, the stock data in the table to be migrated, the method further comprises:
determining the migration state of the table to be migrated as the second state; and
synchronizing state information indicating the second state with the target data node, so that the target data node determines the migration state of the target data table as the second state.

### Claim 8 (depends on 5)

The method according to claim 5, wherein the change operation performed on the data in the table to be migrated and the operation of determining the migration state of the table to be migrated and the migration state of the target data table are mutually exclusive.

### Claim 9 (depends on 8)

The method according to claim 8, wherein the change operation performed on the data in the table to be migrated is performed after a read lock for the table to be migrated is acquired;
the operation of determining the migration state of the table to be migrated and the migration state of the target data table is performed after a write lock for the table to be migrated is acquired; and the read lock and the write lock are mutually exclusive.

### Claim 10 (depends on 5)

The method according to claim 5, wherein, before writing, to the target data table of the target data node and the table to be migrated, the incremental data in the table to be migrated, the method further comprises:
recording site information, wherein the site information indicates a value range of a primary key in the table to be migrated before both the migration state of the table to be migrated and the migration state of the target data table are determined as the first state; and the site information is used to determine the stock data of the table to be migrated.

### Claim 11 (depends on 3)

The method according to claim 3, further comprising:
after the stock data has been written to the target data table of the target data node, sending a switch request to the target data node, wherein the switch request is used to switch, to the target data table, a read operation on the table to be migrated; and
after the switching is completed, stopping a write operation on the table to be migrated.

### Claim 12 (depends on 11)

The method according to claim 11, wherein the change operation performed on the data in the table to be migrated and the operation of switching, to the target data table, the read operation on the table to be migrated are mutually exclusive.

### Claim 13 (depends on 12)

The method according to claim 12, wherein the change operation performed on the data in the table to be migrated is performed after a read lock for the table to be migrated is acquired;
the operation of switching, to the target data table, the read operation on the table to be migrated is performed after a write lock for the table to be migrated is acquired; and
the read lock and the write lock are mutually exclusive.

### Claim 14 (depends on 11)

The method according to claim 11, wherein the sending the switch request to the target data node, further comprises:
after verifying that the data in the table to be migrated is consistent with the data in the target data table, sending the switch request to the target data node.

### Claim 15

A data migration apparatus, applied to each data node of a plurality of data nodes comprised in a distributed system, wherein the apparatus comprises:
at least one processor; and
a memory communicatively connected with the at least one processor,
wherein the memory stores instructions executable by the at least one processor, and the instructions, when executed by the at least one processor, cause the at least one processor to perform operations of:
determining a target data node and a table to be migrated of a data node for a present data migration task; and
writing, to a target data table of the target data node and the table to be migrated, incremental data in the table to be migrated, wherein the incremental data is data obtained by performing, after the data migration task is started, a change operation on data in the table to be migrated.

### Claim 16

A distributed system comprising a plurality of data nodes, wherein each data node of the plurality of data nodes is configured for:
determining a target data node and a table to be migrated of a data node for a present data migration task; and
writing, to a target data table of the target data node and the table to be migrated, incremental data in the table to be migrated, wherein the incremental data is data obtained by performing, after the data migration task is started, a change operation on data in the table to be migrated.

### Claim 17 (depends on 1)

A computer device, comprising a memory, a processor, and a computer program which is stored in the memory and is run on the processor, wherein the processor, when executing the computer program, implements the method according to claim 1.

### Claim 18 (depends on 1)

A computer-readable storage medium, wherein the computer-readable storage medium has stored a computer program, and the computer program, when executed by a processor, implements the method according to claim 1.

### Claim 19 (depends on 7)

The method according to claim 7, wherein the change operation performed on the data in the table to be migrated and the operation of determining the migration state of the table to be migrated and the migration state of the target data table are mutually exclusive.

### Claim 20 (depends on 19)

The method according to claim 19, wherein the change operation performed on the data in the table to be migrated is performed after a read lock for the table to be migrated is acquired;
the operation of determining the migration state of the table to be migrated and the migration state of the target data table is performed after a write lock for the table to be migrated is acquired; and the read lock and the write lock are mutually exclusive.
