You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ad...@apache.org on 2020/07/10 17:30:35 UTC
[cassandra] branch cassandra-2.1 updated: Fix writing of snapshot manifest when the table has table-backed secondary indexes patch by Aleksandr Sorokoumov; reviewed by Andrés de la Peña for CASSANDRA-10968
This is an automated email from the ASF dual-hosted git repository.
adelapena pushed a commit to branch cassandra-2.1
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/cassandra-2.1 by this push:
new 976096a Fix writing of snapshot manifest when the table has table-backed secondary indexes patch by Aleksandr Sorokoumov; reviewed by Andrés de la Peña for CASSANDRA-10968
976096a is described below
commit 976096abd2ba786f747774ee5160c4cba6fefce2
Author: Aleksandr Sorokoumov <al...@gmail.com>
AuthorDate: Fri Jul 10 16:57:40 2020 +0100
Fix writing of snapshot manifest when the table has table-backed secondary indexes
patch by Aleksandr Sorokoumov; reviewed by Andrés de la Peña for CASSANDRA-10968
---
CHANGES.txt | 1 +
.../org/apache/cassandra/db/ColumnFamilyStore.java | 5 ++--
.../apache/cassandra/db/ColumnFamilyStoreTest.java | 34 ++++++++++++++++++++++
3 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index d0d0993..0a6268c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
2.1.21
+ * Fix writing of snapshot manifest when the table has table-backed secondary indexes (CASSANDRA-10968)
* Fix parse error in cqlsh COPY FROM and formatting for map of blobs (CASSANDRA-15679)
* Paged Range Slice queries with DISTINCT can drop rows from results (CASSANDRA-14956)
* Update release checksum algorithms to SHA-256, SHA-512 (CASSANDRA-14970)
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 2989b9d..df9b046 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -2335,9 +2335,9 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
*/
public void snapshotWithoutFlush(String snapshotName, Predicate<SSTableReader> predicate, boolean ephemeral)
{
+ final JSONArray filesJSONArr = new JSONArray();
for (ColumnFamilyStore cfs : concatWithIndexes())
{
- final JSONArray filesJSONArr = new JSONArray();
try (RefViewFragment currentView = cfs.selectAndReference(CANONICAL_SSTABLES))
{
for (SSTableReader ssTable : currentView.sstables)
@@ -2352,10 +2352,9 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
if (logger.isDebugEnabled())
logger.debug("Snapshot for {} keyspace data file {} created in {}", keyspace, ssTable.getFilename(), snapshotDirectory);
}
-
- writeSnapshotManifest(filesJSONArr, snapshotName);
}
}
+ writeSnapshotManifest(filesJSONArr, snapshotName);
if (ephemeral)
createEphemeralSnapshotMarkerFile(snapshotName);
}
diff --git a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
index 35814f0..1fc2029 100644
--- a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
+++ b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
@@ -19,6 +19,7 @@
package org.apache.cassandra.db;
import java.io.File;
+import java.io.FileReader;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.CharacterCodingException;
@@ -57,6 +58,9 @@ import org.apache.cassandra.thrift.SlicePredicate;
import org.apache.cassandra.thrift.SliceRange;
import org.apache.cassandra.thrift.ThriftValidation;
import org.apache.cassandra.utils.*;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
import static org.apache.cassandra.Util.cellname;
import static org.apache.cassandra.Util.column;
@@ -2233,4 +2237,34 @@ public class ColumnFamilyStoreTest extends SchemaLoader
PerRowSecondaryIndexTest.TestIndex.reset();
}
+
+ @Test
+ public void testSnapshotWithoutFlushWithSecondaryIndexes() throws Exception
+ {
+ String keyspaceName = "Keyspace1";
+ String cfName = "Indexed1";
+ Keyspace keyspace = Keyspace.open(keyspaceName);
+ ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfName);
+ cfs.truncateBlocking();
+
+ List<Mutation> rms = new LinkedList<>();
+ Mutation rm;
+
+ rm = new Mutation(keyspaceName, ByteBufferUtil.bytes("k1"));
+ rm.add(cfName, cellname("birthdate"), ByteBufferUtil.bytes(1L), 0);
+ rm.add(cfName, cellname("nobirthdate"), ByteBufferUtil.bytes(1L), 0);
+ rms.add(rm);
+ Util.writeColumnFamily(rms);
+
+ String snapshotName = "newSnapshot";
+ cfs.snapshotWithoutFlush(snapshotName);
+
+ File snapshotManifestFile = cfs.directories.getSnapshotManifestFile(snapshotName);
+ JSONParser parser = new JSONParser();
+ JSONObject manifest = (JSONObject) parser.parse(new FileReader(snapshotManifestFile));
+ JSONArray files = (JSONArray) manifest.get("files");
+
+ // Keyspace1-Indexed1 and the corresponding index CFS
+ assert files.size() == 2;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org