You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by be...@apache.org on 2021/08/19 05:43:31 UTC
[cassandra] branch cassandra-3.11 updated: Prevent broken
concurrent schema pulls
This is an automated email from the ASF dual-hosted git repository.
bereng pushed a commit to branch cassandra-3.11
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/cassandra-3.11 by this push:
new 23b61a5 Prevent broken concurrent schema pulls
23b61a5 is described below
commit 23b61a5fa1de17cc6b8a1d7c300053160bfc728a
Author: Bereng <be...@gmail.com>
AuthorDate: Mon Aug 16 07:46:33 2021 +0200
Prevent broken concurrent schema pulls
patch by Dimitar Dimitrov and Berenguer Blasi; reviewed by Brandon Williams, Berenguer Blasi for CASSANDRA-16856
Co-authored-by: Dimitar Dimitrov <dm...@gmail.com>
Co-authored-by: Berenguer Blasi <be...@gmail.com>
---
src/java/org/apache/cassandra/schema/SchemaKeyspace.java | 2 +-
.../org/apache/cassandra/service/MigrationCoordinator.java | 1 +
src/java/org/apache/cassandra/service/MigrationManager.java | 1 +
.../org/apache/cassandra/schema/SchemaKeyspaceTest.java | 13 +++++++++++++
4 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/java/org/apache/cassandra/schema/SchemaKeyspace.java b/src/java/org/apache/cassandra/schema/SchemaKeyspace.java
index b852072..68c0b07 100644
--- a/src/java/org/apache/cassandra/schema/SchemaKeyspace.java
+++ b/src/java/org/apache/cassandra/schema/SchemaKeyspace.java
@@ -380,7 +380,7 @@ public final class SchemaKeyspace
return PartitionRangeReadCommand.allDataRead(cfs.metadata, FBUtilities.nowInSeconds());
}
- public static Collection<Mutation> convertSchemaToMutations()
+ public static synchronized Collection<Mutation> convertSchemaToMutations()
{
Map<DecoratedKey, Mutation> mutationMap = new HashMap<>();
diff --git a/src/java/org/apache/cassandra/service/MigrationCoordinator.java b/src/java/org/apache/cassandra/service/MigrationCoordinator.java
index 10c7551..ce5f269 100644
--- a/src/java/org/apache/cassandra/service/MigrationCoordinator.java
+++ b/src/java/org/apache/cassandra/service/MigrationCoordinator.java
@@ -481,6 +481,7 @@ public class MigrationCoordinator
{
try
{
+ logger.debug("Pulled schema from endpoint {};", endpoint);
mergeSchemaFrom(endpoint, mutations);
}
catch (Exception e)
diff --git a/src/java/org/apache/cassandra/service/MigrationManager.java b/src/java/org/apache/cassandra/service/MigrationManager.java
index 8d8a0bd..21daef2 100644
--- a/src/java/org/apache/cassandra/service/MigrationManager.java
+++ b/src/java/org/apache/cassandra/service/MigrationManager.java
@@ -431,6 +431,7 @@ public class MigrationManager
private static void pushSchemaMutation(InetAddress endpoint, Collection<Mutation> schema)
{
+ logger.debug("Pushing schema to endpoint {}", endpoint);
MessageOut<Collection<Mutation>> msg = new MessageOut<>(MessagingService.Verb.DEFINITIONS_UPDATE,
schema,
MigrationsSerializer.instance);
diff --git a/test/unit/org/apache/cassandra/schema/SchemaKeyspaceTest.java b/test/unit/org/apache/cassandra/schema/SchemaKeyspaceTest.java
index f3ee85d..19f06e5 100644
--- a/test/unit/org/apache/cassandra/schema/SchemaKeyspaceTest.java
+++ b/test/unit/org/apache/cassandra/schema/SchemaKeyspaceTest.java
@@ -19,6 +19,8 @@
package org.apache.cassandra.schema;
import java.io.IOException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
@@ -92,6 +94,17 @@ public class SchemaKeyspaceTest
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1));
}
+ /** See CASSANDRA-16856. Make sure schema pulls are synchronized to prevent concurrent schema pull/writes
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testSchemaPullSynchoricity() throws Exception
+ {
+ Method method = SchemaKeyspace.class.getDeclaredMethod("convertSchemaToMutations");
+ assertTrue(Modifier.isSynchronized(method.getModifiers()));
+ }
+
@Test
public void testThriftConversion() throws Exception
{
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org