lib/backup: fix issue with inconsistent copying of appliedRetention.txt (#5027)

* lib/backup: fix issue with inconsistent copying of appliedRetention.txt

appliedRetention.txt can be modified in place, so it should be always copied just the same as parts.json

Updates: https://github.com/victoriaMetrics/victoriaMetrics/issues/5005
Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>

* docs: add changelog entry for appliedRetention.txt copying fix

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>

---------

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>
This commit is contained in:
Zakhar Bessarab 2023-09-21 13:25:19 +04:00 committed by Aliaksandr Valialkin
parent 9979f6796e
commit ecd523662f
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
2 changed files with 7 additions and 3 deletions

View file

@ -12,6 +12,8 @@ The following `tip` changes can be tested by building VictoriaMetrics components
## v1.93.x long-time support release (LTS)
* BUGFIX: [vmbackup](https://docs.victoriametrics.com/vmbackup.html): properly copy `appliedRetention.txt` files inside `<-storageDataPath>/{data}` folders during [incremental backups](https://docs.victoriametrics.com/vmbackup.html#incremental-backups). Previously the new `appliedRetention.txt` could be skipped during incremental backups, which could lead to increased load on storage after restoring from backup. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5005).
## [v1.93.5](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.93.5)
Released at 2023-09-19

View file

@ -40,9 +40,11 @@ type Part struct {
// key returns a string, which uniquely identifies p.
func (p *Part) key() string {
if strings.HasSuffix(p.Path, "/parts.json") {
// parts.json file contents changes over time, so it must have an unique key in order
// to always copy it during backup, restore and server-side copy.
if strings.HasSuffix(p.Path, "/parts.json") ||
strings.HasSuffix(p.Path, "/appliedRetention.txt") {
// parts.json and appliedRetention.txt files contents changes over time,
// so it must have an unique key in order to always copy it during
// backup, restore and server-side copy.
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5005
id := atomic.AddUint64(&uniqueKeyID, 1)
return fmt.Sprintf("unique-%016X", id)