Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens if you delete Kafka snapshot files?

The question is simple. What will happen if you delete the Kafka snapshot files in the Kafka log dir. Will Kafka be able to start? Will it have to do a slow rebuild of something?

Bonus question what exactly do the snapshot files contain?

Background for this question

I have a cluster that has been down for a couple of days due to simultaneous downtime on all brokers and a resulting corrupted broker. Now when it starts it is silent for hours (in the log file no new messages). By inspecting the JVM I have found that all the (very limited) cpu usage is spent in loadproducersfromlog function/method. By reading the comments above it is suggested that this is an attempt to recover producer state from the snapshots. I do not care about this. I just want my broker back so I am thinking if I can simply delete the snapshots to get Kafka started again.

like image 481
HansHarhoff Avatar asked Sep 15 '25 17:09

HansHarhoff


1 Answers

If snapshot files are deleted, during start up method log.loadSegmentFiles(), all messages in the partition will have to be read to recreate the snapshot even if log and index files are present. This will increase the time to load partition.

For contents of snapshot file, please refer writeSnapshot() in ProducerStateManager. https://github.com/apache/kafka/blob/980b725bb09ee42469534bf50d01118ce650880a/core/src/main/scala/kafka/log/ProducerStateManager.scala

like image 177
Prasanth Nair Avatar answered Sep 17 '25 18:09

Prasanth Nair