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

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

commit 9d28bebde8028c506bb521a7beec7db60f0b9918
Merge: 939ab71 0e12b8d
Author: Brandon Williams <brandonwilli...@apache.org>
AuthorDate: Mon Oct 11 12:00:46 2021 -0500

    Merge branch 'cassandra-3.0' into cassandra-3.11

 CHANGES.txt                                             |  1 +
 src/java/org/apache/cassandra/db/ColumnFamilyStore.java | 17 ++++++++++++++---
 src/java/org/apache/cassandra/db/SystemKeyspace.java    |  6 +++---
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --cc CHANGES.txt
index a40b226,ae88aaa..d43066e
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,15 -1,5 +1,16 @@@
 -3.0.26:
 +3.11.12
 + * Add key validation to ssstablescrub (CASSANDRA-16969)
 + * Update Jackson from 2.9.10 to 2.12.5 (CASSANDRA-16851)
 + * Include SASI components to snapshots (CASSANDRA-15134)
 + * Make assassinate more resilient to missing tokens (CASSANDRA-16847)
 + * Exclude Jackson 1.x transitive dependency of hadoop* provided dependencies 
(CASSANDRA-16854)
 + * Validate SASI tokenizer options before adding index to schema 
(CASSANDRA-15135)
 + * Fixup scrub output when no data post-scrub and clear up old use of row, 
which really means partition (CASSANDRA-16835)
 + * Fix ant-junit dependency issue (CASSANDRA-16827)
 + * Reduce thread contention in CommitLogSegment and HintsBuffer 
(CASSANDRA-16072)
 + * Avoid sending CDC column if not enabled (CASSANDRA-16770)
 +Merged from 3.0:
+  * Don't take snapshots when truncating system tables (CASSANDRA-16839)
   * Make -Dtest.methods consistently optional in all Ant test targets 
(CASSANDRA-17014)
   * Immediately apply stream throughput, considering negative values as 
unthrottled (CASSANDRA-16959)
   * Do not release new SSTables in offline transactions (CASSANDRA-16975)
diff --cc src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 30cb400,e7c1868..4a74a2f
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@@ -2238,9 -2068,9 +2249,9 @@@ public class ColumnFamilyStore implemen
          viewManager.stopBuild();
  
          final long truncatedAt;
 -        final ReplayPosition replayAfter;
 +        final CommitLogPosition replayAfter;
  
