Beyond the explicitly stated objectives for RESTBase has been a mandate to store (more or less) complete history of transformations in order to enable future alternative use-cases. Since storage is always bounded, this has created a number of challenges that have been met with efforts such as:
* Cluster expansions (one executed, one planned)
* Multi-instance
* Compression
* Culling
* Revision retention policies
The latter of these, //revision retention policies//, work by performing an asynchronous query of past records on each new write, and applying the policy to results. Records that are excluded by policy are overwritten with a TTL (to be GC'd when the TTL expires).
The GC of records with a TTL in Cassandra is something that happens as the result of compaction. One issue with this process is the so-called //overlapping tables problem//. Compactions typically only involve a subset of all on-disk files, and TTL-containing records (or tombstones) can only be GC'd when the tables under consideration represent the whole picture; You cannot drop otherwise expired data if there is a possibility that older (preceding) values exist in other files (tables //not// under consideration of the current compaction).
The RESTBase key-rev-value data model, combined with revision retention policies, create a kind of pathalogical worst-case for the problem of overlapping tables, and the GC of tombstoned data.
First, the history of each document is represented by a single partition, which means that the more history we have (and/or the greater the frequency of change), the more likely it is that it will appear across more files on disk (eventually all of them). Second, the use of revision retention policies ensure that tombstoned data is distributed throughout the document history.
Consider the following: `local_group_wikipedia_T_parsoid_html.data` on restbase1015-a.eqiad.wmnet had a droppable tombstone ratio of 90%(!!). After completion of a major compaction (where the expectation is that all files are compacted into one), the droppable tombstone ratio was still 81%. Upon further investigation, it was discovered that exactly one file contained a `repairedAt` timestamp, the result of experiments with incremental repair dating back to March of 2015. This meant that the previous compaction had actually resulted in two files, one for all repaired tables (of which there was already only one), and one for unrepaired tables (everything else). After removing the `repairedAt` field from the file and re-running the major compaction, the droppable tombstone ratio was less than 3%. //The exclusion of a single file from compaction was enough to cause the difference between an 81% ratio, to 3%.// Completion of this second major compaction created a corresponding decrease in storage from 507G to 225G, //a reduction of more than half//.
In addition to nominally doubling required storage, this "dead" data must be considered when merging for a read, so it impacts latency as well.
I believe that, for all intents and purposes, RESTBase's use of Cassandra could be considered an anti-pattern, and I see 3 (broad) possible courses of action:
# Rethink RESTBase's data model and access
# Invest effort into solutions to make Cassandra better accomodate RESTBase's data model/access
# Identify alternatives to Cassandra