Lightning Error: "Region distribution is unbalanced, the ratio of the regions"

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: lightning报错“Region distribution is unbalanced, the ratio of the regions”

| username: jarry_618

【TiDB Usage Environment】 /Test/
【TiDB Version】 6.5
【Reproduction Path】 Performed scale-out for TiKV and TiFlash
【Encountered Issues: Symptoms and Impact】
【Resource Configuration】
【Attachments: Screenshots/Logs/Monitoring】

| username: jarry_618 | Original post link

The image you provided is not accessible. Please provide the text you need translated.

| username: tidb菜鸟一只 | Original post link

Region Distribution Status >= 5.3.0 checks whether the Region distribution of the TiKV cluster is even and whether there are a large number of empty regions. If the number of empty Regions is greater than max(1000, number of tables * 3), which is greater than the larger of “1000” and “3 times the number of tables”, TiDB Lightning cannot perform the import.
It looks like the Region distribution of your cluster is not even enough.

| username: jarry_618 | Original post link

It looks like there are very few empty regions.

| username: jarry_618 | Original post link

The regions are indeed uneven, with only a single-digit number of regions on the newly added 3 nodes. But it seems there is no command to perform rebalance…

| username: TiDBer_pkQ5q1l0 | Original post link

The balance is automatic. Check the monitoring of pd operate.

| username: jarry_618 | Original post link

Several hours have passed, and I found that no rebalance was done at all. It’s probably because there were no business operations in my testing environment.

| username: magongyong | Original post link

How large is the data? If it’s too much, consider using the TiDB mode. I encountered this issue before.

| username: magongyong | Original post link

Is the version 6.5.0?

| username: jarry_618 | Original post link

Yes, V6.5.0.

| username: jarry_618 | Original post link

Test environment, don’t want to bypass it, hope to find a solution. :grinning:

| username: magongyong | Original post link

After upgrading to 6.5.1, I haven’t encountered this issue again. You can give it a try. If you don’t want to upgrade, switching to TiDB mode should work.

| username: jarry_618 | Original post link

After upgrading to 6.5.1, I noticed that rebalancing is indeed happening, although the speed is not fast. :call_me_hand:

| username: jarry_618 | Original post link

I found that it stopped, and in the end, it is still unbalanced…
image

| username: magongyong | Original post link

Is there still an error when importing? I haven’t encountered the issue of imbalance; it usually balances itself automatically after a while.

| username: jarry_618 | Original post link

You can see that the imbalance ratio has decreased, but it’s still somewhat lacking.

| username: xingzhenxiang | Original post link

Try expanding a TiKV and trigger a large data migration balance to see what happens.
I’m using version 6.5.1 and didn’t see this error when importing 1.5TB of data.

| username: jarry_618 | Original post link

Before importing, was your database large?
Secondly, did you expand TiKV before importing?

| username: xingzhenxiang | Original post link

Before the import, there was 9.2T of data. My import mode is logical mode import, but the imported data is not in the same database as before. Before the import, I performed upgrades and machine resource scaling, all achieved through scaling in and out.

| username: jarry_618 | Original post link

Logical won’t have this problem.