DB.RunValueLogGC function picks up a value log file to perform gc. If it results in no rewrites, then an
ErrNoRewrite is thrown. Is it possible that
RunValueLogGC picks same vlog file in next run? Or it keeps a track of already picked vlog files?
@rohanil Badger keeps a map of file id to amount of data that can be GCed from them. When this function runs, it picks the file with most amount of GC data. This map is populated at the time of compaction.
But in some cases, there is a chance that compaction has not been run and there is no entry in map. In that case, badger picks a file randomly whose id is less than value log head. It takes a sample window of data from that file and calculates discard ratio from it. Then it takes decision of running GC or not by comparing it with passed discard ratio value. Here it might be possible to pick window of less discard ratio(based on the entries in file).
It does not keep track of already picked files.