From 48d53ef69fdaebd611aa20d0fb5c0cd48190bd5a Mon Sep 17 00:00:00 2001 From: Yury Luneff Date: Tue, 17 Nov 2026 21:08:45 +0300 Subject: [PATCH] vitastor-disk: Fix stable/rollback handling in index_journal_by_object The "stable" and "rollback" branches read the "version" key, but dump-journal writes the version as "ver". So both target versions were always 0: "stable" marked every write of the object stable, and "rollback" removed nothing. The rollback loop also counted down with a size_t and "i >= 0", so it never ended and read before the vector. Read "ver", and count down with an int as elsewhere in the code. The function is only used to convert older metadata with its journal in write_json_heap(), and write_json_meta() only calls write_json_heap() for "3.0" metadata, so that path isn't reachable yet. There is no test harness for vitastor-disk internals, so this comes without a test. --- src/disk_tool/disk_tool_meta.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/disk_tool/disk_tool_meta.cpp b/src/disk_tool/disk_tool_meta.cpp index acaf2c5c..84bf0491 100644 --- a/src/disk_tool/disk_tool_meta.cpp +++ b/src/disk_tool/disk_tool_meta.cpp @@ -917,10 +917,10 @@ int disk_tool_t::index_journal_by_object(json11::Json journal, } else if (rec["type"] == "stable") { - uint64_t commit_to = rec["version"].uint64_value(); + uint64_t commit_to = rec["ver"].uint64_value(); for (size_t i = 0; i < jbo.size(); i++) { - if (jbo[i]["version"].uint64_value() <= commit_to) + if (jbo[i]["ver"].uint64_value() <= commit_to) { if (jbo[i]["type"] == "big_write") { @@ -937,10 +937,10 @@ int disk_tool_t::index_journal_by_object(json11::Json journal, } else if (rec["type"] == "rollback") { - uint64_t rollback_to = rec["version"].uint64_value(); - for (size_t i = jbo.size()-1; i >= 0; i--) + uint64_t rollback_to = rec["ver"].uint64_value(); + for (int i = jbo.size()-1; i >= 0; i--) { - if (jbo[i]["version"].uint64_value() > rollback_to) + if (jbo[i]["ver"].uint64_value() > rollback_to) jbo.erase(jbo.begin()+i, jbo.begin()+i+1); } } -- 2.47.3