From fbb1ba8d18ffb14772864681cd0edcfcc20dc983 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Tue, 26 Jun 2018 10:05:33 +0200 Subject: [PATCH] B #2189: Store NEXT_SNAPSHOT id in the snapshot metadata to not reuse ID's --- include/Snapshots.h | 1 - src/vm/Snapshots.cc | 11 ++++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/Snapshots.h b/include/Snapshots.h index 72284a104b..a17339bbc2 100644 --- a/include/Snapshots.h +++ b/include/Snapshots.h @@ -106,7 +106,6 @@ public: */ void clear() { - next_snapshot = 0; active = -1; disk_id = -1; diff --git a/src/vm/Snapshots.cc b/src/vm/Snapshots.cc index 515561d9d0..0fa26b05db 100644 --- a/src/vm/Snapshots.cc +++ b/src/vm/Snapshots.cc @@ -33,6 +33,8 @@ Snapshots::Snapshots(int _disk_id, bool _orphans): } snapshot_template.add("ALLOW_ORPHANS", _orphans); + + snapshot_template.add("NEXT_SNAPSHOT", 0); }; Snapshots::Snapshots(const Snapshots& s): @@ -105,11 +107,6 @@ void Snapshots::init() active = id; } - if (id >= next_snapshot) - { - next_snapshot = id + 1; - } - snapshot_pool.insert(pair(id, snap[i])); } @@ -120,6 +117,8 @@ void Snapshots::init() disk_id = did; } + snapshot_template.get("NEXT_SNAPSHOT", next_snapshot); + if ( snapshot_template.get("ALLOW_ORPHANS", orphans) == false ) { orphans = false; @@ -177,6 +176,8 @@ int Snapshots::create_snapshot(const string& name, long long size_mb) snapshot->replace("PARENT", "-1"); } + snapshot_template.replace("NEXT_SNAPSHOST", next_snapshot + 1); + snapshot_template.set(snapshot); snapshot_pool.insert(