From 80de533b7c7c713b7f3a86335cef55267bc905e6 Mon Sep 17 00:00:00 2001 From: walter Date: Fri, 8 Nov 2024 14:10:53 +0800 Subject: [PATCH] [improve](backup) Only compress the running backup/restore job #43177 #43278 (#43487) cherry pick from #43278 --- .../src/main/java/org/apache/doris/backup/BackupJob.java | 8 ++++++-- .../src/main/java/org/apache/doris/backup/RestoreJob.java | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJob.java b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJob.java index fdcc48927789c1..32b65b013da57c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJob.java +++ b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJob.java @@ -1066,11 +1066,15 @@ public static BackupJob read(DataInput in) throws IOException { @Override public void write(DataOutput out) throws IOException { - if (Config.backup_job_compressed_serialization) { + // For a completed job, there's no need to save it with compressed serialization as it has + // no snapshot or backup meta info, making it small in size. This helps maintain compatibility + // more easily. + boolean shouldCompress = !isDone() && Config.backup_job_compressed_serialization; + if (shouldCompress) { type = JobType.BACKUP_COMPRESSED; } super.write(out); - if (Config.backup_job_compressed_serialization) { + if (shouldCompress) { type = JobType.BACKUP; int written = 0; diff --git a/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java b/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java index 68e3331b71ec17..0bca5ef4dd4276 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java +++ b/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java @@ -2498,11 +2498,15 @@ public static RestoreJob read(DataInput in) throws IOException { @Override public void write(DataOutput out) throws IOException { - if (Config.restore_job_compressed_serialization) { + // For a completed job, there's no need to save it with compressed serialization as it has + // no snapshot or backup meta info, making it small in size. This helps maintain compatibility + // more easily. + boolean shouldCompress = !isDone() && Config.restore_job_compressed_serialization; + if (shouldCompress) { type = JobType.RESTORE_COMPRESSED; } super.write(out); - if (Config.restore_job_compressed_serialization) { + if (shouldCompress) { type = JobType.RESTORE; int written = 0;