RongtongJin commented on code in PR #4367:
URL: https://github.com/apache/rocketmq/pull/4367#discussion_r880387878
##########
store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAConnection.java:
##########
@@ -278,16 +287,20 @@ protected boolean processReadResult(ByteBuffer
byteBufferRead) {
case HANDSHAKE:
if (diff >=
AutoSwitchHAClient.HANDSHAKE_HEADER_SIZE) {
isSlaveSendHandshake = true;
- // Flag(SyncFromLastFile)
- long syncFromLastFileFlag =
byteBufferRead.getInt(readPosition + 4);
- if (syncFromLastFileFlag ==
AutoSwitchHAClient.SYNC_FROM_LAST_FILE) {
-
AutoSwitchHAConnection.this.isSyncFromLastFile = true;
- LOGGER.info("Slave request sync from
lastFile");
- }
// SlaveId
- AutoSwitchHAConnection.this.slaveId =
byteBufferRead.getLong(readPosition + 8);
+ AutoSwitchHAConnection.this.slaveId =
byteBufferRead.getLong(readPosition + 4);
// AddressLength
- int addressLength =
byteBufferRead.getInt(readPosition + 16);
+ int addressLength =
byteBufferRead.getInt(readPosition + 12);
+ // Flag(isSyncFromLastFile)
+ short syncFromLastFileFlag =
byteBufferRead.getShort(readPosition + 16);
+ if (syncFromLastFileFlag == 1) {
+
AutoSwitchHAConnection.this.isSyncFromLastFile = true;
+ }
+ // Flag(isAsyncLearner role)
+ short isAsyncLearner =
byteBufferRead.getShort(readPosition + 18);
+ if (isAsyncLearner == 1) {
+
AutoSwitchHAConnection.this.isAsyncLearner = true;
+ }
Review Comment:
当出现半包的时候,diff < AutoSwitchHAClient.HANDSHAKE_HEADER_SIZE +
addressLength,也就是ip地址body传输了一半,这个时候直接复制slaveAddress=“”,并且继续往下走会得到错误的slaveAddress
--
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]