Repository navigation
[Bug] Recognize IoTConsensusV2 class name aliases on ConfigNode - #18989
Open
luoluoyuyu wants to merge 1 commit into
Open
luoluoyuyu wants to merge 1 commit into
luoluoyuyu wants to merge 1 commit into
Conversation
ConfigNode compared the raw value of data_region_consensus_protocol_class with ConsensusFactory.IOT_CONSENSUS_V2, while DataNode normalizes the configured value through ConsensusFactory.normalizeConsensusProtocolClass before using it. When the configuration used the legacy org.apache.iotdb.consensus.pipe.PipeConsensus name or the implementation class name org.apache.iotdb.consensus.pipe.IoTConsensusV2, ConfigNode concluded that IoTConsensusV2 was not configured and therefore: - createInitialConsensusPipes() never created the __consensus.* pipes on database creation; - checkAndRepairConsensusPipes() returned immediately, so PipeMetaSyncer could never repair missing pipes; - RouteBalancer disabled the automatic data region leader balance. Since the IoTConsensusV2 write path only writes the local state machine, the missing pipes silently degraded the data region replication factor to one: no error was reported and syncLag stayed at zero. Normalize the value once at the configuration boundary so CONF never holds an alias, log the normalization when the configuration file uses an alias, keep the comparison sites and the RouteBalancer cache defensive, and normalize the value sent by a joining ConfigNode so a mixed-version cluster is not rejected.
Caideyipi
reviewed
Oct 23, 2026
Caideyipi
left a comment
Collaborator
There was a problem hiding this comment.
Review
The normalization is applied when ConfigNode reads its setting and when it compares a joining node's parameters, so both startup and mixed-version registration use the canonical class name. The pipe creation and repair checks follow the same alias handling, and the new tests cover both legacy names. I found no blocking issue in the changed paths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Root cause
ConfigNodecompared the raw value ofdata_region_consensus_protocol_classwithConsensusFactory.IOT_CONSENSUS_V2, whileDataNodenormalizes the configured value throughConsensusFactory.normalizeConsensusProtocolClassbefore using it.When the configuration uses the legacy
org.apache.iotdb.consensus.pipe.PipeConsensusname or the implementation class nameorg.apache.iotdb.consensus.pipe.IoTConsensusV2,ConfigNodeconcluded that IoTConsensusV2 was not configured:createInitialConsensusPipes()never created the__consensus.*pipes when a database was created;checkAndRepairConsensusPipes()returned immediately, soPipeMetaSyncercould never repair the missing pipes;RouteBalancerdisabled the automatic data region leader balance (IS_ENABLE_AUTO_LEADER_BALANCE_FOR_DATA_REGIONbecamefalse).Since the IoTConsensusV2 write path only writes the local state machine, the missing pipes silently degraded the data region replication factor to one: no error was reported,
syncLagstayed at zero, and the region peers could all end up as followers.The value persisted by
SystemPropertiesUtils.storeSystemParameters()is already normalized, so the degradation originated at the configuration boundary; on a restart,ConfigNodeStartupCheck.checkSystemProperties()overwroteCONFwith the persisted canonical value and the cluster silently healed.Fix
ConfigNodeConfig#setDataRegionConsensusProtocolClass) soCONFnever holds an alias regardless of the source (properties file, system properties, programmatic setup).ConfigNodeDescriptorwhen the value is read, and log a WARN when a legacy name is found, so the degradation is visible in the ConfigNode log.RegionMaintainHandler#isIoTConsensusV2Configured()and use it at the four comparison sites (createNewRegionPeer,createInitialConsensusPipes,checkAndRepairConsensusPipes,isIoTConsensusV2DataRegion).RouteBalancer.ConfigManager#checkConfigNodeGlobalConfig, so a mixed-version cluster is not rejected during a rolling upgrade.Tests
ConfigNodeConfigTest#testDataRegionConsensusProtocolClassNormalizesLegacyNames: both aliases are stored in canonical form; canonical and Ratis values are preserved.RegionMaintainHandlerConsensusPipeTest#testCreatesMissingPipesWhenLegacyConsensusProtocolAliasConfigured: the periodic self-healing path creates the pipes when the legacy alias is configured.RegionMaintainHandlerConsensusPipeTest#testCreatesInitialPipesWhenImplementationClassNameConfigured: database creation creates the initial pipes when the implementation class name is configured.The three new tests fail on the unpatched code and pass with the fix.
RegionMaintainHandlerTest(30 tests),RemovePeerRestartConsensusTestandRestartDuringRemovePeerTest(14 tests) and theConfigNodePropertiesTestArchUnit rule still pass. Both theenand thezhlocale sources compile, andmvn spotless:check -pl iotdb-core/confignodepasses.Note on existing clusters
After upgrading, the pipes are recreated by
PipeMetaSynceron the ConfigNode leader, but data written while the pipes were missing only exists in the leader's state machine. Whether it is back-filled depends on the pipe/snapshot start semantics, so operators of an affected cluster should verify the replicas (for example with a backup or a replica consistency check) instead of assuming the history is repaired automatically.This PR has:
Key changed/added classes (or packages if there are too many classes) in this PR
org.apache.iotdb.confignode.conf.ConfigNodeConfigorg.apache.iotdb.confignode.conf.ConfigNodeDescriptororg.apache.iotdb.confignode.procedure.env.RegionMaintainHandlerorg.apache.iotdb.confignode.manager.load.balancer.RouteBalancerorg.apache.iotdb.confignode.manager.ConfigManagerorg.apache.iotdb.confignode.i18n.ConfigNodeMessages(en/zh)