Repository: qdrant/qdrant
File: lib/collection/src/update_handler.rs (Rust)

Code before:

                        segments
                            .write()
                            .report_optimizer_error(CollectionError::service_error(format!(
                                "Optimization task panicked{separator}{message}"
                            )));
                    })),
                );
                handles.push(handle);
            }
        }

        handles
    }

    /// Ensure there is at least one appendable segment with enough capacity
    ///
    /// If there is no appendable segment, or all are at or over capacity, a new empty one is
    /// created.
    ///
    /// Capacity is determined based on `optimizers.max_segment_size_kb`.
    pub(super) fn ensure_appendable_segment_with_capacity(
        segments: &LockedSegmentHolder,
        segments_path: &Path,
        collection_params: &CollectionParams,
        collection_quantization: &Option<QuantizationConfig>,
        thresholds_config: &OptimizerThresholds,
        payload_index_schema: Arc<SaveOnDisk<PayloadIndexSchema>>,
    ) -> OperationResult<()> {
        let no_segment_with_capacity = {
            let segments_read = segments.read();
            segments_read
                .appendable_segments_ids()
                .into_iter()
                .filter_map(|segment_id| segments_read.get(segment_id))
                .all(|segment| {
                    let max_vector_size_bytes = segment
                        .get()
                        .read()
                        .max_available_vectors_size_in_bytes()
                        .unwrap_or_default();
                    let max_segment_size_bytes = thresholds_config
                        .max_segment_size_kb
                        .saturating_mul(segment::common::BYTES_IN_KB);

                    max_vector_size_bytes >= max_segment_size_bytes
                })
        };

        if no_segment_with_capacity {
            log::debug!("Creating new appendable segment, all existing segments are over capacity");

Review comment (suggestion):
```suggestion
        collection_quantization: Option<&QuantizationConfig>,
```

Code after:
                                        tracker_handle
                                            .update(TrackerStatus::Error(error.to_string()));

                                        is_optimization_failed.store(true, Ordering::Relaxed);

                                        panic!("Optimization error: {error}");
                                    }
                                },
                            }
                        }
                    },
                    // Panic handler
                    Some(Box::new(move |panic_payload| {
                        let message = panic::downcast_str(&panic_payload).unwrap_or("");
                        let separator = if !message.is_empty() { ": " } else { "" };

                        log::warn!(
                            "Optimization task panicked, collection may be in unstable state\
                             {separator}{message}"
                        );

                        segments
                            .write()
                            .report_optimizer_error(CollectionError::service_error(format!(
                                "Optimization task panicked{separator}{message}"
                            )));
                    })),
                );
                handles.push(handle);
            }
        }

        handles
    }

    /// Ensure there is at least one appendable segment with enough capacity
    ///
    /// If there is no appendable segment, or all are at or over capacity, a new empty one is
    /// created.
    ///
    /// Capacity is determined based on `optimizers.max_segment_size_kb`.
    pub(super) fn ensure_appendable_segment_with_capacity(
        segments: &LockedSegmentHolder,
        segments_path: &Path,
        collection_params: &CollectionParams,
        collection_quantization: Option<&QuantizationConfig>,
        thresholds_config: &OptimizerThresholds,
        payload_index_schema: Arc<SaveOnDisk<PayloadIndexSchema>>,
    ) -> OperationResult<()> {
        let no_segment_with_capacity = {
            let segments_read = segments.read();