vitastor-disk: Fix stable/rollback handling in index_journal_by_object #127
Reference in New Issue
Block a user
No description provided.
Delete Branch "koolkhel/vitastor:disk-meta-journal-keys"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
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.
Tested: a scratch harness linking
disk_tool_meta.cppunder ASan, with a journal of small writes, a stable entry and rollbacks. On master "stable" for v1 also marks v2 stable and "rollback" overflows the heap; with the fix only v1 becomes stable and the rollbacks remove the newer versions.Contributor Name
Yury Luneff (MIND Software LLC, https://mindsw.io)
CLA