Skip to content

Commit 6e8b4ce

Browse files
michaelsembweverdriftx
authored andcommitted
HCD-136 – DSE 6.8 to CC4 internode transport compatibility
CC4 can only communicate with DSE 6.8 on messaging version VERSION_3014 (messaging/protocol version 11) and VERSION_3014 (messaging/protocol version 11). Manully setting the CC4 node's `MessagingService.current_version` achieves this, done using the jvm flag `-Dds.current_messaging_version=11`. Using VERSION_30 (messaging/protocol version 10) is also accepted, but hits the column filter bug on system tables `select *` queries during startup. This commits automates the DSE 6.8 detection and negotiation when the maxMessagingVersion in the handshake is above 256, replying with a max accept of VERSION_3014. The ds.current_messaging_version flag is kept, as when it is used everything behaves as it previously did. This is important for CNDB, as it hasn't dropped support for bdp/cndb-6.8 (a customised version of DSE 6.8). The flag and fields related to it are marked deprecated and can be removed in CC5. Logging in OutboundConnectionInitiator is improved with an introduced ClosedOutboundConnectionException that extends ClosedChannelException. ClosedOutboundConnectionException adds a message including the requestMessagingVersion, settings.framing and settings.encryption variables. In StartupClusterConnectivityChecker, don't send PING_REQ messages to any DSE 6.x/C* 3.x peers. They are not required (only speed up startup times), and isn't understood anyway by those peers. Fix commit log versions, as they were being incorrectly written with filenames using messaging versions not corresponding to commit log versions. Introduce CommitLogDescriptor.currentVersion() to translate messaging versions to commit log versions. This is important to honour custom ds.current_messaging_version values.
1 parent b38dadc commit 6e8b4ce

File tree

4 files changed

+71
-4
lines changed

4 files changed

+71
-4
lines changed

src/java/org/apache/cassandra/config/CassandraRelevantProperties.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,9 @@ public enum CassandraRelevantProperties
371371
/**
372372
* The current messaging version. This is used when we add new messaging versions without adopting them immediately,
373373
* or to force the node to use a specific version for testing purposes.
374+
* @deprecated remove when cndb no longer supports bdp/6.8-cndb
374375
*/
376+
@Deprecated(since = "5.0")
375377
DS_CURRENT_MESSAGING_VERSION("ds.current_messaging_version", Integer.toString(MessagingService.VERSION_DS_20)),
376378
DTEST_API_LOG_TOPOLOGY("cassandra.dtest.api.log.topology"),
377379
/** This property indicates if the code is running under the in-jvm dtest framework */

src/java/org/apache/cassandra/db/commitlog/CommitLogDescriptor.java

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ public class CommitLogDescriptor
7676

7777
/**
7878
* Increment this number if there is a changes in the commit log disc layout or MessagingVersion changes.
79-
* Note: make sure to handle {@link #getMessagingVersion()}
79+
* Note: make sure to handle {@link #currentVersion()} and {@link #getMessagingVersion()}
8080
*/
81-
public static final int CURRENT_VERSION = MessagingService.current_version;
81+
public static final int CURRENT_VERSION = currentVersion();
8282

8383
final int version;
8484
public final long id;
@@ -226,7 +226,13 @@ private static Matcher extactFromFileName(String name)
226226

227227
public int getMessagingVersion()
228228
{
229-
switch (version)
229+
return getMessagingVersion(version);
230+
}
231+
232+
@VisibleForTesting
233+
static int getMessagingVersion(int commitLogVersion)
234+
{
235+
switch (commitLogVersion)
230236
{
231237
case VERSION_30:
232238
return MessagingService.Version.VERSION_30.value;
@@ -243,7 +249,37 @@ public int getMessagingVersion()
243249
case VERSION_DSE_68:
244250
return MessagingService.Version.VERSION_DSE_68.value;
245251
default:
246-
throw new IllegalStateException("Unknown commitlog version " + version);
252+
throw new IllegalStateException("Unknown commitlog version " + commitLogVersion);
253+
}
254+
}
255+
256+
private static int currentVersion()
257+
{
258+
return currentVersion(MessagingService.current_version);
259+
}
260+
261+
@VisibleForTesting
262+
static int currentVersion(int messagingVersion)
263+
{
264+
switch(messagingVersion)
265+
{
266+
case MessagingService.VERSION_30:
267+
case MessagingService.VERSION_3014:
268+
return VERSION_30;
269+
case MessagingService.VERSION_40:
270+
return VERSION_40;
271+
case MessagingService.VERSION_50:
272+
return VERSION_50;
273+
case MessagingService.VERSION_DSE_68:
274+
return VERSION_DSE_68;
275+
case MessagingService.VERSION_DS_10:
276+
return VERSION_DS_10;
277+
case MessagingService.VERSION_DS_11:
278+
return VERSION_DS_11;
279+
case MessagingService.VERSION_DS_20:
280+
return VERSION_DS_20;
281+
default:
282+
throw new IllegalStateException("Unknown messaging version " + messagingVersion);
247283
}
248284
}
249285

src/java/org/apache/cassandra/net/MessagingService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ public static boolean supportsExtendedDeletionTime(int value)
297297
}
298298
static Map<Integer, Integer> versionOrdinalMap = Arrays.stream(Version.values()).collect(Collectors.toMap(v -> v.value, Enum::ordinal));
299299

300+
@Deprecated(since = "5.0") // remove when cndb no longer supports bdp/6.8-cndb
300301
private static int currentVersion()
301302
{
302303
int version = CassandraRelevantProperties.DS_CURRENT_MESSAGING_VERSION.getInt();

test/unit/org/apache/cassandra/db/commitlog/CommitLogDescriptorTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,4 +349,32 @@ public void testDSE68MessagingVersion()
349349
CommitLogDescriptor descriptor = new CommitLogDescriptor(680, 1, null, null);
350350
Assert.assertEquals(MessagingService.VERSION_DSE_68, descriptor.getMessagingVersion());
351351
}
352+
353+
@Test
354+
public void testMessagingToCommitLogVersionSymmetry()
355+
{
356+
for (MessagingService.Version messagingVersion : MessagingService.Version.values())
357+
{
358+
int commitLogVersion = CommitLogDescriptor.currentVersion(messagingVersion.value);
359+
360+
// special case for MessagingService.VERSION_3014
361+
int expectedMessagingVersion = messagingVersion.value;
362+
if (MessagingService.Version.VERSION_3014 == messagingVersion)
363+
expectedMessagingVersion = MessagingService.VERSION_30;
364+
365+
Assert.assertEquals(expectedMessagingVersion, CommitLogDescriptor.getMessagingVersion(commitLogVersion));
366+
}
367+
}
368+
369+
@Test(expected = IllegalStateException.class)
370+
public void testMessagingToCommitLogVersionFailure()
371+
{
372+
CommitLogDescriptor.currentVersion(1);
373+
}
374+
375+
@Test(expected = IllegalStateException.class)
376+
public void testCommitLogToMessagingVersionFailure()
377+
{
378+
CommitLogDescriptor.getMessagingVersion(1);
379+
}
352380
}

0 commit comments

Comments
 (0)