You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ma...@apache.org on 2020/04/16 11:01:36 UTC

[cassandra] branch cassandra-3.0 updated (29c8624 -> 5774096)

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

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


    from 29c8624  Merge branch 'cassandra-2.2' into cassandra-3.0
     new 16f639a  Duplicate results with DISTINCT queries in mixed mode
     new 5774096  Merge branch 'cassandra-2.2' into cassandra-3.0

The 2 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:
 CHANGES.txt                                        |  3 +-
 .../service/pager/PartitionRangeQueryPager.java    |  5 +-
 .../cassandra/distributed/UpgradeableCluster.java  |  7 ++
 .../distributed/impl/AbstractCluster.java          | 11 ++-
 .../impl/DelegatingInvokableInstance.java          |  3 +-
 .../cassandra/distributed/impl/Instance.java       |  2 +-
 .../upgrade/MixedModeReadRepairTest.java           | 27 +++---
 .../cassandra/distributed/upgrade/PagingTest.java  | 96 ++++++++++++++++++++++
 .../distributed/upgrade/UpgradeTestBase.java       | 13 ++-
 9 files changed, 142 insertions(+), 25 deletions(-)
 create mode 100644 test/distributed/org/apache/cassandra/distributed/upgrade/PagingTest.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-2.2' into cassandra-3.0

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

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

commit 577409673e9d52385a7c2c175b0e1ef4e0317cba
Merge: 29c8624 16f639a
Author: Marcus Eriksson <ma...@apache.org>
AuthorDate: Thu Apr 16 12:52:07 2020 +0200

    Merge branch 'cassandra-2.2' into cassandra-3.0

 CHANGES.txt                                        |  3 +-
 .../service/pager/PartitionRangeQueryPager.java    |  5 +-
 .../cassandra/distributed/UpgradeableCluster.java  |  7 ++
 .../distributed/impl/AbstractCluster.java          | 11 ++-
 .../impl/DelegatingInvokableInstance.java          |  3 +-
 .../cassandra/distributed/impl/Instance.java       |  2 +-
 .../upgrade/MixedModeReadRepairTest.java           | 27 +++---
 .../cassandra/distributed/upgrade/PagingTest.java  | 96 ++++++++++++++++++++++
 .../distributed/upgrade/UpgradeTestBase.java       | 13 ++-
 9 files changed, 142 insertions(+), 25 deletions(-)

diff --cc CHANGES.txt
index eb0b66e,6913575..5af0ef3
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,10 -1,10 +1,11 @@@
 -2.2.18
 +3.0.21
 + * Memtable memory allocations may deadlock (CASSANDRA-15367)
 + * Run evictFromMembership in GossipStage (CASSANDRA-15592)
 +Merged from 2.2:
+  * Duplicate results with DISTINCT queries in mixed mode (CASSANDRA-15501)
   * Disable JMX rebinding (CASSANDRA-15653)
  Merged from 2.1:
--  * Fix parse error in cqlsh COPY FROM and formatting for map of blobs (CASSANDRA-15679)
 -
 -2.2.17
++ * Fix parse error in cqlsh COPY FROM and formatting for map of blobs (CASSANDRA-15679)
   * Fix Commit log replays when static column clustering keys are collections (CASSANDRA-14365)
   * Fix Red Hat init script on newer systemd versions (CASSANDRA-15273)
   * Allow EXTRA_CLASSPATH to work on tar/source installations (CASSANDRA-15567)
