Commit Graph

326 Commits

Author SHA1 Message Date
Tim Visée
1c48de0a8c General optional named vector improvements (#1835)
* Remove unnecessary mut

* Simplify creating option with if

* Simplify some returns

* DRY in vector name checking functions

* Use panic with attribute rather than debug_assert false

* Make update vector function plural because we can update multiple
2023-05-05 08:45:42 +02:00
Roman Titov
16b7fb7688 Improve handling out-of-RAM errors during Qdrant startup (#1777)
* WIP: Start working on out-of-RAM errors handling [skip ci]

* Implement basic handling of out-of-RAM errors during Qdrant startup

* Try to fix CI fail by allowing both V1 and V2 cgroups

* Try to fix CI fail by improving cgroups handling

* Fix cgroups path detection/handling (+ some minor stylistic changes)

* fixup! Fix cgroups path detection/handling (+ some minor stylistic changes)

* Add test

* Enable low RAM test

* fixup! Add test

* free memory checks

* rm unused function

* Oom fallback script (#1809)

* add recover mode in qdrant + script for handelling OOM

* fix clippy

* reformat entrypoint.sh

* fix test

* add logging to test

* fix test

* fix test

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-05-02 20:54:13 +02:00
dependabot[bot]
b988e47c2a Bump quantization from 299d542 to b5b1ff2 (#1821)
* Bump quantization from `299d542` to `b5b1ff2`

Bumps [quantization](https://github.com/qdrant/quantization) from `299d542` to `b5b1ff2`.
- [Release notes](https://github.com/qdrant/quantization/releases)
- [Commits](299d542ce8...b5b1ff2175)

---
updated-dependencies:
- dependency-name: quantization
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix build

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ivan Pleshkov <pleshkov.ivan@gmail.com>
2023-05-02 09:14:49 +02:00
Andrey Vasnetsov
3b95a8e045 undo vector-related changes in estimate_cardinality (#1806)
* undo vector-related changes in estimate_cardinality

* fix adjust_to_available_vectors
2023-04-29 10:04:39 +02:00
Tim Visée
d48cd31a36 Add optimizer for many deleted points, make aware of deleted points and vectors (#1758)
* Minor collection optimizer cleanup

* Make optimizers better aware of available vs soft deleted points

* Fix incorrect deleted state on proxy segment for double delete

* Rename upsert_vector to upsert_point, because we work with points

* Refactor point methods for more clear and consistent naming

* Replace internal_size in IdTracker with total_point_count

* Keep track of vector deletion count on storage creation

* Add sparse index optimizer, to optimize indexes with high deletion count

* Add minimum vector count threshold to sparse index optimizer

* Add sparse index optimizer test

* Use consistent naming, write vector in full everywhere

* Simplify vacuum optimizer a bit

* Merge sparse index optimizer into vacuum optimizer

* Improve update_from in segment builder by returning early

* More accurately count vectors in segment optimizer

* Remove random from vacuum optimizer tests to make them more reliable

* Don't expose the total points in segment info, use available points

* Process review feedback

* Compare available vectors against indexed ones in vacuum optimizer

This is much better than using the number of soft-deleted vectors when
the segment was created for calculations. Not to mention that value had
other problems as well.

* Remove create_deleted_vector_count field, update vacuum test parameters

* Potentially solve out of bound panic when building index

* Review fixes:

- Propagate deleted flags into payload hnsw building
- Use `total` number of points for building HNSW instead of number of
  available points
- minor refactoring of `hnsw_config` copy -> clone
- Better detection of `indexed_points` in HNSW

* fix assert condition

* Optional named vectors optimizer reveiw 2 (#1794)

* review with Ivan

* fmt

* remove available_vector_count from segment entry

* remove total_point_count from segment entry

---------

Co-authored-by: Ivan Pleshkov <pleshkov.ivan@gmail.com>

* rollback changes in deleted count in proxy segment

* improve vector threshold detection logic in optimized_segment_builder

* style changes

* fix propagate deleted points to vectors

* Fix typo in method name

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
Co-authored-by: Ivan Pleshkov <pleshkov.ivan@gmail.com>
2023-04-28 10:36:58 +02:00
Ivan Pleshkov
531abf5da7 Revert hnsw m min value validation (#1797)
* revert hnsw m min value

* grpc goo

* update openapi
2023-04-27 17:44:09 +02:00
Arnaud Gourlay
e0fe29a9f4 Support Array of Scalars in JsonPath extractor (#1784) 2023-04-26 07:55:04 +02:00
Tim Visée
9873ac88ec Make query planner aware of deleted points and vectors (#1757)
* Exclude deleted vectors from HNSW graph building stage

* When estimating query cardinality, use available points as baseline

We should not use the total number of points in a segment, because a
portion of it may be soft deleted. Instead, we use the available
(non-deleted) points as baseline.

* Add plain search check to unfiltered HNSW search due to deleted points

* Cardinality sampling on available points, ignore deleted named vectors

* Estimate available vectors in query planner, now consider deleted points

In the query planner, we want to know the number of available points as
accurately as possible. This isn't possible because we only know the
number of deletions and vectors can be deleted in two places: as point
or as vector. These deletions may overlap. This now estimates the number
of deleted vectors based on the segment state. It assumes that point and
vector deletions have an overlap of 20%. This is an arbitrary
percentage, but reflects an almost-worst scenario.

This improves because the number of deleted points wasn't considered at
all before.

* Remove unused function from trait

* Fix bench compilation error

* Fix typo in docs

* Base whether to do plain search in HNSW upon full scan threshold

* Remove index threshold from HNSW config, only use full scan threshold

* Simplify timer aggregator assignment in HNSW search

* Remove vector storage type from cardinality function parameters

* Propagate point deletes to all its vectors

* Check for deleted vectors first, this makes early return possible

Since point deletes are now propagated to vectors, deleted points are
included in vector deletions. Because of that we can check if the vector
is deleted first so we can return early and skip the point deletion
check.

For integrity we also check if the point is deleted, if the vector was
not. That is because it may happen that point deletions are not properly
propagated to vectors.

* Don't use arbitrary vector count estimation, use vector count directly

Before we had to estimate the number of vectors (for a named vector)
because vectors could be deleted as point or vector. Point deletes are
now propagated to vector deletes, that means we can simply use the
deleted vector count which is now much more accurate.

* When sampling IDs, check deleted vecs before deleted points

* On segment consistency check, delete vectors for deleted points

* Fix vector delete state not being kept when updating storage from other

* Fix segment builder skipping deleted vectors breaking offsets

* update segment to handle optional vectors + add test (#1781)

* update segment to handle optional vectors + add test

* Only update stored record when deleting if it wasn't deleted already

* Reformat comment

---------

Co-authored-by: timvisee <tim@visee.me>

* Fix missed vector name test, these are now marked as deleted

* upd test

* upd test

* Update consensus test

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-04-25 14:31:04 +02:00
Roman Titov
e240740ff3 Fix payload index snapshot restoration (#1775) 2023-04-24 21:41:11 +02:00
Roman Titov
5d3f9e167e Improve handling of out-of-disk-space errors during Qdrant startup (#1755)
Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-04-24 13:02:29 +02:00
Arnaud Gourlay
6acaca8bc6 fix Clippy 1.69 lint 'type parameter goes unused in function definition' (#1764) 2023-04-21 14:49:00 +02:00
Tim Visée
bce35092ed Add support for deleted vectors in segments (#1724)
* Use resize rather than while-push loop

* Add deleted flags to simple vector storage

* Add deleted flag to memmap vector storage

* Map BitSlice on mmap file for deleted flags

* Use vector specific deletion BitSlice in RawScorer

* Use BitSlice for deleted points, fix check point logic, clarify names

* Extract div_ceil function to shared module

* We can use unchecked set and replace because we just checked the length

* Add deleted count function to vector storage

* Add vector storage point deletion tests

* Keep deleted state in simple vector storage with update_from, add test

* Keep deleted state in memmap vector storage with update_from, add test

* Simplify div_ceil

* Improve deletion handling in update_from in mmap vector storage

* Improve performance, use trickery to get BitSlice view over deleted mmap

* Use BitSlice where possible, construct BitVec more efficiently

* Incorporate vector specific delete flags in quantized raw scorer

* Don't pin MmapMut, it is not required

* With quantization, keep mmap deleted flags in RAM for better performance

* Advice the kernel to prepare deleted flags mmap for faster future access

* Simplify deleted bitslice access, add bound check, remove unused function

* Fix compilation on Windows

* Cleanup

* Rename delete functions to delete_{point,vec} to prevent confusion

* Use then_some rather than match a boolean

* Lock deleted flags in memory only when quantization is available

* Add docs and stabilize issue link to dev_ceil

* Flush deleted mmap when closing segment

This requires us to to wrap the memory map struct in an Arc and Mutex.
Though this may look inefficient, it doesn't have a negative side effect
on deleted flag performance, because the flags are accessed through a
BitSlice that is separate and doesn't use locking.

* Rename some point functions to vec because that makes more sense

* Simplify delete flag fetching option, use deref func instead of asterisk

* Do not calculate slice size manually, use size_of_val

* remove test raw scorer

* use deref in check

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-04-20 12:06:29 +02:00
Ibrahim M. Akrab
ac572256e7 Inverted index optimization (#1677)
* Change BTreeSet/BTreeMap to HashSet/HashMap
Use Vec in Document
Use Vec in Postinglist

* fix document removal index out of range

* add common vocabulary dictionary to inverted index

* use radix-trie to store vocabulary

* add documentation for seemingly dangerous unwraps

* Implement BitVec representation of PostingList
Add dynamic switching between Vec and BitVec representation
Split PostingList into its own module

* use same persistent storage for documents

* clean up

* remove unused comments

* keep stored document format the same

* add reverse dictionary for faster document building

* get rid of reverse vocabulary

* review + fix tests

* review + fix clippy

* fix typo

* use u32 as token id

* fmt

* remove patricia_tree

* fmt

* only use vec for posting

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-04-18 18:46:06 +02:00
paulotten
d855d3e146 chore: fix clippy warnings (#1740)
* chore: fix clippy warnings

- Prefer `unwrap_or_else` over `unwrap_or` as the later is always executed.
- Use `clamp`.

* chore: convert `default_quantization_ignore_value` and `default_quantization_rescore_value` to `const fn`

* chore: revert `clamp` change
2023-04-17 11:42:34 +02:00
Tim Visée
2552fdacef Fix divide by zero panic (#1710) 2023-04-12 17:59:08 +02:00
Andrey Vasnetsov
cdb714f9a2 make is-empty condition consistent with all other conditions (#1698)
* make is-empty condition consistent with all other conditions

* review and clippy
2023-04-11 18:19:28 +02:00
Tim Visée
f5a14449a0 Add vector specific quantization configuration (#1680)
* Add QuantizationConfigDiff type

* Add quantization config diff to vector parameters

* Prefer vector config over collection config for quantization

* Update OpenAPI specification

* Validate quantization configuration quantile in 0.5-1.0 range

As per https://github.com/qdrant/qdrant/pull/1681

* Add test if check if vector specific quantization config is persisted

* Alias quantization to quantization_config in vector parameters

* Remove quantization config diff, use full vector specific config instead

* Regenerate OpenAPI specification and gRPC docs

* Fix compilation error

* Add error handling to quantization config conversions

* Fix quantization integration test, make HNSW test stricter
2023-04-10 21:39:43 +02:00
Luis Cossío
139d3eb1e2 Include "last_responded" in telemetry (#1668)
* feat: include "last_queried" in /telemetry

* fix: anonymize responses in the WebApiTelemetry and GrpcTelemetry Anonymize impls

* fix: anonymize the last_queried field

* fix: use YYYY/MM/DD hh:mm:ss format on 'last_queried'

* tests: add and fix telemetry test

* refactor: rename last_queried -> last_responded

* cargo fmt

* update openapi models

* refactor: rename last_request_time -> last_response_date

* tests: update test

* review changes

* add chrono to schemars

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-04-10 20:20:00 +02:00
Tim Visée
e985ff31b6 General improvements (#1687)
* Change file mode of some .sh files to make them executable

* Remove whitespace on empty lines from YAML configurations

* Fix unused import warning on Windows
2023-04-10 20:03:56 +02:00
Tim Visée
b7c1ecfd5f Add vector specific HNSW configuration (#1675)
* Validate VectorConfig/VectorParams, remove obsolete validation

* Add HNSW config diff to vector parameters

* Validate params in collection config

* Add HNSW config to segment vector data config

* Add VectorsConfig params iterator for more elegant conversions

* Prefer vector HNSW config over collection config for building HNSW index

* Base segment vector param HNSW config on collection config

* General improvements

* Rewrite HNSW ef_construct extract function to also consider vector configs

* Update OpenAPI specification

* Add test to check if vector specific HNSW config is persisted

* review changes

* review changes

* Regenerate gRPC docs

* Fix test on Windows

* Regenerate OpenAPI specification

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-04-10 17:16:56 +02:00
Tim Visée
f446f5c7ad Verify quantization configuration on collection creation (#1681)
* Verify quantization configuration on collection creation

* Update OpenAPI specification

* Update range in doc to match validation definition

* Update OpenAPI specification
2023-04-10 16:02:11 +02:00
Andrey Vasnetsov
e034b0ea35 Try to fix dying shards (#1682)
* use common channel pool for healthcheck requests

* add dynamic channel pool

* fmt

* lower parallel connections num

* fmt

* fix clippy

* fix clippy

* better status error message

* smarter channel dropping conditions

* per-channel stats

* refactor pool

* rollback dockerfile

* health-check timeout

* prevent reporting last active peer as dead

* introduce update rate limit

* only rate-limit client requests

* ability to save snapshot without locking wal (#1685)

* ability to save snapshot without locking wal

* fix empty wal saving

* skip waiting on local shard in listener mode even if it is a direct request to listener shard

* snapshot recovery test + better handling of segment versions

* use latest wal

* review changes
2023-04-10 15:29:39 +02:00
Ivan Pleshkov
cc3f091d4a additional deleted checks in raw scorers (#1674) 2023-04-07 01:42:33 +03:00
Ivan Pleshkov
d5515ed676 fix search one day bug (#1672) 2023-04-06 16:08:07 +03:00
Andrey Vasnetsov
b73335259f Restore is empty functions as before (#1657)
* is_empty should match with value=null

* fmt
2023-04-04 12:17:07 +02:00
Ivan Pleshkov
4635481492 Add Actix and config validation (#1463)
* actix validation

* add check for memmap/indexing_threshold

* fix actix json settings

* Validate settings configuration on start, print pretty warnings on fail

* Add more validation rules for settings and nested types

* Move shared validation logic into collection/operations

* Show validation warning in log when loading some internal configs

* Show prettier actix JSON validation errors

* Stubs for pretty handling of query errors, reformat validation errors

* Use crate flatten function, the hard work was already done for us

We don't have to flatten validation errors into their qualified field
names ourselves because there is a utility function for this.

* Configure actix path validator

* Actix endpoints don't require public

* Extend validation to more actix types

* Validate all remaining actix path and query properties

* Rephrase range validation messages to clearly describe they're inclusive

* Validate all query params to respond with pretty deserialize errors

* Nicely format JSON payload deserialize error responses

* Improve error reporting for upsert point batches

* Add basic validation test that checks a path, query and payload value

* Add some validation constraints

* Add simple validation error render test

* Update Cargo.lock

---------

Co-authored-by: timvisee <tim+github@visee.me>
2023-04-03 09:43:55 +02:00
Ibrahim M. Akrab
f85ae02ab6 add isNull condition for payload filtering (#1617)
* add minimal working is_null filter

* add is_null condition to grpc api (backward compatible)

* add unit tests is_null and is_empty conditions

* add is_null to  points.proto file

* add some failing OpenAPI tests

* fix a failing test due to change in collection data

* refactor MultiValue's check for is_null

* fix is_empty condition not picking up "key":[]

* remove duplicate OpenAPI integration test

* reuse same variable in condition checker tests

* update grpc docs

* fix is_null cardinality estimation to match is_empty

* update openapi specs

* remove unused debug statements

* add new test points to original test_collection

* fix failing tests according to newly added points

* add the `"key":[null]` test_case
2023-04-01 20:46:50 +02:00
Ivan Pleshkov
1c6a6cea54 fix remove geo index (#1566) 2023-03-15 15:29:28 +01:00
Ivan Pleshkov
faf1235333 Remove deleted flags from vector storage (#1561)
* remove deleted flags from vector storage

* remove deleted flags from mmap

* new simple vector storage format

* are you happy clippy

* remove id_tracker from raw_scorer

* revert vector storage format changes

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-03-15 14:05:07 +01:00
Ivan Pleshkov
7fd15ef4af Don't update payload if point was not upserted (#1564)
* fix values count loading in geoindex

* don't update payload if point was not upserted

* remove debug comments

* post-check of internal id

* revert changes from geo indexing branch
2023-03-15 13:36:46 +04:00
Ivan Pleshkov
30ef3b6ea8 Fix values count loading in geoindex (#1563)
* fix values count loading in geoindex

* WIP: fix loading statistics in geo-index

* WIP: fmt

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-03-15 12:56:42 +04:00
Andrey Vasnetsov
97c06f0377 Fix histogram for large integer values (#1562)
* make histogram generic

* fmt
2023-03-15 09:52:42 +01:00
Andrey Vasnetsov
91991f62bc ensure segment flushing order + extend logging (#1551)
* ensure segment flushing order + extend logging

* fix review
2023-03-13 10:46:06 +01:00
Ivan Pleshkov
2be8590968 Enum vector index (#1539)
* separate payload and vector index bases

* vector index as enum
2023-03-12 14:14:21 +01:00
Ivan Pleshkov
35719c0fab Remove vector scorer trait (#1546)
* remove vector scorer

* nits

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-03-11 20:13:24 +01:00
Tim Visée
68a9c2ad48 Fix clippy warnings (#1542) 2023-03-10 12:57:38 +01:00
Andrey Vasnetsov
c6dd977c5e Quantization re scoring param (#1538)
* parameter to disable rescoring with quantization

* fix

* fix default

* review fixes

* upd api autogen
2023-03-09 11:51:29 +01:00
Ivan Pleshkov
84e6cd8290 Vector storages enum (#1533)
* separate scoring and data containing

* vector storage enum

* fix test build

* are you happy clippy

* review fixes
2023-03-09 09:43:20 +04:00
Ivan Pleshkov
5174388ab4 integrate quantized data to storages (#1311)
* integrate quantized data to storages

* revert gitignore

* are you happy clippy

* quantize in optimizer

* provide flag

* fix segfault

* skip quantization flag, update scores

* use quantization flag

* are you happy fmt

* use quantization flag

* quantized search test

* are you happy fmt

* refactor test, refactor scorer choosing

* are you happy fmt

* run quantization on segment builder

* decrease testing parameters

* simplify segment

* update version

* remove use_quantization flag

* provide quantization config

* quantization version up

* euclid dist

* add euclid test

* saveload

* fix initialization bugs

* quantization lib version up

* fix arm build

* refactor scorer selecting

* quant lib version up

* are you happy fmt

* are you happy fmt

* are you happy clippy

* add save/load test for simple storage

* add comments

* quantiles

* quantization mmap

* remove f32

* mmap test

* fix mmap slice

* fix mmap test

* use chunks for quantization storage

* fix build

* are you happy fmt

* update quantization library

* update quantization lib

* update quantization lib

* integrate api changes

* are you happy fmt

* change quantization api

* additional checks in tests

* update quantization version

* fix unit tests

* add quantization to storage config

* use quantization for all cardinality search cases

* Integrate quantization suggestions 2 (#1520)

* review api

* wip: refactor quantization integrations

* wip: refactor quantization integrations

* wip: fmt

* include quantization into snapshot

* fmt

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-03-03 17:46:17 +01:00
Ivan Pleshkov
83efed1fcf fix windows warning unused parallel_graph_build (#1513) 2023-03-01 11:10:22 +01:00
Arnaud Gourlay
ea485a9029 Fix condition check for values_count (#1502) 2023-02-28 09:47:28 +01:00
Arnaud Gourlay
2770a24766 Nested payload filters (#1487)
* Nested payload filters

* close ToDo + add parsing of multuiple array values

* fmt

* improve testing nested arrays

* fix NumericIndex to accumulate points_to_values mapping

* revert numberic index + strict array field access

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-02-23 15:57:12 +01:00
Arnaud Gourlay
3803af502d Access payload key through nested Array (#1465)
* Access payload key through nested Array

* support removal through array index

* propagate type changes

* fmt

* avoid allocating Vec of one element
2023-02-17 17:41:28 +01:00
Luis Cossío
c15fec2a2a feat: add "any" to "match" statements (#1466)
* feat: add "any" to "match" statements

Adds support for using "any" to match on a list of different possible values

* enable proper counting in cardinality estimation

* fmt

* upd OpenAPI

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-02-15 11:11:20 +01:00
dependabot[bot]
1204682000 Bump rocksdb from 0.19.0 to 0.20.0 (#1461)
* Bump rocksdb from 0.19.0 to 0.20.0

Bumps [rocksdb](https://github.com/rust-rocksdb/rust-rocksdb) from 0.19.0 to 0.20.0.
- [Release notes](https://github.com/rust-rocksdb/rust-rocksdb/releases)
- [Changelog](https://github.com/rust-rocksdb/rust-rocksdb/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-rocksdb/rust-rocksdb/compare/v0.19.0...v0.20.0)

---
updated-dependencies:
- dependency-name: rocksdb
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix api changes

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ivan Pleshkov <pleshkov.ivan@gmail.com>
2023-02-10 10:22:34 +01:00
Andrey Vasnetsov
ac251358b9 Fix flacky windows test (#1448)
* use async sleep

* fmt

* disablee test_parallel_graph_build on CI on windows untill there is a way to reproduce
2023-02-09 20:48:00 +01:00
Roman Titov
1be2f67a2e Reimplement ExtendedPointId deserialization (#1453)
Reimplement `ExtendedPointId` deserialization, to produce better error message when deserialization fails
2023-02-10 02:36:36 +10:00
Andrey Vasnetsov
26551c64ef rollback custom deserialization for point id 2023-02-08 14:13:57 +01:00
Andrey Vasnetsov
39cc731611 Windows support (#1432)
* windows-support

* fmt

* install protoc with action

* upd WAL revision
2023-02-06 14:00:23 +01:00
Andrey Vasnetsov
e3066b96fc allow to overwrite max number of cpus with env variable (#1425) 2023-02-02 14:44:03 +01:00