From b58bf3ada536e65d1b1fabae067129317d40086b Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sat, 21 Sep 2024 13:44:36 +0300 Subject: [PATCH] Fix possible OSD crash during parallel read & write to an image with snapshots OSDs could crash with the following "assertion failed" message (crash didn't affect data and was caused by OSD thinking upper blocks are full while they weren't). Reproduction without introducing artificial delays is hard because you have to force OSD to read an object with enqueued but not handled write which fills previously non-full bitmap. O_o. ``` vitastor-osd: ./src/osd/osd_primary_chain.cpp:613: void osd_t::send_chained_read_results(pg_t&, osd_op_t*): Assertion `stripes[role].read_buf' failed. ``` --- src/blockstore/blockstore_read.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/blockstore/blockstore_read.cpp b/src/blockstore/blockstore_read.cpp index bc2ecffd..ce9ec787 100644 --- a/src/blockstore/blockstore_read.cpp +++ b/src/blockstore/blockstore_read.cpp @@ -993,7 +993,8 @@ int blockstore_impl_t::read_bitmap(object_id oid, uint64_t target_version, void { while (dirty_it->first.oid == oid) { - if (target_version >= dirty_it->first.version) + // Condition has to be the same as in dequeue_read() + if (!IS_IN_FLIGHT(dirty_it->second.state) && target_version >= dirty_it->first.version) { if (result_version) *result_version = dirty_it->first.version;