Johnny Miller created CASSANDRA-21814:
-----------------------------------------
Summary: UCS normalises flush and level 0 densities to the wrong
token space with multiple data directories
Key: CASSANDRA-21814
URL: https://issues.apache.org/jira/browse/CASSANDRA-21814
Project: Apache Cassandra
Issue Type: Bug
Reporter: Johnny Miller
With more than one data directory, UCS normalises two densities to the whole
local token space when they should be normalised to one directory's share of it.
Both lines date from the original UCS commit (CASSANDRA-18397), so 5.0, 6.0 and
trunk are affected. With a single data directory {{shardSetCoverage()}} equals
{{localSpaceCoverage()}} and neither line has any effect.
*1. Flush shard count* in
{{{}UnifiedCompactionStrategy.createSSTableMultiWriter{}}}:
{code:java}
double flushDensity = cfs.metric.flushSizeOnDisk.get() *
shardManager.shardSetCoverage() / shardManager.localSpaceCoverage();
{code}
{{flushSizeOnDisk}} is updated once per flush writer in
{{{}ColumnFamilyStore{}}}, and a flush has one writer per data directory. The
value is therefore already the size of data covering one directory's token
space, which is what {{Controller.getNumShards}} expects. Multiplying by
{{shardSetCoverage() / localSpaceCoverage()}} divides it again by the number of
directories, so flushes are split into fewer shards than the configuration asks
for.
*2. Level 0 bound* in {{{}UnifiedCompactionStrategy.formLevels{}}}:
{code:java}
double maxDensity = controller.getMaxLevelDensity(0,
controller.getBaseSstableSize(controller.getFanout(0)) /
shardManager.localSpaceCoverage());
{code}
The base sstable size comes from the flush size, which covers one directory's
share of the token ring, so it should be divided by {{{}shardSetCoverage(){}}}.
With N directories the level 0 bound is N times too low, and flushed sstables
can be counted above level 0.
[~blambov] fixed the same two calculations in the DataStax fork inĀ
[51acbd61|https://github.com/datastax/cassandra/commit/51acbd61feb8b04105e68a48fff37878e317df79],
together with tests in {{UnifiedCompactionStrategyTest}} and clarifications in
{{UnifiedCompactionStrategy.md}} and the {{Controller.getNumShards}} javadoc.
Found while working on CASSANDRA-21615 and kept separate from it.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]