-         if (keyspace.getMetadata().params.durableWrites || 
DatabaseDescriptor.isAutoSnapshot())
+         if (!noSnapshot && (keyspace.getMetadata().params.durableWrites || 
DatabaseDescriptor.isAutoSnapshot()))
          {
              replayAfter = forceBlockingFlush();
              viewManager.forceBlockingFlush();
@@@ -2270,8 -2100,8 +2281,8 @@@
              logger.debug("Discarding sstable data for truncated CF + 
indexes");
              data.notifyTruncated(truncatedAt);
  
-             if (DatabaseDescriptor.isAutoSnapshot())
+             if (!noSnapshot && DatabaseDescriptor.isAutoSnapshot())
 -                snapshot(Keyspace.getTimestampedSnapshotName(name));
 +                snapshot(Keyspace.getTimestampedSnapshotNameWithPrefix(name, 
SNAPSHOT_TRUNCATE_PREFIX));
  
              discardSSTables(truncatedAt);
  
diff --cc src/java/org/apache/cassandra/db/SystemKeyspace.java
index 4ab81ae,dc550df..ec26a69
--- a/src/java/org/apache/cassandra/db/SystemKeyspace.java
+++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java
@@@ -1387,43 -1346,10 +1387,43 @@@ public final class SystemKeyspac
  
      public static void resetAvailableRanges()
      {
 -        ColumnFamilyStore availableRanges = 
Keyspace.open(NAME).getColumnFamilyStore(AVAILABLE_RANGES);
 +        ColumnFamilyStore availableRanges = 
Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME).getColumnFamilyStore(AVAILABLE_RANGES);
-         availableRanges.truncateBlocking();
+         availableRanges.truncateBlockingWithoutSnapshot();
      }
  
 +    public static synchronized void updateTransferredRanges(String 
description,
 +                                                         InetAddress peer,
 +                                                         String keyspace,
 +                                                         
Collection<Range<Token>> streamedRanges)
 +    {
 +        String cql = "UPDATE system.%s SET ranges = ranges + ? WHERE 
operation = ? AND peer = ? AND keyspace_name = ?";
 +        Set<ByteBuffer> rangesToUpdate = new HashSet<>(streamedRanges.size());
 +        for (Range<Token> range : streamedRanges)
 +        {
 +            rangesToUpdate.add(rangeToBytes(range));
 +        }
 +        executeInternal(String.format(cql, TRANSFERRED_RANGES), 
rangesToUpdate, description, peer, keyspace);
 +    }
 +
 +    public static synchronized Map<InetAddress, Set<Range<Token>>> 
getTransferredRanges(String description, String keyspace, IPartitioner 
partitioner)
 +    {
 +        Map<InetAddress, Set<Range<Token>>> result = new HashMap<>();
 +        String query = "SELECT * FROM system.%s WHERE operation = ? AND 
keyspace_name = ?";
 +        UntypedResultSet rs = executeInternal(String.format(query, 
TRANSFERRED_RANGES), description, keyspace);
 +        for (UntypedResultSet.Row row : rs)
 +        {
 +            InetAddress peer = row.getInetAddress("peer");
 +            Set<ByteBuffer> rawRanges = row.getSet("ranges", 
BytesType.instance);
 +            Set<Range<Token>> ranges = 
Sets.newHashSetWithExpectedSize(rawRanges.size());
 +            for (ByteBuffer rawRange : rawRanges)
 +            {
 +                ranges.add(byteBufferToRange(rawRange, partitioner));
 +            }
 +            result.put(peer, ranges);
 +        }
 +        return ImmutableMap.copyOf(result);
 +    }
 +
      /**
       * Compare the release version in the system.local table with the one 
included in the distro.
       * If they don't match, snapshot all tables in the system keyspace. This 
is intended to be
@@@ -1558,37 -1482,4 +1558,37 @@@
          }
      }
  
 +    public static void writePreparedStatement(String loggedKeyspace, 
MD5Digest key, String cql)
 +    {
 +        executeInternal(String.format("INSERT INTO %s.%s"
 +                                      + " (logged_keyspace, prepared_id, 
query_string) VALUES (?, ?, ?)",
 +                                      SchemaConstants.SYSTEM_KEYSPACE_NAME, 
PREPARED_STATEMENTS),
 +                        loggedKeyspace, key.byteBuffer(), cql);
 +        logger.debug("stored prepared statement for logged keyspace '{}': 
'{}'", loggedKeyspace, cql);
 +    }
 +
 +    public static void removePreparedStatement(MD5Digest key)
 +    {
 +        executeInternal(String.format("DELETE FROM %s.%s"
 +                                      + " WHERE prepared_id = ?",
 +                                      SchemaConstants.SYSTEM_KEYSPACE_NAME, 
PREPARED_STATEMENTS),
 +                        key.byteBuffer());
 +    }
 +
 +    public static void resetPreparedStatements()
 +    {
-         ColumnFamilyStore availableRanges = 
Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME).getColumnFamilyStore(PREPARED_STATEMENTS);
-         availableRanges.truncateBlocking();
++        ColumnFamilyStore preparedStatements = 
Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME).getColumnFamilyStore(PREPARED_STATEMENTS);
++        preparedStatements.truncateBlockingWithoutSnapshot();
 +    }
 +
 +    public static List<Pair<String, String>> loadPreparedStatements()
 +    {
 +        String query = String.format("SELECT logged_keyspace, query_string 
FROM %s.%s", SchemaConstants.SYSTEM_KEYSPACE_NAME, PREPARED_STATEMENTS);
 +        UntypedResultSet resultSet = executeOnceInternal(query);
 +        List<Pair<String, String>> r = new ArrayList<>();
 +        for (UntypedResultSet.Row row : resultSet)
 +            r.add(Pair.create(row.has("logged_keyspace") ? 
row.getString("logged_keyspace") : null,
 +                              row.getString("query_string")));
 +        return r;
 +    }
  }

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

Reply via email to