smengcl commented on PR #1630:
URL: https://github.com/apache/ratis/pull/1630#issuecomment-6090883991

   > > ...  restart the peers ...
   > 
   > If restarting is needed, could we just use raftMetaConf command 
(RaftMetaConfCommand)?
   > 
   > Using setConf may have some unnecessary complication since there are two 
addresses for the same peer at the same time. I am not sure if the code can 
handle them correctly.
   
   @szetszwo Thanks, that is a fair concern, and I agree that changing 
addresses at runtime is tricky. To be clear about the scope: this patch only 
changes what is recorded. It does not change which addresses running servers 
connect to.
   
   **What it does:** Today a `setConfiguration` with the same IDs and 
priorities but different addresses gets a [success reply while the request is 
discarded](https://github.com/apache/ratis/blob/1c2f23488b1ef357ef4523823d201acd67f03406/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java#L1494-L1499),
 because `hasNoChange` compares only IDs and priorities. With the patch it is 
committed and written by every peer like any other configuration.
   
   **What it does not do:** With gRPC, running servers keep their connections. 
`PeerProxyMap` [keeps the first 
address](https://github.com/apache/ratis/blob/1c2f23488b1ef357ef4523823d201acd67f03406/ratis-common/src/main/java/org/apache/ratis/util/PeerProxyMap.java#L131-L147)
 it has for a peer ID, and the lookups in `RaftConfigurationImpl`, the majority 
checks and the log appenders all go by peer ID. The recorded addresses are 
reported to clients, for example in GroupInfo. A server uses a recorded address 
only for a peer it has no address for yet, for example when it starts without 
peers in its group and reads them from Raft storage.
   
   **Two addresses for the same peer:** I believe this can already happen on 
master. A request that changes membership or priority and also has a different 
address for an existing peer already creates a joint configuration with both 
addresses, since the new configuration is [built from the peers in the 
request](https://github.com/apache/ratis/blob/1c2f23488b1ef357ef4523823d201acd67f03406/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java#L534-L535).
 So the patch should not add a new state. It only stops skipping the case where 
nothing else changed.
   
   I agree `raftMetaConf` is a reasonable option when a restart is needed 
anyway. I leaned towards `setConfiguration` for the Ozone case because Ozone 
SCM [starts with an empty 
group](https://github.com/apache/ozone/blob/d067ba38e7aea917db7efd290b4af53987ec985a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMRatisServerImpl.java#L119-L123)
 and recovers its peers from Raft storage, so the stored addresses are what it 
uses after a restart. With `setConfiguration` that change is agreed by the 
group, instead of being edited by hand on each peer.
   
   If it helps, I am happy to add tests for both behaviours: running servers 
keep working with the new addresses recorded, and servers restarted from 
storage use them. And if you still think the offline approach is the safer 
choice, I am fine with closing this and using `raftMetaConf` instead. Thanks 
for the careful review.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to