Skip to content

Commit

Permalink
feat: 执行历史归档新增模式-只备份不删除 TencentBlueKing#3037
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyu096 committed Jun 6, 2024
1 parent 128db0d commit c5b0bc6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public void archive() {
// min 查询返回 null,说明是空表,无需归档
archiveSummary.setSkip(true);
archiveSummary.setSuccess(true);
archiveSummary.setMessage("Empty table, do not need archive");
log.info("[{}] Empty table, do not need archive!", tableName);
return;
}
Expand All @@ -192,6 +193,7 @@ public void archive() {
tableName, minNeedArchiveId, maxNeedArchiveId);
archiveSummary.setSkip(true);
archiveSummary.setSuccess(true);
archiveSummary.setMessage("MinNeedArchiveId is greater than maxNeedArchiveId, skip archive table");
return;
}

Expand All @@ -205,6 +207,7 @@ public void archive() {
).getMessage();
log.error(msg, e);
archiveErrorTaskCounter.increment();
archiveSummary.setMessage(e.getMessage());
} finally {
archiveSummary.setArchiveMode(archiveDBProperties.getMode());
storeArchiveSummary();
Expand All @@ -228,10 +231,15 @@ private void backupAndDelete() throws IOException {
long backupReadRecordCost = 0;
long backupWriteRecordCost = 0;
long deleteCost = 0;
log.info("[{}] Start backup and delete process, backupEnabled: {}, deleteEnabled: {}", tableName,
backupEnabled, deleteEnabled);
try {
while (maxNeedArchiveId > start) {
// start < id <= stop
stop = Math.min(maxNeedArchiveId, start + readIdStepSize);

log.info("[{}] LoopArchive, current: [{}-{}]", tableName, start, stop);

BackupResult backupResult = null;
if (backupEnabled) {
backupResult = backupRecords(start, stop);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public class ArchiveSummary {
private Long lastDeletedId;
private Long deleteRecordSize;

/**
* 归档详细说明信息
*/
private String message;

public ArchiveSummary(String tableName) {
this.tableName = tableName;
}
Expand Down

0 comments on commit c5b0bc6

Please sign in to comment.