Cassandra - avoid nodetool cleanup
Asked Answered
M

2

6

If we have added new nodes to a C* ring, do we need to run "nodetool cleanup" to get rid of the data that has now been assigned elsewhere? Or is this going to happen anyway during normal compactions? During normal compactions, does C* remove data that does no longer belong on this node, or do we need to run "nodetoool cleanup" for that? Asking because "cleanup" takes forever and crashes the node before finishing.

If we need to run "nodetool cleanup", is there a way to find out which nodes now have data they should no longer own? (i.e data that now belongs on the new nodes, but is still present on the old nodes because no one removed it. This is the data that "nodetool cleanup" would remove.) We have RF=3 and two data centers, each of which has a complete copy of the data. I assume we need to run cleanup on all nodes in the data center where we have added nodes, because each row on the new node used to be on another node (primary), plus two copies (replicas) on two other nodes.

Manaker answered 3/7, 2014 at 17:27 Comment(1)
nodetool cleanup just caused a 25+ million row loss on my setup. As per the documentation, I waited until new nodes were up and running (UN) but the documentation does not mention the schemas need to be sync'ed. Turns out nodetool describecluster showed a problem where the schemas were out of sync, but the nodes were up normal UN. So without knowing this I ran nodetool cleanup. 30 minutes later it had finished destroying the work of 20+ days.Coated
C
5

If you are on Apache Cassandra 1.2 or newer, cleanup checks the meta data on files so that it only does something if it needs to. So you are safe to just run it on every node, and only those nodes with extra data will do something. The data will not be removed during the normal compaction process, you have to call cleanup to remove it.

Colorless answered 4/7, 2014 at 2:34 Comment(0)
C
0

What I found helpful is to just compare how much space each node occupies in the data folder (for me it was /var/lib/cassandra/data). Some things like snapshots might differ between the nodes but when you see that newer nodes use much less disk space than older ones it might be because they did not have a cleanup after the newer ones where added. While you are there, you can also check what is the biggest .db file in there and check if your storage is has enough free space to store another file of that size The cleanup seems to copy the data of the .db files into new ones, minus the data that is now on other nodes. So you might need that extra space while it runs.

Charlotte answered 5/12, 2022 at 18:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.