[TinyKV] Why does Log Compaction need to reach consensus through the Raft layer before it can be executed?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 【tinykv】为什么 Log Compaction 需要经过 Raft 层达成共识以后才能执行?

| username: sa_ka_na

In the implementation of tinykv, if at some point it is found that applied index - storage first index > gcLimit, a Log Compact Request will be proposed to the Raft layer. After it is committed, the gc worker is notified to perform log compaction.
Why is it necessary to reach consensus before performing log compaction, rather than having each peer do it individually?