mirror of https://github.com/apache/cassandra
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 commit is contained in:
parent
f3568c0d50
commit
976096abd2
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue