cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Milan Majercik (JIRA)" <>
Subject [jira] [Commented] (CASSANDRA-12796) Heap exhaustion when rebuilding secondary index over a table with wide partitions
Date Tue, 06 Dec 2016 12:37:59 GMT


Milan Majercik commented on CASSANDRA-12796:

[~beobal], the patch for branch {{3.0}} works fine, however the page size for single partition
pager appears to be calculated incorrectly. My table's average partition size is around {{7GB}}
and yet the page size got calculated as {{1}}.

    private int calculateIndexingPageSize()
        double averageRowSize = baseCfs.getMeanPartitionSize();
        if (averageRowSize <= 0)
            return DEFAULT_PAGE_SIZE;

        return (int) Math.max(1, Math.min(DEFAULT_PAGE_SIZE, 4 * 1024 * 1024 / averageRowSize));

This rendered index rebuild extremely slow as registering read/write order group implies significant
performance overhead and for this reason the page size should have reasonable size.

I think there is no harm if we set page size to {{DEFAULT_PAGE_SIZE}} as the pager doesn't
span across different partitions in case the partition is small ([])


> Heap exhaustion when rebuilding secondary index over a table with wide partitions
> ---------------------------------------------------------------------------------
>                 Key: CASSANDRA-12796
>                 URL:
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Core
>            Reporter: Milan Majercik
>            Priority: Critical
> We have a table with rather wide partition and a secondary index defined over it. As
soon as we try to rebuild the index we observed exhaustion of Java heap and eventual OOM error.
After a lengthy investigation we have managed to find a culprit which appears to be a wrong
granule of barrier issuances in method {{org.apache.cassandra.db.Keyspace.indexRow}}:
> {code}
>         try (OpOrder.Group opGroup = cfs.keyspace.writeOrder.start()){html}
>         {
>             Set<SecondaryIndex> indexes = cfs.indexManager.getIndexesByNames(idxNames);
>             Iterator<ColumnFamily> pager = QueryPagers.pageRowLocally(cfs, key.getKey(),
>             while (pager.hasNext())
>             {
>                 ColumnFamily cf =;
>                 ColumnFamily cf2 = cf.cloneMeShallow();
>                 for (Cell cell : cf)
>                 {
>                     if (cfs.indexManager.indexes(, indexes))
>                         cf2.addColumn(cell);
>                 }
>                 cfs.indexManager.indexRow(key.getKey(), cf2, opGroup);
>             }
>         }
> {code}
> Please note the operation group granule is a partition of the source table which poses
a problem for wide partition tables as flush runnable ({{}})
won't proceed with flushing secondary index memtable before completing operations prior recent
issue of the barrier. In our situation the flush runnable waits until whole wide partition
gets indexed into the secondary index memtable before flushing it. This causes an exhaustion
of the heap and eventual OOM error.
> After we changed granule of barrier issue in method {{org.apache.cassandra.db.Keyspace.indexRow}}
to query page as opposed to table partition secondary index (see []),
rebuild started to work without heap exhaustion. 

This message was sent by Atlassian JIRA

View raw message