You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by aw...@apache.org on 2018/12/13 18:23:58 UTC
[04/10] cassandra git commit: MigrationManager attempts to pull
schema from different major version nodes
MigrationManager attempts to pull schema from different major version nodes
Patch by Ariel Weisberg; Reviewed by Dinesh Joshi for CASSANDRA-14928
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/505a03c7
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/505a03c7
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/505a03c7
Branch: refs/heads/trunk
Commit: 505a03c77764351e1b649e8c7d73d0421e7bcc13
Parents: afa4563
Author: Ariel Weisberg <aw...@apple.com>
Authored: Mon Dec 10 15:50:19 2018 -0500
Committer: Ariel Weisberg <aw...@apple.com>
Committed: Thu Dec 13 12:27:26 2018 -0500
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../apache/cassandra/service/MigrationManager.java | 11 +++++++++--
src/java/org/apache/cassandra/utils/FBUtilities.java | 14 +++++++++++++-
3 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/505a03c7/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index b989f3c..58309fa 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
2.2.14
+ * MigrationManager attempts to pull schema from different major version nodes (CASSANDRA-14928)
* Don't skip entire sstables when reading backwards with mixed clustering column order
(CASSANDRA-14910)
* Cannot perform slice reads in reverse direction against tables with clustering columns
http://git-wip-us.apache.org/repos/asf/cassandra/blob/505a03c7/src/java/org/apache/cassandra/service/MigrationManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/MigrationManager.java b/src/java/org/apache/cassandra/service/MigrationManager.java
index 4cb5ed7..d025196 100644
--- a/src/java/org/apache/cassandra/service/MigrationManager.java
+++ b/src/java/org/apache/cassandra/service/MigrationManager.java
@@ -82,15 +82,22 @@ public class MigrationManager
VersionedValue value = state.getApplicationState(ApplicationState.SCHEMA);
if (!endpoint.equals(FBUtilities.getBroadcastAddress()) && value != null)
- maybeScheduleSchemaPull(UUID.fromString(value.value), endpoint);
+ maybeScheduleSchemaPull(UUID.fromString(value.value), endpoint, state.getApplicationState(ApplicationState.RELEASE_VERSION).value);
}
/**
* If versions differ this node sends request with local migration list to the endpoint
* and expecting to receive a list of migrations to apply locally.
*/
- private static void maybeScheduleSchemaPull(final UUID theirVersion, final InetAddress endpoint)
+ private static void maybeScheduleSchemaPull(final UUID theirVersion, final InetAddress endpoint, String releaseVersion)
{
+ String ourMajorVersion = FBUtilities.getReleaseVersionMajor();
+ if (!releaseVersion.startsWith(ourMajorVersion))
+ {
+ logger.debug("Not pulling schema because release version in Gossip is not major version {}, it is {}", ourMajorVersion, releaseVersion);
+ return;
+ }
+
if ((Schema.instance.getVersion() != null && Schema.instance.getVersion().equals(theirVersion)) || !shouldPullSchemaFrom(endpoint))
{
logger.debug("Not pulling schema because versions match or shouldPullSchemaFrom returned false");
http://git-wip-us.apache.org/repos/asf/cassandra/blob/505a03c7/src/java/org/apache/cassandra/utils/FBUtilities.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/FBUtilities.java b/src/java/org/apache/cassandra/utils/FBUtilities.java
index 23a2c2e..8492fed 100644
--- a/src/java/org/apache/cassandra/utils/FBUtilities.java
+++ b/src/java/org/apache/cassandra/utils/FBUtilities.java
@@ -66,6 +66,8 @@ public class FBUtilities
private static final ObjectMapper jsonMapper = new ObjectMapper(new JsonFactory());
+ public static final String UNKNOWN_RELEASE_VERSION = "Unknown";
+
public static final BigInteger TWO = new BigInteger("2");
private static final String DEFAULT_TRIGGER_DIR = "triggers";
@@ -343,7 +345,7 @@ public class FBUtilities
{
if (in == null)
{
- return System.getProperty("cassandra.releaseVersion", "Unknown");
+ return System.getProperty("cassandra.releaseVersion", UNKNOWN_RELEASE_VERSION);
}
Properties props = new Properties();
props.load(in);
@@ -357,6 +359,16 @@ public class FBUtilities
}
}
+ public static String getReleaseVersionMajor()
+ {
+ String releaseVersion = FBUtilities.getReleaseVersionString();
+ if (FBUtilities.UNKNOWN_RELEASE_VERSION.equals(releaseVersion))
+ {
+ throw new AssertionError("Release version is unknown");
+ }
+ return releaseVersion.substring(0, releaseVersion.indexOf('.'));
+ }
+
public static long timestampMicros()
{
// we use microsecond resolution for compatibility with other client libraries, even though
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org