4747import java .util .Collections ;
4848import java .util .List ;
4949import java .util .concurrent .Phaser ;
50+ import java .util .concurrent .TimeUnit ;
51+ import java .util .concurrent .atomic .AtomicLong ;
5052import java .util .concurrent .locks .ReadWriteLock ;
5153import java .util .concurrent .locks .ReentrantReadWriteLock ;
5254import java .util .stream .Collectors ;
@@ -65,6 +67,9 @@ public class CompactionScheduler {
6567 private static final Logger LOGGER =
6668 LoggerFactory .getLogger (IoTDBConstant .COMPACTION_LOGGER_NAME );
6769 private static final IoTDBConfig config = IoTDBDescriptor .getInstance ().getConfig ();
70+ private static final long DISK_SPACE_CHECK_FAIL_LOG_INTERVAL_MS = TimeUnit .MINUTES .toMillis (1 );
71+ private static final AtomicLong LAST_DISK_SPACE_CHECK_FAIL_LOG_TIME = new AtomicLong (0 );
72+ private static final AtomicLong SUPPRESSED_DISK_SPACE_CHECK_FAIL_LOG_COUNT = new AtomicLong (0 );
6873
6974 private CompactionScheduler () {}
7075
@@ -207,13 +212,32 @@ private static boolean canAddTaskToWaitingQueue(AbstractCompactionTask task)
207212 }
208213 // check disk space
209214 if (!task .isDiskSpaceCheckPassed ()) {
210- LOGGER .info (
211- "Compaction task start check failed because disk free ratio is less than disk_space_warning_threshold" );
215+ logDiskSpaceCheckFailure (task );
212216 return false ;
213217 }
214218 return true ;
215219 }
216220
221+ private static void logDiskSpaceCheckFailure (AbstractCompactionTask task ) {
222+ long now = System .currentTimeMillis ();
223+ long lastLogTime = LAST_DISK_SPACE_CHECK_FAIL_LOG_TIME .get ();
224+ if (now - lastLogTime >= DISK_SPACE_CHECK_FAIL_LOG_INTERVAL_MS
225+ && LAST_DISK_SPACE_CHECK_FAIL_LOG_TIME .compareAndSet (lastLogTime , now )) {
226+ long suppressedCount = SUPPRESSED_DISK_SPACE_CHECK_FAIL_LOG_COUNT .getAndSet (0 );
227+ LOGGER .info (
228+ "Skip compaction task because disk free ratio is less than disk_space_warning_threshold, "
229+ + "taskType={}, storageGroup={}, dataRegion={}, timePartition={}, processedFileNum={}, suppressedSimilarLogs={}" ,
230+ task .getCompactionTaskType (),
231+ task .getStorageGroupName (),
232+ task .getDataRegionId (),
233+ task .getTimePartition (),
234+ task .getProcessedFileNum (),
235+ suppressedCount );
236+ } else {
237+ SUPPRESSED_DISK_SPACE_CHECK_FAIL_LOG_COUNT .incrementAndGet ();
238+ }
239+ }
240+
217241 public static int scheduleInsertionCompaction (
218242 TsFileManager tsFileManager , long timePartition , CompactionScheduleContext context )
219243 throws InterruptedException {
0 commit comments