Skip to content

Commit 041d292

Browse files
authored
[remove datanode] Do not disable the entire region group for one removing region (apache#14241)
* fix disabled * fix disabled
1 parent c5eacf0 commit 041d292

File tree

4 files changed

+18
-23
lines changed

4 files changed

+18
-23
lines changed

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/region/RegionGroupCache.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,29 +110,26 @@ private RegionGroupStatus caculateRegionGroupStatus(
110110
Map<Integer, RegionStatistics> regionStatisticsMap) {
111111
int unknownCount = 0;
112112
int readonlyCount = 0;
113+
int removingCount = 0;
113114
for (RegionStatistics regionStatistics : regionStatisticsMap.values()) {
114-
if (RegionStatus.Removing.equals(regionStatistics.getRegionStatus())) {
115-
// The RegionGroup is considered as Disabled when
116-
// at least one Region is in the ReadOnly or Removing status
117-
return RegionGroupStatus.Disabled;
118-
}
119115
unknownCount += RegionStatus.Unknown.equals(regionStatistics.getRegionStatus()) ? 1 : 0;
120116
readonlyCount += RegionStatus.ReadOnly.equals(regionStatistics.getRegionStatus()) ? 1 : 0;
117+
removingCount += RegionStatus.Removing.equals(regionStatistics.getRegionStatus()) ? 1 : 0;
121118
}
122119

123-
if (unknownCount + readonlyCount == 0) {
120+
if (unknownCount + readonlyCount + removingCount == 0) {
124121
// The RegionGroup is considered as Running only if
125122
// all Regions are in the Running status
126123
return RegionGroupStatus.Running;
127124
} else if (readonlyCount == 0) {
128-
return unknownCount <= ((regionCacheMap.size() - 1) / 2)
125+
return (unknownCount + removingCount) <= ((regionCacheMap.size() - 1) / 2)
129126
// The RegionGroup is considered as Available when the number of Unknown Regions is less
130127
// than half
131128
? RegionGroupStatus.Available
132129
// Disabled otherwise
133130
: RegionGroupStatus.Disabled;
134131
} else {
135-
return unknownCount + readonlyCount <= ((regionCacheMap.size() - 1) / 2)
132+
return (unknownCount + readonlyCount + removingCount) <= ((regionCacheMap.size() - 1) / 2)
136133
// The RegionGroup is considered as Discouraged when the number of Unknown or ReadOnly
137134
// Regions is less
138135
// than half, and there are at least 1 ReadOnly Region

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/RegionGroupStatus.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,22 @@ public enum RegionGroupStatus {
2424
Running("Running", 1),
2525

2626
/**
27-
* All Regions in RegionGroup are in the Running or Unknown status, and the number of Regions in
28-
* the Unknown status is less than half
27+
* All Regions in RegionGroup are in the Running or Unknown or Removing status, and the number of
28+
* Regions in the Unknown or Removing status is less than half
2929
*/
3030
Available("Available", 2),
3131

3232
/**
33-
* All Regions in RegionGroup are in the Running, Unknown or ReadOnly status, and at least 1 node
34-
* is in ReadOnly status, the number of Regions in the Unknown or ReadOnly status is less than
35-
* half
33+
* All Regions in RegionGroup are in the Running, Unknown or ReadOnly or Removing status, and at
34+
* least 1 node is in ReadOnly status, the number of Regions in the Unknown or ReadOnly or
35+
* Removing status is less than half
3636
*/
3737
Discouraged("Discouraged", 3),
3838

3939
/**
4040
* The following cases will lead to Disabled RegionGroup:
4141
*
42-
* <p>1. There is a Region in Removing status
43-
*
44-
* <p>2. More than half of the Regions are in Unknown or ReadOnly status
42+
* <p>1. More than half of the Regions are in Unknown or ReadOnly or Removing status
4543
*/
4644
Disabled("Disabled", 4);
4745

iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/load/LoadManagerTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public void testRegionGroupCache() throws InterruptedException {
188188
Assert.assertEquals(
189189
new Pair<>(
190190
new RegionGroupStatistics(RegionGroupStatus.Running, allRunningRegionStatisticsMap),
191-
new RegionGroupStatistics(RegionGroupStatus.Disabled, oneRemovingRegionStatisticsMap)),
191+
new RegionGroupStatistics(RegionGroupStatus.Available, oneRemovingRegionStatisticsMap)),
192192
differentRegionGroupStatisticsMap.get(regionGroupId));
193193
// Add and mark Region 3 as Adding
194194
int addDataNodeId = 3;
@@ -203,8 +203,8 @@ public void testRegionGroupCache() throws InterruptedException {
203203
oneAddingRegionStatisticsMap.put(addDataNodeId, new RegionStatistics(RegionStatus.Adding));
204204
Assert.assertEquals(
205205
new Pair<>(
206-
new RegionGroupStatistics(RegionGroupStatus.Disabled, oneRemovingRegionStatisticsMap),
207-
new RegionGroupStatistics(RegionGroupStatus.Disabled, oneAddingRegionStatisticsMap)),
206+
new RegionGroupStatistics(RegionGroupStatus.Available, oneRemovingRegionStatisticsMap),
207+
new RegionGroupStatistics(RegionGroupStatus.Available, oneAddingRegionStatisticsMap)),
208208
differentRegionGroupStatisticsMap.get(regionGroupId));
209209
// Both Region 0 and 3 can't be updated
210210
LOAD_CACHE.cacheRegionHeartbeatSample(
@@ -226,8 +226,8 @@ public void testRegionGroupCache() throws InterruptedException {
226226
oneRemovingRegionStatisticsMap.put(addDataNodeId, new RegionStatistics(RegionStatus.Running));
227227
Assert.assertEquals(
228228
new Pair<>(
229-
new RegionGroupStatistics(RegionGroupStatus.Disabled, oneAddingRegionStatisticsMap),
230-
new RegionGroupStatistics(RegionGroupStatus.Disabled, oneRemovingRegionStatisticsMap)),
229+
new RegionGroupStatistics(RegionGroupStatus.Available, oneAddingRegionStatisticsMap),
230+
new RegionGroupStatistics(RegionGroupStatus.Available, oneRemovingRegionStatisticsMap)),
231231
differentRegionGroupStatisticsMap.get(regionGroupId));
232232
// Removing process completed
233233
LOAD_MANAGER.removeRegionCache(regionGroupId, removeDataNodeId);
@@ -237,7 +237,7 @@ public void testRegionGroupCache() throws InterruptedException {
237237
allRunningRegionStatisticsMap.put(addDataNodeId, new RegionStatistics(RegionStatus.Running));
238238
Assert.assertEquals(
239239
new Pair<>(
240-
new RegionGroupStatistics(RegionGroupStatus.Disabled, oneRemovingRegionStatisticsMap),
240+
new RegionGroupStatistics(RegionGroupStatus.Available, oneRemovingRegionStatisticsMap),
241241
new RegionGroupStatistics(RegionGroupStatus.Running, allRunningRegionStatisticsMap)),
242242
differentRegionGroupStatisticsMap.get(regionGroupId));
243243
}

iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/load/cache/RegionGroupCacheTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public void getRegionGroupStatusTest() {
123123
2, new RegionHeartbeatSample(currentTime, RegionStatus.Removing));
124124
disabledRegionGroup2.updateCurrentStatistics();
125125
Assert.assertEquals(
126-
RegionGroupStatus.Disabled,
126+
RegionGroupStatus.Available,
127127
disabledRegionGroup2.getCurrentStatistics().getRegionGroupStatus());
128128
}
129129
}

0 commit comments

Comments
 (0)