Skip to content

Commit 7d8f28b

Browse files
authored
CNDB-16307: respect storage compatibility mode when dispatching hints (#2176)
### What is the issue After CNDB-16249, hints are written with the storage-compatible messaging version (e.g., VERSION_40), but dispatch was still using the peer's negotiated version (VERSION_DS_20). This mismatch forced hints to be decoded and re-encoded on dispatch, which fails when the tenant is unassigned because tables are unknown. ### What does this PR fix and why was it fixed Cap the dispatch version to the storage compatibility mode's version so hints can use the encoded path (no deserialization) when the versions match.
1 parent c32e5af commit 7d8f28b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.apache.cassandra.io.FSReadError;
3737
import org.apache.cassandra.io.util.File;
3838
import org.apache.cassandra.locator.InetAddressAndPort;
39+
import org.apache.cassandra.utils.StorageCompatibilityMode;
3940
import org.apache.cassandra.utils.concurrent.UncheckedInterruptedException;
4041
import org.apache.cassandra.utils.concurrent.Future;
4142

@@ -292,7 +293,12 @@ private boolean deliver(HintsDescriptor descriptor, InetAddressAndPort address)
292293
return false;
293294
}
294295

295-
try (HintsDispatcher dispatcher = HintsDispatcher.create(file, rateLimiter, address, descriptor.hostId, optVersion.get(), shouldAbort))
296+
// Use the minimum of peer's messaging version and storage compatibility mode's version.
297+
// This ensures hints written with the storage-compatible version can be dispatched using the
298+
// encoded path without deserialization, as long as the peer supports that version.
299+
int dispatchVersion = Math.min(optVersion.get(), StorageCompatibilityMode.current().storageMessagingVersion());
300+
301+
try (HintsDispatcher dispatcher = HintsDispatcher.create(file, rateLimiter, address, descriptor.hostId, dispatchVersion, shouldAbort))
296302
{
297303
if (offset != null)
298304
dispatcher.seek(offset);

0 commit comments

Comments
 (0)