[BugFix] Fix too many disk io when check consistency (backport #61745) (#62348)

Co-authored-by: kisshot288 <59246842+kisshot288@users.noreply.github.com>
This commit is contained in:
mergify[bot] 2025-08-26 15:09:14 +00:00 committed by GitHub
parent e4e493480b
commit b3fa782058
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -1307,6 +1307,11 @@ public class Config extends ConfigBase {
public static long check_consistency_default_timeout_second = 600; // 10 min
@ConfField(mutable = true)
public static long consistency_tablet_meta_check_interval_ms = 2 * 3600 * 1000L; // every 2 hours
/**
* tablet can be checked only one time on one day, to avoid too many disk io in be
*/
@ConfField(mutable = true)
public static long consistency_check_cooldown_time_second = 24 * 3600L; // every 1 day
// Configurations for query engine
/**

View File

@ -525,7 +525,12 @@ public class ConsistencyChecker extends FrontendDaemon {
// sort tablets
Queue<MetaObject> tabletQueue =
new PriorityQueue<>(Math.max(index.getTablets().size(), 1), COMPARATOR);
tabletQueue.addAll(index.getTablets());
long startCheckTime = System.currentTimeMillis();
long cooldownedTimeMs = startCheckTime - Config.consistency_check_cooldown_time_second * 1000;
List<Tablet> cooldownedTablets = index.getTablets().stream()
.filter(t -> t.getLastCheckTime() < cooldownedTimeMs)
.toList();
tabletQueue.addAll(cooldownedTablets);
while ((chosenOne = tabletQueue.poll()) != null) {
LocalTablet tablet = (LocalTablet) chosenOne;