osd: use lower_bound to find head operation in pg_cancel_write_queue #90

Merged
vitalif merged 1 commits from changwei.ye/vitastor:fix-pg-cancle-write-queue into master 2026-10-17 21:20:36 +03:00
Contributor

Description

osd: use lower_bound to find head operation in pg_cancel_write_queue

std::multimap::find() is not guaranteed by the C++ standard to return the
first element of a range with equivalent keys, which may fail to retrieve
the head operation in pg.write_queue.

Switch to lower_bound() to reliably locate the head of the queue in O(log N)
time, and add an explicit check for it->first == oid to prevent falsely
matching a subsequent larger key when the target oid is missing.

Contributor Name

Changwei Ye (Datatom, https://www.datatom.com/)

CLA

### Description osd: use lower_bound to find head operation in pg_cancel_write_queue std::multimap::find() is not guaranteed by the C++ standard to return the first element of a range with equivalent keys, which may fail to retrieve the head operation in pg.write_queue. Switch to lower_bound() to reliably locate the head of the queue in O(log N) time, and add an explicit check for it->first == oid to prevent falsely matching a subsequent larger key when the target oid is missing. ### Contributor Name Changwei Ye (Datatom, https://www.datatom.com/) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
changwei.ye added 1 commit 2026-10-12 11:06:50 +03:00
std::multimap::find() is not guaranteed by the C++ standard to return the
first element of a range with equivalent keys, which may fail to retrieve
the head operation in pg.write_queue.

Switch to lower_bound() to reliably locate the head of the queue in O(log N)
time, and add an explicit check for it->first == oid to prevent falsely
matching a subsequent larger key when the target oid is missing.
changwei.ye requested review from vitalif 2026-10-12 11:07:04 +03:00
changwei.ye force-pushed fix-pg-cancle-write-queue from 672382c674 to f0816f6ed0 2026-10-15 07:19:58 +03:00 Compare
vitalif approved these changes 2026-10-17 21:20:25 +03:00
vitalif merged commit bba9aacfe3 into master 2026-10-17 21:20:36 +03:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#90
No description provided.