Syed Ammar Mustafa
Syed Ammar Mustafa

Reputation: 413

Does cassandra flush memtables on nodetool stopdaemon. If not what to do to avoid data loss

I am using apache-cassandra-3.10

I understand instead of kill -9 pid, the only way to stop cassandra gracefully is nodetool stopdaemon.

But I want to know if nodetool stopdaemon also flushes the data in the memtables to sstables before shutdown.

If it does not flush then it would lead to data loss, when I stop the node using nodetool stopdaemon.

Also after researching on this , I read about the DURABLE_WRITES. What does durable write actually do ?

Also , the datastax documentation states under the section Setting DURABLE_WRITES "Do not set this attribute on a keyspace using the SimpleStrategy"

reference : https://docs.datastax.com/en/cql/3.1/cql/cql_reference/create_keyspace_r.html

What if my keyspace is configured with Simple Strategy , I still cannot benefit with DURABLE_WRITES in case it can help with data loss on shutdown ?

Is manually running nodetool flush before shutdown, the only way to make sure we do not lose data on shutdown ?

I read from https://issues.apache.org/jira/browse/CASSANDRA-3564 that the functionality to flush at shutdown has not been added.

Also there is a open ticket on the same issue https://issues.apache.org/jira/browse/CASSANDRA-12001

Intention is to avoid any data loss at shut down using nodetool stopdaemon. Basically flush all tables before shutdown , Considering Simple-strategy in use.

Upvotes: 5

Views: 5171

Answers (2)

Shoban Sundar
Shoban Sundar

Reputation: 573

Cassandra is very robust and crash-safe. Even if you kill/stop daemon you might not have data loss. But if you do safe shutdown, then you can save startup time for the Cassandra.

Follow the below steps to safe shutdown:

  1. nodetool disablegossip
  2. nodetool disablethrift
  3. nodetool disablebinary (In case of Cassandra 2.0 and above)
  4. nodetool drain

disabling gossip stops the communication to the other nodes, disabling thrift and binary stops communication with the clients.

Finally drain flushes all the tables.

Now stop Cassandra either by kill or stop daemon

Upvotes: 3

observer
observer

Reputation: 126

nodetool drain will suffice.
From Datastax Documentation about nodeool drain,

Flushes all memtables from the node to SSTables on disk. Cassandra stops listening for connections from the client and other nodes. You need to restart Cassandra after running nodetool drain.
link: nodetool drain

Then you can either kill or run nodetool stopdaemon.

Upvotes: 4

Related Questions