Skip to content

Commit 977ebb7

Browse files
committed
Replace RegionGroup visibility polling with failure-path diagnostic; clarify RemoveDataNode message
Drop the 10s busy-wait waitForRegionGroupsVisible loop in PartitionManager: the schema-region create/activate/allocate path is unchanged from the PR baseline, so the poll only masks the intermittent "no available RegionGroup" race probabilistically rather than fixing it. Instead, log a single WARN on the failure path (right before throwing NoAvailableRegionGroupException) that dumps every RegionGroup visible in PartitionInfo for the Database and its LoadCache status. This pinpoints, on the next CI repro, whether PartitionInfo has no RegionGroup yet or has some that are all Disabled — without flooding the log, since it only fires when allocation already failed. Also reword FAILED_TO_REMOVE_DATA_NODE_BECAUSE_DATA_REPLICATION_FACTOR_IS_ONE (en + zh): drop the misleading data-loss / increase-factor tail and end with "Removing DataNodes is not supported with single replica."
1 parent 14dc895 commit 977ebb7

3 files changed

Lines changed: 21 additions & 69 deletions

File tree

‎iotdb-core/confignode/src/main/i18n/en/org/apache/iotdb/confignode/i18n/ProcedureMessages.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ public final class ProcedureMessages {
448448

449449
public static final String
450450
FAILED_TO_REMOVE_DATA_NODE_BECAUSE_DATA_REPLICATION_FACTOR_IS_ONE =
451-
"Cannot remove DataNode because data_replication_factor is 1 or at least one DataRegion has only one replica. Removing a DataNode may cause data loss. Increase data_replication_factor and ensure each DataRegion has more than one replica before removing DataNodes.";
451+
"Cannot remove DataNode because data_replication_factor is 1 or at least one DataRegion has only one replica. Removing DataNodes is not supported with single replica.";
452452
public static final String FAILED_TO_ROLLBACK_ALTER_PIPE_DETAILS_METADATA_WILL_BE_SYNCHRONIZED =
453453
"Failed to rollback alter pipe {}, details: {}, metadata will be synchronized later.";
454454
public static final String FAILED_TO_ROLLBACK_COMMIT_SET_TEMPLATE_ON_PATH_DUE_TO =

‎iotdb-core/confignode/src/main/i18n/zh/org/apache/iotdb/confignode/i18n/ProcedureMessages.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ public final class ProcedureMessages {
448448

449449
public static final String
450450
FAILED_TO_REMOVE_DATA_NODE_BECAUSE_DATA_REPLICATION_FACTOR_IS_ONE =
451-
"不能移除 DataNode,因为 data_replication_factor 为 1,或至少存在一个 DataRegion 只有一个副本。移除 DataNode 可能造成数据丢失。请先提高 data_replication_factor,并确保每个 DataRegion 都有多个副本,再移除 DataNode。";
451+
"不能移除 DataNode,因为 data_replication_factor 为 1,或至少存在一个 DataRegion 只有一个副本。单副本不支持移除 DataNode。";
452452
public static final String FAILED_TO_ROLLBACK_ALTER_PIPE_DETAILS_METADATA_WILL_BE_SYNCHRONIZED =
453453
"Failed to rollback alter pipe {}, details: {}, metadata will be synchronized later.";
454454
public static final String FAILED_TO_ROLLBACK_COMMIT_SET_TEMPLATE_ON_PATH_DUE_TO =

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

Lines changed: 19 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
import java.util.Collections;
109109
import java.util.HashMap;
110110
import java.util.HashSet;
111+
import java.util.LinkedHashMap;
111112
import java.util.LinkedList;
112113
import java.util.List;
113114
import java.util.Map;
@@ -147,9 +148,6 @@ public class PartitionManager {
147148
public static final String CONSENSUS_WRITE_ERROR =
148149
"Failed in the write API executing the consensus layer due to: ";
149150

150-
private static final long REGION_GROUP_VISIBILITY_TIMEOUT_MS = 10_000L;
151-
private static final long REGION_GROUP_VISIBILITY_CHECK_INTERVAL_MS = 20L;
152-
153151
// Monitor for leadership change
154152
private final Object scheduleMonitor = new Object();
155153

@@ -718,75 +716,12 @@ private TSStatus generateAndAllocateRegionGroups(
718716
getLoadManager().allocateRegionGroups(allotmentMap, consensusGroupType);
719717
LOGGER.info(ManagerMessages.CREATEREGIONGROUPS_STARTING_TO_CREATE_THE_FOLLOWING_REGIONGROUPS);
720718
createRegionGroupsPlan.planLog(LOGGER);
721-
final TSStatus createStatus =
722-
getProcedureManager().createRegionGroups(consensusGroupType, createRegionGroupsPlan);
723-
if (createStatus.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
724-
return createStatus;
725-
}
726-
return waitForRegionGroupsVisible(createRegionGroupsPlan, consensusGroupType);
719+
return getProcedureManager().createRegionGroups(consensusGroupType, createRegionGroupsPlan);
727720
} else {
728721
return RpcUtils.SUCCESS_STATUS;
729722
}
730723
}
731724

732-
private TSStatus waitForRegionGroupsVisible(
733-
final CreateRegionGroupsPlan createRegionGroupsPlan,
734-
final TConsensusGroupType consensusGroupType) {
735-
final Map<String, Set<TConsensusGroupId>> expectedRegionGroups = new HashMap<>();
736-
createRegionGroupsPlan
737-
.getRegionGroupMap()
738-
.forEach(
739-
(database, regionReplicaSets) -> {
740-
final Set<TConsensusGroupId> regionGroupIds =
741-
regionReplicaSets.stream()
742-
.map(TRegionReplicaSet::getRegionId)
743-
.filter(regionGroupId -> consensusGroupType.equals(regionGroupId.getType()))
744-
.collect(Collectors.toSet());
745-
if (!regionGroupIds.isEmpty()) {
746-
expectedRegionGroups.put(database, regionGroupIds);
747-
}
748-
});
749-
750-
final long startTime = System.currentTimeMillis();
751-
while (System.currentTimeMillis() - startTime <= REGION_GROUP_VISIBILITY_TIMEOUT_MS) {
752-
if (areRegionGroupsVisible(expectedRegionGroups, consensusGroupType)) {
753-
return RpcUtils.SUCCESS_STATUS;
754-
}
755-
try {
756-
TimeUnit.MILLISECONDS.sleep(REGION_GROUP_VISIBILITY_CHECK_INTERVAL_MS);
757-
} catch (final InterruptedException e) {
758-
Thread.currentThread().interrupt();
759-
return new TSStatus(TSStatusCode.CREATE_REGION_ERROR.getStatusCode())
760-
.setMessage(
761-
String.format(
762-
"Interrupted while waiting for created %s RegionGroups %s to become visible in PartitionInfo.",
763-
consensusGroupType, expectedRegionGroups));
764-
}
765-
}
766-
767-
final String message =
768-
String.format(
769-
"Created %s RegionGroups %s are not visible in PartitionInfo within %d ms.",
770-
consensusGroupType, expectedRegionGroups, REGION_GROUP_VISIBILITY_TIMEOUT_MS);
771-
LOGGER.warn(message);
772-
return new TSStatus(TSStatusCode.CREATE_REGION_ERROR.getStatusCode()).setMessage(message);
773-
}
774-
775-
private boolean areRegionGroupsVisible(
776-
final Map<String, Set<TConsensusGroupId>> expectedRegionGroups,
777-
final TConsensusGroupType consensusGroupType) {
778-
for (final Map.Entry<String, Set<TConsensusGroupId>> entry : expectedRegionGroups.entrySet()) {
779-
final Set<TConsensusGroupId> visibleRegionGroups =
780-
partitionInfo.getRegionGroupSlotsCounter(entry.getKey(), consensusGroupType).stream()
781-
.map(Pair::getRight)
782-
.collect(Collectors.toSet());
783-
if (!visibleRegionGroups.containsAll(entry.getValue())) {
784-
return false;
785-
}
786-
}
787-
return true;
788-
}
789-
790725
/**
791726
* Only leader use this interface. Checks whether the specified DataPartition has a successor and
792727
* returns if it does.
@@ -1059,6 +994,23 @@ public List<Pair<Long, TConsensusGroupId>> getSortedRegionGroupSlotsCounter(
1059994
}
1060995

1061996
if (result.isEmpty()) {
997+
// Diagnostic for the intermittent "no available RegionGroup" CI failures: dump every
998+
// RegionGroup visible in PartitionInfo for this Database together with its LoadCache status.
999+
// This pinpoints whether PartitionInfo simply has no RegionGroup yet (newly created
1000+
// RegionGroup not exposed) or it has some but all of them are currently Disabled.
1001+
// Only logged on the failure path right before throwing, so it never floods the log.
1002+
final Map<TConsensusGroupId, RegionGroupStatus> visibleRegionGroupStatusMap =
1003+
new LinkedHashMap<>();
1004+
regionGroupSlotsCounter.forEach(
1005+
slotsCounter ->
1006+
visibleRegionGroupStatusMap.put(
1007+
slotsCounter.getRight(),
1008+
getLoadManager().getRegionGroupStatus(slotsCounter.getRight())));
1009+
LOGGER.warn(
1010+
"No available {} RegionGroup for Database: {}. RegionGroups visible in PartitionInfo and their LoadCache status: {}",
1011+
type,
1012+
database,
1013+
visibleRegionGroupStatusMap);
10621014
throw new NoAvailableRegionGroupException(type, Collections.singletonList(database));
10631015
}
10641016

0 commit comments

Comments
 (0)