gentryhuang opened a new issue, #4549:
URL: https://github.com/apache/rocketmq/issues/4549
**This method of deleteExpiredFile question:**
Messages pile up, and a disk rate threshold (such as 0.85 or 0.90) is
immediately executed to delete files. This situation may result in unconsumed
messages being deleted and messages being lost.
**Key codes are as follows:**
`private void deleteExpiredFiles() {
int deleteCount = 0;
long fileReservedTime =
DefaultMessageStore.this.getMessageStoreConfig().getFileReservedTime();
int deletePhysicFilesInterval =
DefaultMessageStore.this.getMessageStoreConfig().getDeleteCommitLogFilesInterval();
int destroyMapedFileIntervalForcibly =
DefaultMessageStore.this.getMessageStoreConfig().getDestroyMapedFileIntervalForcibly();
boolean timeup = this.isTimeToDelete();
// core code
boolean spacefull = this.isSpaceToDelete();
boolean manualDelete = this.manualDeleteFileSeveralTimes > 0;
if (timeup || spacefull || manualDelete) {
if (manualDelete)
this.manualDeleteFileSeveralTimes--;
// core code
boolean cleanAtOnce =
DefaultMessageStore.this.getMessageStoreConfig().isCleanFileForciblyEnable() &&
this.cleanImmediately;
log.info("begin to delete before {} hours file. timeup: {}
spacefull: {} manualDeleteFileSeveralTimes: {} cleanAtOnce: {}",
fileReservedTime,
timeup,
spacefull,
manualDeleteFileSeveralTimes,
cleanAtOnce);
fileReservedTime *= 60 * 60 * 1000;
deleteCount =
DefaultMessageStore.this.commitLog.deleteExpiredFile(
fileReservedTime,
deletePhysicFilesInterval,
destroyMapedFileIntervalForcibly,
cleanAtOnce);
if (deleteCount > 0) {
} else if (spacefull) {
log.warn("disk space will be full soon, but delete file
failed.");
}
}
}`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]