Skip to content

Garbage Collection

disksing edited this page Dec 13, 2021 · 2 revisions

Garbage Collection

Older versions of data in TiKV are not deleted by default. You need to actively trigger the Garbage Collection process (also known as GC) to recycle old version data according to the needs of your application.

Triggering can be done by periodically starting the GC process using a cron job or other task schedule system (you can check the example worker), or by periodically calling the client.GC function within a service. Whenever possible, keep only one active GC task in the cluster to avoid unnecessary overhead.

The key parameter to GC is safepoint, which is a timestamp. TiKV keeps the last version before safepoint for each key when recycling data (unless the last record is delete). You can decide the retention time of historical data according to your application needs and calculate the cooresponding safepoint. The method of calculation can be referred to Timestamps.

Clone this wiki locally