title: Fixing Cassandra Database
body: <p>My co-worker and I have been thrown into a project that uses Cassandra with no introductions.
  Alright, let's do this!</p>
  <p><code>SELECT * FROM reports WHERE timestamp &lt; '2019-01-01 00:00:00' ALLOW FILTERING;</code></p>
  <p><code>Error: 1300</code></p>
  <p>Apparently, we have too many tombstones. What's that?
  A tombstone is deleted data that hasn't been removed yet for performance reasons.
  Tombstones should be deleted with <code>nodetool repair</code> before the <code>gc_grace_period</code> has expired, default is 10 days.
  Now, this project is around 7 years old and it doesn't seem like there's a job that runs <code>repair</code>.
  According to default warning and error values, 1K tombstones are a lot. We find about 1.4M.
  We measured the number of tombstones with <code>Tracing on</code>, running a SELECT query, and accumulating the tombstones reported.</p>
  <p>We tried to run <code>nodetool repair --full -pr -j 4</code> but we get <code>Validation failed in /10.0.3.1</code>.
  <a href="https://support.datastax.com/hc/en-us/articles/205256895--Validation-failed-when-running-a-nodetool-repair" rel="nofollow noreferrer">DataStax's guide to repairing repairs</a> wants us to fix the validation error with <code>nodetool scrub</code>.
  But we still get the same error afterwards.
  The guide then wants us to run <code>sstablescrub</code>, which failed with an out-of-memory exception.</p>
  <p>Going back to our original problem of deleting data before 2019, we tried to run <code>DELETE FROM reports WHERE timestamp &lt; '2019-01-01 00:00:00'</code>.
  However, <code>timestamp</code> is not our partition key so we are not allowed to delete data like this, which has also been confirmed by many other StackOverflow posts and an DataStax issue on Jira.
  Every post mentions that we should &quot;just&quot; change the schema of our Cassandra database to fit our queries.
  First, we only need to do this once; second, our client wants to have this data deleted as soon as possible.</p>
  <ol>
  <li><strong>Is there a way of easily changing the schema of a Cassandra database?</strong></li>
  <li><strong>Is there a way that we can make a slow solution that at least works?</strong></li>
  </ol>
  <p>All in all, we are new to Cassandra and we are unsure on how to proceed.</p>
  <p>What we want is</p>
  <ol start="3">
  <li><strong>delete all data from before 2019 and confirm that it is deleted</strong></li>
  <li><strong>have stable selects, avoiding error 1300</strong></li>
  </ol>
  <p>Can you help?</p>
  <p>We have 4 nodes running in Docker on Azure if that is necessary to know.
  The version of Cassandra is 3.11.6.</p>