You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by if...@apache.org on 2020/09/22 09:38:07 UTC

[cassandra] branch cassandra-3.11 updated (cbb7644 -> 492009a)

This is an automated email from the ASF dual-hosted git repository.

ifesdjeen pushed a change to branch cassandra-3.11
in repository https://gitbox.apache.org/repos/asf/cassandra.git.


    from cbb7644  Merge branch cassandra-3.0 into cassandra-3.11
     new 2f0eb6f  Fix support for adding UDT fields to clustering keys
     new 2cde7a7  Merge branch 'cassandra-2.2' into cassandra-3.0
     new 492009a  Merge branch 'cassandra-3.0' into cassandra-3.11

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/cassandra/db/marshal/TupleType.java |  32 +++--
 .../db/transform/DuplicateRowChecker.java          |  13 +-
 .../cassandra/distributed/test/FrozenUDTTest.java  | 153 +++++++++++++++++++++
 .../operations/TuplesWithNullsComparisonTest.java  |  78 +++++++++++
 .../db/compaction/CompactionIteratorTest.java      |   2 +-
 5 files changed, 260 insertions(+), 18 deletions(-)
 create mode 100644 test/distributed/org/apache/cassandra/distributed/test/FrozenUDTTest.java
 create mode 100644 test/unit/org/apache/cassandra/cql3/validation/operations/TuplesWithNullsComparisonTest.java


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


[cassandra] 01/01: Merge branch 'cassandra-3.0' into cassandra-3.11

Posted by if...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ifesdjeen pushed a commit to branch cassandra-3.11
in repository https://gitbox.apache.org/repos/asf/cassandra.git

commit 492009ae9b48839cc97540ecb1cf5217c1f30118
Merge: cbb7644 2cde7a7
Author: Alex Petrov <ol...@gmail.com>
AuthorDate: Tue Sep 22 11:34:34 2020 +0200

    Merge branch 'cassandra-3.0' into cassandra-3.11

 .../org/apache/cassandra/db/marshal/TupleType.java |  32 +++--
 .../db/transform/DuplicateRowChecker.java          |  13 +-
 .../cassandra/distributed/test/FrozenUDTTest.java  | 153 +++++++++++++++++++++
 .../operations/TuplesWithNullsComparisonTest.java  |  78 +++++++++++
 .../db/compaction/CompactionIteratorTest.java      |   2 +-
 5 files changed, 260 insertions(+), 18 deletions(-)

