Skip to content

Commit c36fbcf

Browse files
authored
Fix version mismatch error when dispatching encoded hints in storage compatibility mode (#2179)
### What is the issue Fix version mismatch error when dispatching encoded hints in storage compatibility mode ### What does this PR fix and why was it fixed Remove version checks in HintMessage.Encoded serialization that prevented dispatching hints written at storage compatibility version (e.g., 12) when the peer connection uses a different messaging version (e.g., 110). UUID and VInt serialization are version-independent, and hint bytes are written verbatim, so the version check was unnecessarily restrictive.
1 parent 7d8f28b commit c36fbcf

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/java/org/apache/cassandra/hints/HintMessage.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,11 @@ else if (obj instanceof Encoded)
110110
{
111111
Encoded message = (Encoded) obj;
112112

113-
if (version != message.version)
114-
throw new IllegalArgumentException("serializedSize() called with non-matching version " + version +
115-
" for message with version " + message.version);
116-
113+
// UUID serialization is version-independent, VInt encoding is version-independent,
114+
// and hint bytes are written verbatim. The size is the same regardless of the version
115+
// passed, so we don't need to check for version mismatch here. This allows encoded
116+
// hints written at the storage compatibility version to be dispatched correctly
117+
// even when the peer is at a different (newer) messaging version.
117118
long size = UUIDSerializer.serializer.serializedSize(message.hostId, version);
118119
size += TypeSizes.sizeofUnsignedVInt(message.hint.remaining());
119120
size += message.hint.remaining();
@@ -147,9 +148,11 @@ else if (obj instanceof Encoded)
147148
{
148149
Encoded message = (Encoded) obj;
149150

150-
if (version != message.version)
151-
throw new IllegalArgumentException("serialize() called with non-matching version " + version);
152-
151+
// UUID serialization and VInt encoding are version-independent, and hint bytes are
152+
// written verbatim (already encoded at message.version). This allows encoded hints
153+
// written at the storage compatibility version to be dispatched correctly even when
154+
// the peer is at a different (newer) messaging version. The receiver will deserialize
155+
// the hint bytes using the appropriate version based on the hint file descriptor.
153156
UUIDSerializer.serializer.serialize(message.hostId, out, version);
154157
out.writeUnsignedVInt32(message.hint.remaining());
155158
out.write(message.hint);

0 commit comments

Comments
 (0)