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

Code before:
                        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
                        )
                    }
                }
                None
            }
        };

        self.set_deleted_offset(point_offset);
        let mut write_segment_guard = self.write_segment.get().write();
        let point_version_in_write_segment = write_segment_guard
            .point_version(point_id)
            .unwrap_or_default();
        let mut was_deleted_in_writable = false;
        // Make sure deletion operation is not stale
        if op_num > point_version_in_write_segment {
            was_deleted_in_writable =
                write_segment_guard.delete_point(op_num, point_id, hw_counter)?;
        }
        Ok(was_deleted || was_deleted_in_writable)
    }

    fn update_vectors(
        &mut self,
        op_num: SeqNumberType,
        point_id: PointIdType,
        vectors: NamedVectors,
        hw_counter: &HardwareCounterCell,
    ) -> OperationResult<bool> {
        self.move_if_exists(op_num, point_id, hw_counter)?;
        self.write_segment
            .get()
            .write()
            .update_vectors(op_num, point_id, vectors, hw_counter)
    }

    fn delete_vector(
        &mut self,
        op_num: SeqNumberType,

Review comment (bug):
a `debug_assert` here failed showing that we apply the same `op_num` twice on the write segment

Code after:
                            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
            }
        };

        self.set_deleted_offset(point_offset);

        let was_deleted_in_writable = self
            .write_segment
            .get()
            .write()
            .delete_point(op_num, point_id, hw_counter)?;

        Ok(was_deleted || was_deleted_in_writable)
    }

    fn update_vectors(
        &mut self,
        op_num: SeqNumberType,
        point_id: PointIdType,
        vectors: NamedVectors,
        hw_counter: &HardwareCounterCell,
    ) -> OperationResult<bool> {
        self.move_if_exists(op_num, point_id, hw_counter)?;
        self.write_segment
            .get()
            .write()
            .update_vectors(op_num, point_id, vectors, hw_counter)
    }

    fn delete_vector(
        &mut self,
        op_num: SeqNumberType,
        point_id: PointIdType,
        vector_name: &VectorName,
    ) -> OperationResult<bool> {
        self.move_if_exists(op_num, point_id, &HardwareCounterCell::disposable())?;
        self.write_segment
            .get()
            .write()