-
Notifications
You must be signed in to change notification settings - Fork 21
CNDB-13203: Use MessagingSuccess's version for cnx version #1621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
05220f8
d8ff25c
7489ca7
c46e015
d377fd1
4a398b1
19bd463
a92a2db
9fe030a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -74,6 +74,9 @@ | |||||||||||||||||||||||||||||||||||||||||||
| import static org.apache.cassandra.net.MessagingService.VERSION_30; | ||||||||||||||||||||||||||||||||||||||||||||
| import static org.apache.cassandra.net.MessagingService.VERSION_3014; | ||||||||||||||||||||||||||||||||||||||||||||
| import static org.apache.cassandra.net.MessagingService.VERSION_40; | ||||||||||||||||||||||||||||||||||||||||||||
| import static org.apache.cassandra.net.MessagingService.VERSION_DS_10; | ||||||||||||||||||||||||||||||||||||||||||||
| import static org.apache.cassandra.net.MessagingService.VERSION_DS_11; | ||||||||||||||||||||||||||||||||||||||||||||
| import static org.apache.cassandra.net.MessagingService.minimum_version; | ||||||||||||||||||||||||||||||||||||||||||||
| import static org.apache.cassandra.net.NoPayload.noPayload; | ||||||||||||||||||||||||||||||||||||||||||||
| import static org.apache.cassandra.net.MessagingService.current_version; | ||||||||||||||||||||||||||||||||||||||||||||
| import static org.apache.cassandra.net.ConnectionUtils.*; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -121,17 +124,24 @@ public void resetVerbs() throws Throwable | |||||||||||||||||||||||||||||||||||||||||||
| timeouts.clear(); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| private static volatile long originalRpcTimeout = 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| @BeforeClass | ||||||||||||||||||||||||||||||||||||||||||||
| public static void startup() | ||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||
| DatabaseDescriptor.daemonInitialization(); | ||||||||||||||||||||||||||||||||||||||||||||
| CommitLog.instance.start(); | ||||||||||||||||||||||||||||||||||||||||||||
| // At the time of this commit, the default is 20 seconds and leads to significant delays | ||||||||||||||||||||||||||||||||||||||||||||
| // in this test class, especially in testMessagePurging and testCloseIfEndpointDown. | ||||||||||||||||||||||||||||||||||||||||||||
| originalRpcTimeout = DatabaseDescriptor.getRpcTimeout(TimeUnit.MILLISECONDS); | ||||||||||||||||||||||||||||||||||||||||||||
| DatabaseDescriptor.setRpcTimeout(5000L); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| @AfterClass | ||||||||||||||||||||||||||||||||||||||||||||
| public static void cleanup() throws InterruptedException | ||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||
| factory.shutdownNow(); | ||||||||||||||||||||||||||||||||||||||||||||
| DatabaseDescriptor.setRpcTimeout(originalRpcTimeout); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| interface SendTest | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -192,30 +202,54 @@ Settings override(Settings settings) | |||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // 30 is used for CNDB compatibility | ||||||||||||||||||||||||||||||||||||||||||||
| static final AcceptVersions legacy = new AcceptVersions(VERSION_3014, VERSION_3014); | ||||||||||||||||||||||||||||||||||||||||||||
| static final AcceptVersions ds10 = new AcceptVersions(minimum_version, VERSION_DS_10); | ||||||||||||||||||||||||||||||||||||||||||||
| static final AcceptVersions ds11 = new AcceptVersions(minimum_version, VERSION_DS_11); | ||||||||||||||||||||||||||||||||||||||||||||
| static final AcceptVersions current = new AcceptVersions(current_version, current_version); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| static final List<Function<Settings, Settings>> MODIFIERS = ImmutableList.of( | ||||||||||||||||||||||||||||||||||||||||||||
| static final List<Function<Settings, Settings>> MESSAGGING_VERSIONS = ImmutableList.of( | ||||||||||||||||||||||||||||||||||||||||||||
| settings -> settings.outbound(outbound -> outbound.withAcceptVersions(legacy)) | ||||||||||||||||||||||||||||||||||||||||||||
| .inbound(inbound -> inbound.withAcceptMessaging(legacy)), | ||||||||||||||||||||||||||||||||||||||||||||
| // Mismatched versions (in both directions) to ensure both peers will still agree on the same version. | ||||||||||||||||||||||||||||||||||||||||||||
| settings -> settings.outbound(outbound -> outbound.withAcceptVersions(ds11)) | ||||||||||||||||||||||||||||||||||||||||||||
| .inbound(inbound -> inbound.withAcceptMessaging(ds10)), | ||||||||||||||||||||||||||||||||||||||||||||
| settings -> settings.outbound(outbound -> outbound.withAcceptVersions(ds10)) | ||||||||||||||||||||||||||||||||||||||||||||
| .inbound(inbound -> inbound.withAcceptMessaging(ds11)), | ||||||||||||||||||||||||||||||||||||||||||||
| // This setting ensures that we cover the current case for the power set where no versions are overridden. | ||||||||||||||||||||||||||||||||||||||||||||
| settings -> settings.outbound(outbound -> outbound.withAcceptVersions(current)) | ||||||||||||||||||||||||||||||||||||||||||||
| .inbound(inbound -> inbound.withAcceptMessaging(current)) | ||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| static final List<Function<Settings, Settings>> MODIFIERS = ImmutableList.of( | ||||||||||||||||||||||||||||||||||||||||||||
| settings -> settings.outbound(outbound -> outbound.withEncryption(encryptionOptions)) | ||||||||||||||||||||||||||||||||||||||||||||
| .inbound(inbound -> inbound.withEncryption(encryptionOptions)), | ||||||||||||||||||||||||||||||||||||||||||||
| settings -> settings.outbound(outbound -> outbound.withFraming(LZ4)) | ||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // Messaging versions are a kind of modifier, but they can only be applied once per setting, so they are broken | ||||||||||||||||||||||||||||||||||||||||||||
| // out into a separate list. | ||||||||||||||||||||||||||||||||||||||||||||
| static final List<Settings> SETTINGS = applyPowerSet( | ||||||||||||||||||||||||||||||||||||||||||||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The extra complexity of these settings appears to be an issue for some tests. In looking closer, I can see that the rpc timeout is affecting some, like
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For reference, the delay in cassandra/src/java/org/apache/cassandra/net/OutboundConnection.java Lines 1089 to 1109 in 19bd463
|
||||||||||||||||||||||||||||||||||||||||||||
| ImmutableList.of(Settings.SMALL, Settings.LARGE), | ||||||||||||||||||||||||||||||||||||||||||||
| ImmutableList.of(ConnectionTest.Settings.SMALL, ConnectionTest.Settings.LARGE), | ||||||||||||||||||||||||||||||||||||||||||||
| MESSAGGING_VERSIONS, | ||||||||||||||||||||||||||||||||||||||||||||
| MODIFIERS | ||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| private static <T> List<T> applyPowerSet(List<T> settings, List<Function<T, T>> modifiers) | ||||||||||||||||||||||||||||||||||||||||||||
| private static List<Settings> applyPowerSet(List<ConnectionTest.Settings> settings, | ||||||||||||||||||||||||||||||||||||||||||||
| List<Function<ConnectionTest.Settings, ConnectionTest.Settings>> messagingVersions, | ||||||||||||||||||||||||||||||||||||||||||||
| List<Function<ConnectionTest.Settings, ConnectionTest.Settings>> modifiers) | ||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||
| List<T> result = new ArrayList<>(); | ||||||||||||||||||||||||||||||||||||||||||||
| for (Set<Function<T, T>> set : Sets.powerSet(new HashSet<>(modifiers))) | ||||||||||||||||||||||||||||||||||||||||||||
| List<Settings> result = new ArrayList<>(); | ||||||||||||||||||||||||||||||||||||||||||||
| for (Function<ConnectionTest.Settings, ConnectionTest.Settings> messagingVersion : messagingVersions) | ||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||
| for (T s : settings) | ||||||||||||||||||||||||||||||||||||||||||||
| for (Set<Function<Settings, ConnectionTest.Settings>> set : Sets.powerSet(new HashSet<>(modifiers))) | ||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||
| for (Function<T, T> f : set) | ||||||||||||||||||||||||||||||||||||||||||||
| s = f.apply(s); | ||||||||||||||||||||||||||||||||||||||||||||
| result.add(s); | ||||||||||||||||||||||||||||||||||||||||||||
| for (ConnectionTest.Settings s : settings) | ||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||
| for (Function<Settings, ConnectionTest.Settings> f : set) | ||||||||||||||||||||||||||||||||||||||||||||
| s = f.apply(s); | ||||||||||||||||||||||||||||||||||||||||||||
| s = messagingVersion.apply(s); | ||||||||||||||||||||||||||||||||||||||||||||
| result.add(s); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| return result; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -306,6 +340,10 @@ public void testSendSmall() throws Throwable | |||||||||||||||||||||||||||||||||||||||||||
| .expired ( 0, 0) | ||||||||||||||||||||||||||||||||||||||||||||
| .error ( 0, 0) | ||||||||||||||||||||||||||||||||||||||||||||
| .check(); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // Ensure version is the same | ||||||||||||||||||||||||||||||||||||||||||||
| inbound.assertHandlersMessagingVersion(outbound.messagingVersion()); | ||||||||||||||||||||||||||||||||||||||||||||
| Assert.assertEquals(outbound.settings().endpointToVersion.get(endpoint), outbound.messagingVersion()); | ||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -360,6 +398,10 @@ public long serializedSize(Object noPayload, int version) | |||||||||||||||||||||||||||||||||||||||||||
| .expired ( 0, 0) | ||||||||||||||||||||||||||||||||||||||||||||
| .error ( 0, 0) | ||||||||||||||||||||||||||||||||||||||||||||
| .check(); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // Ensure version is the same | ||||||||||||||||||||||||||||||||||||||||||||
| inbound.assertHandlersMessagingVersion(outbound.messagingVersion()); | ||||||||||||||||||||||||||||||||||||||||||||
| Assert.assertEquals(outbound.settings().endpointToVersion.get(endpoint), outbound.messagingVersion()); | ||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the whole code path to make sure this is the right fix, as the way messaging versions are handled is far from obvious. It is indeed the right one as it ultimately affect the
established.messagingVersionas used here.Just one additional note, should we also invoke
settings.endpointToVersion.set()with the new version?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reading it closely. I set it here with the intention of using it for the
Establishedconstructor, so we're on the same page there.I tested with this yesterday and I will test a bit more today. My primary reason for pushing this without that additional line is from the
InboundConnectionInitatorhere:cassandra/src/java/org/apache/cassandra/net/InboundConnectionInitiator.java
Lines 458 to 459 in ce0edf4
It seems like these might be "okay" to diverge, but that's only true if the
endpointToVersionviews the peer as having a greater version than it actually does (because the only reason the connection version in that case is that the local host has a lower version). However, maybe the difference is not always that the connection is LT the remote peer.I can confirm that these numbers vary without
settings.endpointToVersion.set().There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will look at this a bit more today to come up with a decision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sbtourist - I added
assert messagingVersion <= settings.endpointToVersion.get(settings.to)to that code block and theConnectionTesttests passed. I think that likely means my understanding is correct. I don't know all of the details here, and I definitely don't know the past implementations that we need to be compatible with. Let me know if you think I should addsettings.endpointToVersion.set(...), but at this time, I don't think it is strictly necessary for this patch.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen that, but the
versionsobject you point at is not the same as the one used insettings, which seems specific to the connection. My proof to that is in the case RETRY block, we do set the version; wdyt?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize they were different versions objects. I saw the retry block, but wasn't quite sure how things integrated. I am happy to add the assignment in, if you think that is right. I just haven't had a chance to fully vet it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The versions inside
settings.endpointToVersiondon't seem to be used anywhere seriously, but setting the right version there seems correct to me nonetheless. Though honestly this code is not the best, so please take your time to vet my suggestion.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
settings.endpointToVersionis set by callingendpointToVersion()in a constructor, which is:so unless I'm mistaken, there is only one
EndpointMessagingVersionsobject. I don't see another way to configure it. As such, I hesitate to change this value. It seems like its own distinct change. I will leave in the assertion so that it'll trigger test failures if the value is LT the agreed upon version for the connection.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After adding the assertion and running the upgrade test, I hit the following:
After analyzing it and adding additional logs to CC (relevant logs pasted below), we are getting into trouble because IP addresses are getting reused and the
versionsmap doesn't get cleaned up.writer-0uses ds 10 andwriter-1uses ds 11, but they both end up with the same ip address because their runtimes do not overlap. The key log line comes here:Initiate(request: 100, min: 10, max: 101, type: SMALL_MESSAGES, framing: true, from: /192.168.240.4:7000)where we can see that the DS 11 coordinator sends a messaging requesting version 100 (ds 10) instead of 101 (ds 11).This confirms that the
versionsmap is shared. It also indicates we should either (1) update the map or (2) purge the map after a peer leaves (given the times in the logs, this doesn't appear automatic, but perhaps there is some timeout that must be hit before we purge the old versions).Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the gossiper calls
MessagingService.instance().versions.reset(endpoint);. So perhaps this isn't code that is likely to be encountered. Either way, I am good to set the value now.