diff --cc src/java/org/apache/cassandra/db/transform/DuplicateRowChecker.java
index 7a6f7f9,621821b..57aa0ae
--- a/src/java/org/apache/cassandra/db/transform/DuplicateRowChecker.java
+++ b/src/java/org/apache/cassandra/db/transform/DuplicateRowChecker.java
@@@ -88,10 -93,11 +93,12 @@@ public class DuplicateRowChecker extend
      {
          if (duplicatesDetected > 0)
          {
-             logger.warn("Detected {} duplicate rows for {} during {}",
+             logger.warn("Detected {} duplicate rows for {} during {}.{}",
                          duplicatesDetected,
                          metadata.getKeyValidator().getString(key.getKey()),
-                         stage);
+                         stage,
+                         hadNonEqualDuplicates ? " Some duplicates had different byte representation." : "");
++
              if (snapshotOnDuplicate)
                  DiagnosticSnapshotService.duplicateRows(metadata, replicas);
          }
diff --cc test/distributed/org/apache/cassandra/distributed/test/FrozenUDTTest.java
index 0000000,0000000..2a45b86
new file mode 100644
--- /dev/null
+++ b/test/distributed/org/apache/cassandra/distributed/test/FrozenUDTTest.java
@@@ -1,0 -1,0 +1,153 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements.  See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership.  The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License.  You may obtain a copy of the License at
++ *
++ *     http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.cassandra.distributed.test;
++
++import java.io.IOException;
++import java.util.concurrent.ExecutionException;
++
++import org.junit.Test;
++
++import org.apache.cassandra.distributed.Cluster;
++import org.apache.cassandra.distributed.api.ConsistencyLevel;
++import org.apache.cassandra.service.StorageService;
++
++import static org.apache.cassandra.distributed.shared.AssertUtils.assertRows;
++import static org.apache.cassandra.distributed.shared.AssertUtils.row;
++
++public class FrozenUDTTest extends TestBaseImpl
++{
++    @Test
++    public void testAddAndUDTField() throws IOException
++    {
++        try (Cluster cluster = init(Cluster.build(1).start()))
++        {
++            cluster.schemaChange("create type " + KEYSPACE + ".a (foo text)");
++            cluster.schemaChange("create table " + KEYSPACE + ".x (id int, ck frozen<a>, i int, primary key (id, ck))");
++            for (int i = 0; i < 10; i++)
++                cluster.coordinator(1).execute("insert into " + KEYSPACE + ".x (id, ck, i) VALUES (?, " + json(i) + ", ? )", ConsistencyLevel.ALL, i, i);
++
++            for (int i = 0; i < 10; i++)
++                assertRows(cluster.coordinator(1).execute("select i from " + KEYSPACE + ".x WHERE id = ? and ck = " + json(i), ConsistencyLevel.ALL, i),
++                           row(i));
++
++            cluster.schemaChange("alter type " + KEYSPACE + ".a add bar text");
++
++            for (int i = 5; i < 15; i++)
++                cluster.coordinator(1).execute("insert into " + KEYSPACE + ".x (id, ck, i) VALUES (?, " + json(i) + ", ? )", ConsistencyLevel.ALL, i, i);
++            cluster.forEach(i -> i.flush(KEYSPACE));
++
++            for (int i = 5; i < 15; i++)
++                assertRows(cluster.coordinator(1).execute("select i from " + KEYSPACE + ".x WHERE id = ? and ck = " + json(i), ConsistencyLevel.ALL, i),
++                           row(i));
++        }
++    }
++
++    @Test
++    public void testEmptyValue() throws IOException
++    {
++        try (Cluster cluster = init(Cluster.build(1).start()))
++        {
++            cluster.schemaChange("create type " + KEYSPACE + ".a (foo text)");
++            cluster.schemaChange("create table " + KEYSPACE + ".x (id int, ck frozen<a>, i int, primary key (id, ck))");
++            cluster.coordinator(1).execute("insert into " + KEYSPACE + ".x (id, ck, i) VALUES (1, system.fromjson('{\"foo\":\"\"}'), 1)", ConsistencyLevel.ALL);
++            cluster.coordinator(1).execute("insert into " + KEYSPACE + ".x (id, ck, i) VALUES (1, system.fromjson('{\"foo\":\"a\"}'), 2)", ConsistencyLevel.ALL);
++            cluster.forEach(i -> i.flush(KEYSPACE));
++
++            Runnable check = () -> {
++                assertRows(cluster.coordinator(1).execute("select i from " + KEYSPACE + ".x WHERE id = 1 and ck = system.fromjson('{\"foo\":\"\"}')", ConsistencyLevel.ALL),
++                           row(1));
++                assertRows(cluster.coordinator(1).execute("select i from " + KEYSPACE + ".x WHERE id = 1 and ck = system.fromjson('{\"foo\":\"a\"}')", ConsistencyLevel.ALL),
++                           row(2));
++            };
++
++            check.run();
++            cluster.schemaChange("alter type " + KEYSPACE + ".a add bar text");
++            check.run();
++
++            assertRows(cluster.coordinator(1).execute("select i from " + KEYSPACE + ".x WHERE id = 1 and ck = system.fromjson('{\"foo\":\"\",\"bar\":\"\"}')", ConsistencyLevel.ALL));
++            cluster.coordinator(1).execute("insert into " + KEYSPACE + ".x (id, ck, i) VALUES (1, system.fromjson('{\"foo\":\"\",\"bar\":\"\"}'), 3)", ConsistencyLevel.ALL);
++            check.run();
++            assertRows(cluster.coordinator(1).execute("select i from " + KEYSPACE + ".x WHERE id = 1 and ck = system.fromjson('{\"foo\":\"\",\"bar\":\"\"}')", ConsistencyLevel.ALL),
++                       row(3));
++        }
++    }
++
++    @Test
++    public void testUpgradeSStables() throws IOException
++    {
++        try (Cluster cluster = init(Cluster.build(1).start()))
++        {
++            cluster.schemaChange("create type " + KEYSPACE + ".a (foo text)");
++            cluster.schemaChange("create table " + KEYSPACE + ".x (id int, ck frozen<a>, i int, primary key (id, ck))");
++            cluster.coordinator(1).execute("insert into " + KEYSPACE + ".x (id, ck, i) VALUES (?, " + json(1) + ", ? )", ConsistencyLevel.ALL, 1, 1);
++            assertRows(cluster.coordinator(1).execute("select i from " + KEYSPACE + ".x WHERE id = ? and ck = " + json(1), ConsistencyLevel.ALL, 1), row(1));
++            cluster.forEach(i -> i.flush(KEYSPACE));
++            assertRows(cluster.coordinator(1).execute("select i from " + KEYSPACE + ".x WHERE id = ? and ck = " + json(1), ConsistencyLevel.ALL, 1), row(1));
++
++            cluster.schemaChange("alter type " + KEYSPACE + ".a add bar text");
++            cluster.coordinator(1).execute("insert into " + KEYSPACE + ".x (id, ck, i) VALUES (?, " + json(2) + ", ? )", ConsistencyLevel.ALL, 2, 2);
++            cluster.forEach(i -> i.flush(KEYSPACE));
++            assertRows(cluster.coordinator(1).execute("select i from " + KEYSPACE + ".x WHERE id = ? and ck = " + json(2), ConsistencyLevel.ALL, 2), row(2));
++
++            cluster.forEach(i -> i.runOnInstance(() -> {
++                try
++                {
++                    StorageService.instance.upgradeSSTables(KEYSPACE, false, "x");
++                }
++                catch (IOException | ExecutionException | InterruptedException e)
++                {
++                    throw new RuntimeException(e);
++                }
++            }));
++
++            cluster.forEach(i -> i.forceCompact(KEYSPACE, "x"));
++
++            for (int i = 1; i < 3; i++)
++                assertRows(cluster.coordinator(1).execute("select i from " + KEYSPACE + ".x WHERE id = ? and ck = " + json(i), ConsistencyLevel.ALL, i),
++                           row(i));
++        }
++    }
++
++    @Test
++    public void testDivergentSchemas() throws Throwable
++    {
++        try (Cluster cluster = init(Cluster.create(2)))
++        {
++            cluster.schemaChange("create type " + KEYSPACE + ".a (foo text)");
++            cluster.schemaChange("create table " + KEYSPACE + ".x (id int, ck frozen<a>, i int, primary key (id, ck))");
++
++            cluster.get(1).executeInternal("alter type " + KEYSPACE + ".a add bar text");
++            cluster.coordinator(1).execute("insert into " + KEYSPACE + ".x (id, ck, i) VALUES (?, " + json(1, 1) + ", ? )", ConsistencyLevel.ALL,
++                                           1, 1);
++            cluster.coordinator(1).execute("insert into " + KEYSPACE + ".x (id, ck, i) VALUES (?, " + json(1, 2) + ", ? )", ConsistencyLevel.ALL,
++                                           2, 2);
++            cluster.get(2).flush(KEYSPACE);
++        }
++    }
++
++    private String json(int i)
++    {
++        return String.format("system.fromjson('{\"foo\":\"%d\"}')", i);
++    }
++
++    private String json(int i, int j)
++    {
++        return String.format("system.fromjson('{\"foo\":\"%d\", \"bar\":\"%d\"}')", i, j);
++    }
++}
diff --cc test/unit/org/apache/cassandra/cql3/validation/operations/TuplesWithNullsComparisonTest.java
index 0000000,0000000..5a1bc69
new file mode 100644
--- /dev/null
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/TuplesWithNullsComparisonTest.java
@@@ -1,0 -1,0 +1,78 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements.  See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership.  The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License.  You may obtain a copy of the License at
++ *
++ *     http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.cassandra.cql3.validation.operations;
++
++import org.junit.Test;
++
++import org.apache.cassandra.cql3.CQLTester;
++
++public class TuplesWithNullsComparisonTest extends CQLTester
++{
++    @Test
++    public void testAddUDTField() throws Throwable
++    {
++        String typename = createType("create type %s (foo text);");
++        createTable("create table %s (pk int, ck frozen<" + typename + ">, v int, primary key(pk, ck));");
++        execute("insert into %s (pk, ck, v) values (0, system.fromjson('{\"foo\": \"foo\"}'), 0);");
++        execute("ALTER TYPE " + KEYSPACE + '.' + typename + " ADD bar text;");
++        execute("insert into %s (pk, ck, v) values (0, system.fromjson('{\"foo\": \"foo\"}'), 1);");
++        execute("insert into %s (pk, ck, v) values (0, system.fromjson('{\"foo\": \"foo\", \"bar\": null}'), 2);");
++        flush();
++        compact();
++        assertRows(execute("select v from %s where pk = 0 and ck=system.fromjson('{\"foo\": \"foo\"}')"),
++                   row(2));
++        assertRows(execute("select v from %s where pk = 0"),
++                   row(2));
++    }
++
++    @Test
++    public void testFieldWithData() throws Throwable
++    {
++        String typename = createType("create type %s (foo text);");
++        createTable("create table %s (pk int, ck frozen<" + typename + ">, v int, primary key(pk, ck));");
++        execute("insert into %s (pk, ck, v) values (0, system.fromjson('{\"foo\": \"foo\"}'), 1);");
++        execute("ALTER TYPE " + KEYSPACE + '.' + typename + " ADD bar text;");
++        // this row becomes inaccessible by primary key but remains visible through select *
++        execute("insert into %s (pk, ck, v) values (0, system.fromjson('{\"foo\": \"foo\", \"bar\": \"bar\"}'), 2);");
++        flush();
++        compact();
++        assertRows(execute("select v from %s where pk = 0"),
++                   row(1),
++                   row(2));
++    }
++
++    @Test
++    public void testAddUDTFields() throws Throwable
++    {
++        String typename = createType("create type %s (foo text);");
++        createTable("create table %s (pk int, ck frozen<" + typename + ">, v int, primary key(pk, ck));");
++        execute("insert into %s (pk, ck, v) values (0, system.fromjson('{\"foo\": \"foo\"}'), 0);");
++        execute("ALTER TYPE " + KEYSPACE + '.' + typename + " ADD bar text;");
++        execute("ALTER TYPE " + KEYSPACE + '.' + typename + " ADD bar2 text;");
++        execute("ALTER TYPE " + KEYSPACE + '.' + typename + " ADD bar3 text;");
++        execute("insert into %s (pk, ck, v) values (0, system.fromjson('{\"foo\": \"foo\"}'), 1);");
++        execute("insert into %s (pk, ck, v) values (0, system.fromjson('{\"foo\": \"foo\", \"bar\": null, \"bar2\": null, \"bar3\": null}'), 2);");
++        flush();
++        compact();
++        assertRows(execute("select v from %s where pk = 0 and ck=system.fromjson('{\"foo\": \"foo\"}')"),
++                   row(2));
++        assertRows(execute("select v from %s where pk = 0"),
++                   row(2));
++    }
++}
diff --cc test/unit/org/apache/cassandra/db/compaction/CompactionIteratorTest.java
index 58c5a00,549a94d..d39a2d9
--- a/test/unit/org/apache/cassandra/db/compaction/CompactionIteratorTest.java
+++ b/test/unit/org/apache/cassandra/db/compaction/CompactionIteratorTest.java
@@@ -448,13 -90,11 +448,13 @@@ public class CompactionIteratorTest ext
          assertCommandIssued(sentMessages, true);
      }
  
 -    private void iterate(ColumnFamilyStore cfs, UnfilteredPartitionIterator partitions)
 +    private void iterate(Unfiltered...unfiltereds)
      {
 -
 -        try (CompactionController controller = new CompactionController(getCurrentColumnFamilyStore(), Integer.MAX_VALUE);
 -             ISSTableScanner scanner = scanner(cfs, partitions);
 +        ColumnFamilyStore cfs = getCurrentColumnFamilyStore();
 +        DecoratedKey key = cfs.metadata.partitioner.decorateKey(ByteBufferUtil.bytes("key"));
 +        try (CompactionController controller = new CompactionController(cfs, Integer.MAX_VALUE);
-              UnfilteredRowIterator rows = rows(metadata, key, false, unfiltereds);
++             UnfilteredRowIterator rows = rows(cfs.metadata, key, false, unfiltereds);
 +             ISSTableScanner scanner = new Scanner(Collections.singletonList(rows));
               CompactionIterator iter = new CompactionIterator(OperationType.COMPACTION,
                                                                Collections.singletonList(scanner),
                                                                controller, FBUtilities.nowInSeconds(), null))


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org