Skip to content

Commit

Permalink
fix(backups): add random suffixes to task files to avoid collitions
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-f committed Dec 8, 2021
1 parent cb2a34c commit 2c689af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion @xen-orchestra/backups/writers/_MixinBackupWriter.js
Expand Up @@ -43,7 +43,13 @@ exports.MixinBackupWriter = (BaseClass = Object) =>
// merge worker only compatible with local remotes
const { handler } = this._adapter
if (merge && !disableMergeWorker && typeof handler._getRealPath === 'function') {
await handler.outputFile(join(MergeWorker.CLEAN_VM_QUEUE, formatFilenameDate(new Date())), this._backup.vm.uuid)
const taskFile =
join(MergeWorker.CLEAN_VM_QUEUE, formatFilenameDate(new Date())) +
'-' +
// add a random suffix to avoid collision in case multiple tasks are created at the same second
Math.random().toString(36).slice(2)

await handler.outputFile(taskFile, this._backup.vm.uuid)
const remotePath = handler._getRealPath()
await MergeWorker.run(remotePath)
}
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Expand Up @@ -15,6 +15,7 @@
- [Tables/actions] Fix collapsed actions being clickable despite being disabled (PR [#6023](https://github.com/vatesfr/xen-orchestra/pull/6023))
- [Backup] Fix `handler.rmTree` is not a function (Forum [5256](https://xcp-ng.org/forum/topic/5256/s3-backup-try-it/29) PR [#6041](https://github.com/vatesfr/xen-orchestra/pull/6041) )
- [Backup] Fix `EEXIST` in logs when multiple merge tasks are created at the same time ([Forum #5301](https://xcp-ng.org/forum/topic/5301/warnings-errors-in-journalctl))

### Packages to release

Expand Down

0 comments on commit 2c689af

Please sign in to comment.