You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Daniel Pyykkö <da...@sitevision.se> on 2015/04/16 15:29:16 UTC

Incorrect override of manifest.json?

Hi all,

In Cassandra 2.1.3 the code below is located in the class CassandraFamilyStore.java which is called when you do a snapshot. What I can se happens is that it first creates a snapshot manifest file correctly for a column family but than the loop returns a index which overrides the data that was written in the first iteration. Isn´t the code incorrect and the JSONArray should be located before the outer for-loop or some other solution so it does´t override content that has once been written?

From the call "concatWithIndexes()" I see it returns [CFS(Keyspace=’X', ColumnFamily='tempState'), CFS(Keyspace=’X', ColumnFamily='tempState.tempState_current_idx’)] and the first iteration writes correct data to the manifest.json and the second iteration overrides the data with a empty "filesJSONArr”.

Can somebody please confirm if this is a bug, or if I should write one?


//Kind Regards, Daniel



public void snapshotWithoutFlush(String snapshotName, Predicate<SSTableReader> predicate)
    {
        for (ColumnFamilyStore cfs : concatWithIndexes())
        {
            final JSONArray filesJSONArr = new JSONArray();
            try (RefViewFragment currentView = cfs.selectAndReference(ALL_SSTABLES))
            {
                for (SSTableReader ssTable : currentView.sstables)
                {
                    if (ssTable.openReason == SSTableReader.OpenReason.EARLY || (predicate != null && !predicate.apply(ssTable)))
                    {
                        continue;
                    }

                    File snapshotDirectory = Directories.getSnapshotDirectory(ssTable.descriptor, snapshotName);
                    ssTable.createLinks(snapshotDirectory.getPath()); // hard links
                    filesJSONArr.add(ssTable.descriptor.relativeFilenameFor(Component.DATA));
                    if (logger.isDebugEnabled())
                        logger.debug("Snapshot for {} keyspace data file {} created in {}", keyspace, ssTable.getFilename(), snapshotDirectory);
                }

                writeSnapshotManifest(filesJSONArr, snapshotName);
            }
        }
    }

Re: Incorrect override of manifest.json?

Posted by Robert Coli <rc...@eventbrite.com>.
On Thu, Apr 16, 2015 at 6:29 AM, Daniel Pyykkö <da...@sitevision.se>
wrote:

> In Cassandra 2.1.3 the code below is located in the class
> CassandraFamilyStore.java which is called when you do a snapshot. What I
> can se happens is that it first creates a snapshot manifest file correctly
> for a column family but than the loop returns a index which overrides the
> data that was written in the first iteration. Isn´t the code incorrect and
> the JSONArray should be located before the outer for-loop or some other
> solution so it does´t override content that has once been written?
>

In general if you can make a plausible case that a bug might exist,
especially if you can point it out in the code, you should inquire in one
of three forums, in (in my non-official understanding) descending order of
preference :

1) issues.apache.org
2) cassandra-dev@ mailing list
3) #cassandra-dev IRC channel
4) this list

=Rob