Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bereng committed Oct 22, 2021
1 parent 8c38463 commit e2231ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
23 changes: 5 additions & 18 deletions src/java/org/apache/cassandra/config/Schema.java
Expand Up @@ -17,26 +17,16 @@
*/
package org.apache.cassandra.config;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;

import org.cliffc.high_scale_lib.NonBlockingHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.cassandra.cql3.functions.Function;
import org.apache.cassandra.cql3.functions.FunctionName;
import org.apache.cassandra.cql3.functions.UDAggregate;
import org.apache.cassandra.cql3.functions.UDFunction;
import org.apache.cassandra.cql3.functions.*;
import org.apache.cassandra.db.ColumnFamilyStore;
import org.apache.cassandra.db.Keyspace;
import org.apache.cassandra.db.SystemKeyspace;
Expand All @@ -48,14 +38,10 @@
import org.apache.cassandra.index.Index;
import org.apache.cassandra.io.sstable.Descriptor;
import org.apache.cassandra.locator.LocalStrategy;
import org.apache.cassandra.schema.KeyspaceMetadata;
import org.apache.cassandra.schema.KeyspaceParams;
import org.apache.cassandra.schema.Keyspaces;
import org.apache.cassandra.schema.SchemaKeyspace;
import org.apache.cassandra.schema.*;
import org.apache.cassandra.service.MigrationManager;
import org.apache.cassandra.utils.ConcurrentBiMap;
import org.apache.cassandra.utils.Pair;
import org.cliffc.high_scale_lib.NonBlockingHashMap;

public class Schema
{
Expand Down Expand Up @@ -851,6 +837,7 @@ private synchronized KeyspaceMetadata update(String keyspaceName, java.util.func

KeyspaceMetadata transformed = transformation.apply(current);
setKeyspaceMetadata(transformed);

return transformed;
}

Expand Down
15 changes: 8 additions & 7 deletions test/unit/org/apache/cassandra/schema/SchemaKeyspaceTest.java
Expand Up @@ -39,6 +39,7 @@

import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

import org.apache.cassandra.SchemaLoader;
import org.apache.cassandra.config.CFMetaData;
Expand Down Expand Up @@ -66,7 +67,6 @@
import org.apache.cassandra.utils.ByteBufferUtil;
import org.apache.cassandra.utils.FBUtilities;
import org.apache.cassandra.utils.Pair;
import org.jboss.byteman.contrib.bmunit.BMRule;

import static org.apache.cassandra.cql3.QueryProcessor.executeOnceInternal;
import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -127,11 +127,6 @@ public void testSchemaPullSynchoricity() throws Exception

/** See CASSANDRA-16856/16996. Make sure schema pulls are synchronized to prevent concurrent schema pull/writes */
@Test
@BMRule(name = "delay partition updates to schema tables",
targetClass = "ColumnFamilyStore",
targetMethod = "apply",
action = "Thread.sleep(5000);",
targetLocation = "AT EXIT")
public void testNoVisiblePartialSchemaUpdates() throws Exception
{
String keyspace = "sandbox";
Expand All @@ -148,7 +143,13 @@ public void testNoVisiblePartialSchemaUpdates() throws Exception

Future<Collection<Mutation>> mutationsFromThread = pool.submit(() -> {
barrier.await();
return SchemaKeyspace.convertSchemaToMutations();

// Make sure we actually have a mutation to check for partial modification.
Collection<Mutation> mutations = SchemaKeyspace.convertSchemaToMutations();
while (mutations.size() == 0)
mutations = SchemaKeyspace.convertSchemaToMutations();

return mutations;
});

creation.get(); // make sure the creation is finished
Expand Down

0 comments on commit e2231ca

Please sign in to comment.