From 40a9a01e6edb078a8392c9f3baa17e10b29ea2ff Mon Sep 17 00:00:00 2001 From: Brooklyn Dewolf Date: Thu, 6 Jun 2024 13:18:44 +0200 Subject: [PATCH] engine: Fix duplicate VM backup entry error when creating incremental backup Fixes an issue that originates from https://github.com/oVirt/ovirt-engine/commit/ed023e5e0a000029b4d7e50b03fdbb3fd9a773bd The following error occured when trying to create an incremental backup: ------ ERROR [org.ovirt.engine.core.bll.storage.backup.HybridBackupCommand] (default task-1) [full_cold_vm_backup] Command 'org.ovirt.engine.core.bll.storage.backup.HybridBackupCommand' failed: CallableStatementCallback; SQL [{call insertvmbackup(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}]; ERROR: duplicate key value violates unique constraint "vm_backups_pkey" Detail: Key (backup_id)=(1733241d-4a0b-4205-9e52-5383eb7a82f2) already exists. ----- This was caused by using vmBackupDao.save() instead of vmBackupDao.update(), because the backup already existed when the setVmBackupSnapshot method is executed. Signed-off-by: Brooklyn Dewolf --- .../engine/core/bll/storage/backup/HybridBackupCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/backup/HybridBackupCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/backup/HybridBackupCommand.java index a39f972e731..5a76f1520e8 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/backup/HybridBackupCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/backup/HybridBackupCommand.java @@ -345,7 +345,7 @@ private void setVmBackupSnapshot(Guid snapshotId) { VmBackup vmBackup = getParameters().getVmBackup(); vmBackup.setSnapshotId(snapshotId); getParameters().setVmBackup(vmBackup); - vmBackupDao.save(vmBackup); + vmBackupDao.update(vmBackup); persistCommandIfNeeded(); } }