diff --cc src/java/org/apache/cassandra/service/pager/PartitionRangeQueryPager.java
index ea79017,0000000..aed5a23
mode 100644,000000..100644
--- a/src/java/org/apache/cassandra/service/pager/PartitionRangeQueryPager.java
+++ b/src/java/org/apache/cassandra/service/pager/PartitionRangeQueryPager.java
@@@ -1,124 -1,0 +1,127 @@@
 +/*
 + * 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.service.pager;
 +
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +
 +import org.apache.cassandra.db.*;
 +import org.apache.cassandra.db.filter.DataLimits;
 +import org.apache.cassandra.db.rows.Row;
 +import org.apache.cassandra.dht.*;
 +import org.apache.cassandra.exceptions.RequestExecutionException;
 +
 +/**
 + * Pages a PartitionRangeReadCommand.
 + *
 + * Note: this only work for CQL3 queries for now (because thrift queries expect
 + * a different limit on the rows than on the columns, which complicates it).
 + */
 +public class PartitionRangeQueryPager extends AbstractQueryPager
 +{
 +    private static final Logger logger = LoggerFactory.getLogger(PartitionRangeQueryPager.class);
 +
 +    private volatile DecoratedKey lastReturnedKey;
 +    private volatile PagingState.RowMark lastReturnedRow;
 +
 +    public PartitionRangeQueryPager(PartitionRangeReadCommand command, PagingState state, int protocolVersion)
 +    {
 +        super(command, protocolVersion);
 +
 +        if (state != null)
 +        {
 +            lastReturnedKey = command.metadata().decorateKey(state.partitionKey);
 +            lastReturnedRow = state.rowMark;
 +            restoreState(lastReturnedKey, state.remaining, state.remainingInPartition);
 +        }
 +    }
 +
 +    public PagingState state()
 +    {
 +        return lastReturnedKey == null
 +             ? null
 +             : new PagingState(lastReturnedKey.getKey(), lastReturnedRow, maxRemaining(), remainingInPartition());
 +    }
 +
 +    protected ReadCommand nextPageReadCommand(int pageSize)
 +    throws RequestExecutionException
 +    {
 +        DataLimits limits;
 +        DataRange fullRange = ((PartitionRangeReadCommand)command).dataRange();
 +        DataRange pageRange;
 +        if (lastReturnedKey == null)
 +        {
 +            pageRange = fullRange;
 +            limits = command.limits().forPaging(pageSize);
 +        }
 +        else
 +        {
 +            // We want to include the last returned key only if we haven't achieved our per-partition limit, otherwise, don't bother.
-             boolean includeLastKey = remainingInPartition() > 0 && lastReturnedRow != null;
++            // note that the distinct check should only be hit when getting queries in a mixed mode cluster where a 2.1/2.2-serialized
++            // PagingState is sent to a 3.0 node - in that case we get remainingInPartition = Integer.MAX_VALUE and we include
++            // duplicate keys. For standard non-mixed operation remainingInPartition will always be 0 for DISTINCT queries.
++            boolean includeLastKey = remainingInPartition() > 0 && lastReturnedRow != null && !command.limits().isDistinct();
 +            AbstractBounds<PartitionPosition> bounds = makeKeyBounds(lastReturnedKey, includeLastKey);
 +            if (includeLastKey)
 +            {
 +                pageRange = fullRange.forPaging(bounds, command.metadata().comparator, lastReturnedRow.clustering(command.metadata()), false);
 +                limits = command.limits().forPaging(pageSize, lastReturnedKey.getKey(), remainingInPartition());
 +            }
 +            else
 +            {
 +                pageRange = fullRange.forSubRange(bounds);
 +                limits = command.limits().forPaging(pageSize);
 +            }
 +        }
 +
 +        return ((PartitionRangeReadCommand) command).withUpdatedLimitsAndDataRange(limits, pageRange);
 +    }
 +
 +    protected void recordLast(DecoratedKey key, Row last)
 +    {
 +        if (last != null)
 +        {
 +            lastReturnedKey = key;
 +            if (last.clustering() != Clustering.STATIC_CLUSTERING)
 +                lastReturnedRow = PagingState.RowMark.create(command.metadata(), last, protocolVersion);
 +        }
 +    }
 +
 +    protected boolean isPreviouslyReturnedPartition(DecoratedKey key)
 +    {
 +        // Note that lastReturnedKey can be null, but key cannot.
 +        return key.equals(lastReturnedKey);
 +    }
 +
 +    private AbstractBounds<PartitionPosition> makeKeyBounds(PartitionPosition lastReturnedKey, boolean includeLastKey)
 +    {
 +        AbstractBounds<PartitionPosition> bounds = ((PartitionRangeReadCommand)command).dataRange().keyRange();
 +        if (bounds instanceof Range || bounds instanceof Bounds)
 +        {
 +            return includeLastKey
 +                 ? new Bounds<PartitionPosition>(lastReturnedKey, bounds.right)
 +                 : new Range<PartitionPosition>(lastReturnedKey, bounds.right);
 +        }
 +        else
 +        {
 +            return includeLastKey
 +                 ? new IncludingExcludingBounds<PartitionPosition>(lastReturnedKey, bounds.right)
 +                 : new ExcludingBounds<PartitionPosition>(lastReturnedKey, bounds.right);
 +        }
 +    }
 +}
diff --cc test/distributed/org/apache/cassandra/distributed/upgrade/MixedModeReadRepairTest.java
index b98829d,fabf172..cc50053
--- a/test/distributed/org/apache/cassandra/distributed/upgrade/MixedModeReadRepairTest.java
+++ b/test/distributed/org/apache/cassandra/distributed/upgrade/MixedModeReadRepairTest.java
@@@ -24,8 -24,7 +24,6 @@@ import org.apache.cassandra.distributed
  import org.apache.cassandra.distributed.shared.DistributedTestBase;
  import org.apache.cassandra.distributed.shared.Versions;
  
- import static org.apache.cassandra.distributed.shared.Versions.find;
--
  public class MixedModeReadRepairTest extends UpgradeTestBase
  {
      @Test


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