Quantcast

Incorrect override of manifest.json?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Incorrect override of manifest.json?

Daniel Pyykkö
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.descriptorsnapshotName);
                    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 {}"keyspacessTable.getFilename(), snapshotDirectory);
                }

                writeSnapshotManifest(filesJSONArrsnapshotName);
            }
        }
    }
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Incorrect override of manifest.json?

Robert Coli-3
On Thu, Apr 16, 2015 at 6:29 AM, Daniel Pyykkö <[hidden email]> 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 :

2) cassandra-dev@ mailing list
3) #cassandra-dev IRC channel
4) this list

=Rob

Loading...