Repository: qdrant/qdrant
File: lib/shard/src/proxy_segment/segment_entry.rs (Rust)

Code before:

    fn delete_point(
        &mut self,
        op_num: SeqNumberType,
        point_id: PointIdType,
        hw_counter: &HardwareCounterCell,
    ) -> OperationResult<bool> {
        let mut was_deleted = false;

        let point_offset = match &self.wrapped_segment {
            LockedSegment::Original(raw_segment) => {
                let point_offset = raw_segment.read().get_internal_id(point_id);
                if point_offset.is_some() {
                    let prev = self.deleted_points.write().insert(
                        point_id,
                        ProxyDeletedPoint {
                            local_version: op_num,
                            operation_version: op_num,
                        },
                    );
                    was_deleted = prev.is_none();
                    if let Some(prev) = prev {
                        debug_assert!(
                            prev.operation_version < op_num,
                            "Overriding deleted flag {:?} with older op_num:{}",
                            prev,
                            op_num
                        )
                    }
                }
                point_offset
            }
            LockedSegment::Proxy(proxy) => {
                if proxy.read().has_point(point_id) {
                    let prev = self.deleted_points.write().insert(
                        point_id,
                        ProxyDeletedPoint {
                            local_version: op_num,
                            operation_version: op_num,
                        },
                    );
                    was_deleted = prev.is_none();
                    if let Some(prev) = prev {
                        debug_assert!(
                            prev.operation_version < op_num,
                            "Overriding deleted flag {:?} with older op_num:{}",
                            prev,
                            op_num
                        )
                    }
                }

Review comment (bug):
```suggestion
                        debug_assert!(
                            prev.operation_version < op_num,
                            "Overriding deleted flag {prev:?} with older op_num:{op_num}",
                        )
```

Code after:

    fn delete_point(
        &mut self,
        op_num: SeqNumberType,
        point_id: PointIdType,
        hw_counter: &HardwareCounterCell,
    ) -> OperationResult<bool> {
        let mut was_deleted = false;

        let point_offset = match &self.wrapped_segment {
            LockedSegment::Original(raw_segment) => {
                let point_offset = raw_segment.read().get_internal_id(point_id);
                if point_offset.is_some() {
                    let prev = self.deleted_points.write().insert(
                        point_id,
                        ProxyDeletedPoint {
                            local_version: op_num,
                            operation_version: op_num,
                        },
                    );
                    was_deleted = prev.is_none();
                    if let Some(prev) = prev {
                        debug_assert!(
                            prev.operation_version < op_num,
                            "Overriding deleted flag {prev:?} with older op_num:{op_num}",
                        )
                    }
                }
                point_offset
            }
            LockedSegment::Proxy(proxy) => {
                if proxy.read().has_point(point_id) {
                    let prev = self.deleted_points.write().insert(
                        point_id,
                        ProxyDeletedPoint {
                            local_version: op_num,
                            operation_version: op_num,
                        },
                    );
                    was_deleted = prev.is_none();
                    if let Some(prev) = prev {
                        debug_assert!(
                            prev.operation_version < op_num,
                            "Overriding deleted flag {prev:?} with older op_num:{op_num}",
                        )
                    }
                }
                None
            }
        };