How to delete the setting of retention.ms from topic

by default all topics in our kafka cluster are with retention hours=24 , ( as defined in kafka server.properties )

we decided to decrease the retention hours only on topic test to 64000 ms

so we set the following retention hours - 64000 on topic test

kafka-configs.sh --zookeeper zoo_server:2181 --entity-type topics --alter --entity-name test -add-config retention.ms=64000

now we want to return the default retention hours on topic test ( to 24 hours ) ,as was before

we don’t sure if the following kafka cli , really return the retention hours to 24 on topic test

kafka-configs.sh --zookeeper zoo_server:2181 --alter --entity-type topics --entity-name test --delete-config retention.ms

as I know the above delete the configuration of the retention in ms but I not sure if this is really what above command is doing

please advice if I am wrong?

NOTE: in order to get all data about retention for particular topic in kafka , we can do

kafka-topics.sh --zookeeper zoo_server:2181 --describe --topics-with-overrides

reference- How to see the retention for a particular topic in kafka - Stack Overflow

reference - apache kafka - Delete topic level config - Stack Overflow

additionally:

I can suggest other approach as:

kafka-configs.sh --zookeeper zoo_server:2181 --entity-type topics --alter --entity-name test -add-config retention.ms=86400000

its configure the 24 hours for test topic , but this is workaround
but I preferred is to delete the configuration of retention in ms instead of set the retention in ms to 86400000

Hello! First off, welcome to the Forum and congrats on your first post. :slight_smile:

You are entirely correct. As per the documentation, you can rest assured that

> bin/kafka-configs.sh --bootstrap-server localhost:9092  --entity-type topics --entity-name my-topic
  --alter --delete-config retention.ms

is, in fact, removing the override that you had set and returning that config to cluster defaults. Hope that gives you peace of mind!

2 Likes

thank you so much
you answered on my Question

I guess , after we returned the default config , then no need to restart the Kafka broker
am I right?

No, I don’t believe so! I don’t recall ever having to do that for a topic config change.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.