vitastor-disk: Fix stable/rollback handling in index_journal_by_object #127

Merged
vitalif merged 1 commits from koolkhel/vitastor:disk-meta-journal-keys into master 2026-11-17 23:36:22 +03:00
Contributor

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.cpp under 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

### 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.cpp` under 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 - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-11-17 21:13:34 +03:00
vitastor-disk: Fix stable/rollback handling in index_journal_by_object
Some checks failed
Test / test_enospc_imm_xor (push) Has been cancelled
Test / test_old_enospc (push) Has been cancelled
Test / test_old_enospc_xor (push) Has been cancelled
Test / test_old_enospc_imm (push) Has been cancelled
Test / test_old_enospc_imm_xor (push) Has been cancelled
Test / test_scrub (push) Has been cancelled
Test / test_scrub_zero_osd_2 (push) Has been cancelled
Test / test_scrub_xor (push) Has been cancelled
Test / test_scrub_pg_size_3 (push) Has been cancelled
Test / test_scrub_pg_size_6_pg_minsize_4_osd_count_6_ec (push) Has been cancelled
Test / test_scrub_ec (push) Has been cancelled
Test / test_scrub_deleted_incomplete (push) Has been cancelled
Test / test_old_scrub (push) Has been cancelled
Test / test_old_scrub_zero_osd_2 (push) Has been cancelled
Test / test_old_scrub_xor (push) Has been cancelled
Test / test_old_scrub_pg_size_3 (push) Has been cancelled
Test / test_old_scrub_pg_size_6_pg_minsize_4_osd_count_6_ec (push) Has been cancelled
Test / test_old_scrub_ec (push) Has been cancelled
Test / test_old_partwr_csum (push) Has been cancelled
Test / test_heal_old_csum_32k_dmj (push) Has been cancelled
Test / test_heal_old_csum_32k_dj (push) Has been cancelled
Test / test_heal_old_csum_32k (push) Has been cancelled
Test / test_heal_old_csum_4k_dmj (push) Has been cancelled
Test / test_heal_old_csum_4k_dj (push) Has been cancelled
Test / test_heal_old_csum_4k (push) Has been cancelled
Test / test_nfs (push) Has been cancelled
Test / test_nfs_unaligned_append (push) Has been cancelled
Test / test_nfs_long_readdir (push) Has been cancelled
Test / test_write_encrypted (push) Has been cancelled
Test / test_write_encrypted_ec (push) Has been cancelled
48d53ef69f
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.
vitalif merged commit 48d53ef69f into master 2026-11-17 23:36:22 +03:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#127
No description provided.