Commit Graph

428 Commits

Author SHA1 Message Date
Tim Visée
f3eaeec634 Make WAL inspector support operations with clock tag (#3591)
* Make WAL inspector support operations with clock tag

* Render operation and clock tag separately
2024-03-05 17:06:19 +01:00
Ivan Pleshkov
4397b28530 Validate sparse indices in grpc search (#3225)
* validate sparse indices in grpc search

* add test

* validate into vector conversion
2024-03-05 17:06:04 +01:00
Andrey Vasnetsov
69b6a9866e Print version on startup (#3581)
* add logging of the version and git commit ID to the welcome message

* review fixes
2024-03-05 17:04:47 +01:00
Tim Visée
f08df0b22e Add endpoint to request recovery point for remote shard (#3510)
* Add initial gRPC call for requesting WAL recovery point for remote shard

* Add remote shard method to request WAL recovery point

* Add recovery point type in gRPC, use it in recovery point functions

* Add function to extend recovery point with missing clocks from clock map

* Add new gRPC type for recovery point clocks

* Remove atomic loading, because we use regular integers now
2024-03-05 17:04:41 +01:00
Tim Visée
d93c4f0479 Fix REST API pattern match ordering problem (#3544)
* Change order of actix web REST services to fix pattern matching

* Binary search over list of allowed read only patterns

* Add test to ensure the list of patterns is sorted
2024-03-05 17:01:39 +01:00
Luis Cossío
320b7f2621 order_by in scroll (#3493)
* first PR implementation (#2865)

- fetch offset id
- restructure tests
- only let order_by with numeric
- introduce order_by interface

cargo fmt

update openapi

calculate range to fetch using offset + limit, do some cleanup

enable index validation, fix test

Fix pagination

add e2e tests

make test a little more strict

select numeric index on read_ordered_filtered

add filtering test 🫨

fix filtering on order-by

fix pip requirements

add grpc interface, make read_ordered_filtered fallible

fmt

small optimization of `with_payload` and `with_vector`

refactor common logic of point_ops and local_shard_operations

Make filtering test harder and fix limit for worst case

update openapi

small clarity refactor

avoid extra allocation when sorting with offset

stream from numeric index btree instead of calculating range

use payload to store order-by value, instead of modifying Record interface

various fixes:
- fix ordering at collection level, when merging shard results
- fix offset at segment level, to take into account also value offset
- make rust tests pass

remove unused histogram changes

fix error messages and make has_range_index exhaustive

remove unused From impl

Move OrderBy and Direction to segment::data_types::order_by

Refactor normal scroll_by in local_shard_operations.rs

More cleanup + rename OrderableRead to StreamWithValue

empty commit

optimization for merging results from shards and segments

fix case of multi-valued fields

fix IntegerIndexParams name after rebase

precompute offset key

use extracted `read_by_id_stream`

Expose value_offset to user
- rename offset -> value_offset
- extract offset value fetching logic

* remove offset functionality when using order_by

* include order_by in ForwardProxyShard

* extra nits

* remove histogram changes

* more nits

* self review

* resolve conflicts after rebase, not enable order-by with datetime index schema

* make grpc start_from value extendable

* gen grpc docs

---------

Co-authored-by: kwkr <kawka.maciej.93@gmail.com>
Co-authored-by: generall <andrey@vasnetsov.com>
2024-03-05 16:57:35 +01:00
Luis Cossío
c62de38323 metrics endpoint: Whitelist discover endpoints (#3512)
* whitelist discover endpoints for `/metrics`

* Add error messages for API consistency check

* Restore order in GRPC_ENDPOINT_WHITELIST
2024-03-05 16:57:26 +01:00
Roman Titov
99b750fcfa Add clock_tag field to update operations (#3408) 2024-03-05 16:57:21 +01:00
Tim Visée
1951426533 Dynamic CPU saturation internals (#3364)
* Move CPU count function to common, fix wrong CPU count in visited list

* Change default number of rayon threads to 8

* Use CPU budget and CPU permits for optimizer tasks to limit utilization

* Respect configured thread limits, use new sane defaults in config

* Fix spelling issues

* Fix test compilation error

* Improve breaking if there is no CPU budget

* Block optimizations until CPU budget, fix potentially getting stuck

Our optimization worker now blocks until CPU budget is available to
perform the task.

Fix potential issue where optimization worker could get stuck. This
would happen if no optimization task is started because there's no
available CPU budget. This ensures the worker is woken up again to
retry.

* Utilize n-1 CPUs with optimization tasks

* Better handle situations where CPU budget is drained

* Dynamically scale rayon CPU count based on CPU size

* Fix incorrect default for max_indexing_threads conversion

* Respect max_indexing_threads for collection

* Make max_indexing_threads optional, use none to set no limit

* Update property documentation and comments

* Property max_optimization_threads is per shard, not per collection

* If we reached shard optimization limit, skip further checks

* Add remaining TODOs

* Fix spelling mistake

* Align gRPC comment blocks

* Fix compilation errors since last rebase

* Make tests aware of CPU budget

* Use new CPU budget calculation function everywhere

* Make CPU budget configurable in settings, move static budget to common

* Do not use static CPU budget, instance it and pass it through

* Update CPU budget description

* Move heuristic into defaults

* Fix spelling issues

* Move cpu_budget property to a better place

* Move some things around

* Minor review improvements

* Use range match statement for CPU count heuristics

* Systems with 1 or 2 CPUs do not keep cores unallocated by default

* Fix compilation errors since last rebase

* Update lib/segment/src/types.rs

Co-authored-by: Luis Cossío <luis.cossio@qdrant.com>

* Update lib/storage/src/content_manager/toc/transfer.rs

Co-authored-by: Luis Cossío <luis.cossio@qdrant.com>

* Rename cpu_budget to optimizer_cpu_budget

* Update OpenAPI specification

* Require at least half of the desired CPUs for optimizers

This prevents running optimizations with just one CPU, which could be
very slow.

* Don't use wildcard in CPU heuristic match statements

* Rename cpu_budget setting to optimizer_cpu_budget

* Update CPU budget comments

* Spell acquire correctly

* Change if-else into match

Co-authored-by: Luis Cossío <luis.cossio@qdrant.com>

* Rename max_rayon_threads to num_rayon_threads, add explanation

* Explain limit in update handler

* Remove numbers for automatic selection of indexing threads

* Inline max_workers variable

* Remove CPU budget from ShardTransferConsensus trait, it is in collection

* small allow(dead_code) => cfg(test)

* Remove now obsolete lazy_static

* Fix incorrect CPU calculation in CPU saturation test

* Make waiting for CPU budget async, don't block current thread

* Prevent deadlock on optimizer signal channel

Do not block the optimization worker task anymore to wait for CPU budget
to be available. That prevents our optimizer signal channel from being
drained, blocking incoming updates because the cannot send another
optimizer signal. Now, prevent blocking this task all together and
retrigger the optimizers separately when CPU budget is available again.

* Fix incorrect CPU calculation in optimization cancel test

* Rename CPU budget wait function to notify

* Detach API changes from CPU saturation internals

This allows us to merge into a patch version of Qdrant. We can
reintroduce the API changes in the upcoming minor release to make all of
it fully functional.

---------

Co-authored-by: Luis Cossío <luis.cossio@qdrant.com>
Co-authored-by: Luis Cossío <luis.cossio@outlook.com>
2024-03-05 16:57:12 +01:00
xzfc
2f76603ddf DateTime payload index (#3395)
* Datetime payload index

* Introduce IndexMapItem

* Drop FieldIndex::DatetimeIndex

* Rename OpenAPI struct names

* Switch to microseconds

* Validate and serialize grpc timestamps

* Add tests with different timezones

* minor review fixes

* Revert "Drop FieldIndex::DatetimeIndex"

This reverts commit d55f251afd.

* Revert "Introduce IndexMapItem"

This reverts commit c5255f6b1a.

* fix: back to microseconds after reverts

* extract range conversion from boxed checker fn

* add log to deps

* don't run macro doctest

* no_run -> ignore

* remove prost-types in favor of prost-wkt-types

* better assertion on test_payload_indexing.py

* propagate unparsable datetime

---------

Co-authored-by: Luis Cossío <luis.cossio@outlook.com>
2024-03-05 16:57:08 +01:00
Roman Titov
4fce0037f3 Make update API cancel safe (#3367)
* WIP: `tokio::spawn` update API request handlers [skip ci]

* WIP: `cancel::future::spawn_cancel_on_drop` update API request handlers [skip ci]

* WIP: Make update API cancel-safe [skip ci]

TODO:
- Fix tests
- Evaluate and resolve TODOs

* Fix tests

* Fix benches

* WIP: Simplify cancel safety implementation

* Document and annotate cancel safety guarantees of update API

- Also fix tests after simplifying update API cancel safety impl
- And add a few `cancel::future::cancel_on_token` calls here and there

* Further simplify cancel safety implementation

No more cancellation tokens! 🎉

* Resolve cancel safety TODO

---------

Co-authored-by: timvisee <tim@visee.me>
2024-03-05 16:56:29 +01:00
dependabot[bot]
47263e78bb Bump tracing-tracy from 0.10.5 to 0.11.0 (#3481)
* Bump tracing-tracy from 0.10.5 to 0.11.0

Bumps [tracing-tracy](https://github.com/nagisa/rust_tracy_client) from 0.10.5 to 0.11.0.
- [Commits](https://github.com/nagisa/rust_tracy_client/commits/tracing-tracy-v0.11.0)

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

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

* Provide default config when constructing Tracy

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: timvisee <tim@visee.me>
2024-03-05 16:56:14 +01:00
Gabriel
3392407f6a API for checking collection exists (#3472)
* saving progress

* tests assertions are working

* fixed lint

* fixed typo, existance -> existence

* added timing on grpc

* added timing on grpc

* fixed double time
2024-03-05 16:55:27 +01:00
xzfc
a11c6f6a5b add optional checksum to snapshot recovery request (#3381)
* add optional checksum to snapshot recovery request

* Update openapi yaml files

* Add pytests for snapshots restoration
2024-03-05 16:52:38 +01:00
Shrinibas Mahanta
13b24c9516 fixes gRPC API return status code. (#3423)
* This changes the returning of StorageError::BadInput to StorageError::AlreadyExists.

* This adds AlreadyExists error type to StorageError enum

* This implements already_exists function to handle AlreadyExists StorageError.

* This adds error to status code for StorageError::AlreadyExists using tonic::Code::AlreadyExists

* This adds Error type for actix to handle AlreadyExists Storage error using Error::CONFLICT

* This adds using HttpResponse::Conflict for building HttpResp in case of StorageError

* This adds StatusCode and description for HttpError caused by StorageError

* fix integration test

* rename is_collection_exists -> collection_exists

---------

Co-authored-by: Luis Cossío <luis.cossio@outlook.com>
2024-03-05 16:52:04 +01:00
Tim Visée
3281be7402 Rename IntegerParams to IntegerIndexParams to be consistent with text (#3385) 2024-03-05 16:47:18 +01:00
Tim Visée
820ade7494 Parameterize integer index, allow lookup or range exclusively (#3380)
* Merge serde attributes

* Remove obsolete conversion

* Add integer type with parameters

* Make integer lookup and range parameters non-optional

* Add parameterized integer index types test

Co-authored-by: Di Zhao <diz@twitter.com>

* Cleanup

---------

Co-authored-by: Di Zhao <diz@twitter.com>
2024-03-05 16:47:07 +01:00
kwkr
4296226555 Add checksum to SnapshotDescription (#2840)
* add checksum to SnapshotDescription

* implement storing snapshot checksums in a file

* Don't serialize checksum if it's None for backwards compatibility

* Remove hex dependency, use Rust std formatter for this

* Do not error if we cannot remove checksum file for snapshot

Some snapshots may not have a corresponding checksum file. Maybe it was
created in an older Qdrant version that didn't have support for this, or
a user hasn't provided any.

* Add debug message when hashing snapshot, can be expensive on large files

* Inline debug messages

* Add checksum to shard snapshots

* If creating snapshot fails, delete snapshot target and checksum file

* Use Rust idiomatic ok() and improve debug messages

* Use correct snapshot checksum paths, clean up after shard snapshot

* Use better path type in get_checksum_path

---------

Co-authored-by: timvisee <tim@visee.me>
Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2024-03-05 16:46:31 +01:00
Tim Visée
6a7b954a6f Bump rustls-pemfile to 2.0.0 (#3308) 2024-03-05 16:46:18 +01:00
Kumar Shivendu
0fe19cfb60 feat: Expose git commit id in the health check endpoint (#3346)
* feat: Expose git commit id in the health check endpoint

* fix: CI errors

* test: Add test for health check api

* feat: Add / endpoint to openapi schema

* Make git commit hash optional

* ci: Enable debugging setup-protoc action

* Install later protobuf compiler through GitHub Action

* Disable debug mode for setup-protoc job

* refactor: Use commit instead of commit_id

* fix: Use commit instead of commit_id gRPC docs

* test: Update ping API test

* refactor: Rename ping api to root api

---------

Co-authored-by: timvisee <tim@visee.me>
2024-03-05 16:46:04 +01:00
Tim Visée
f4a746c175 When bind IP is zero, render it as localhost in greeting (#3179)
* When bind IP is zero, render it as localhost in greeting

* Parse IP addresses for more reliable matching, allow localhost addresses
2024-03-05 16:45:06 +01:00
Tim Visée
cf7f78b77b Custom thread priorities on Linux (#3235)
* Set high/low priority for consensus and HNSW threads

* Make setting thread priority Linux specific

* Fix compilation on non-Linux platforms

* Remove unused dependencies from Cargo.toml

* Rename function

* Add warning that setting lower nice is likely to fail
2024-03-05 16:44:33 +01:00
Tim Visée
5aeef698f1 Avoid logging /healthz, /readyz, /livez in access logs (#3313) 2024-03-05 16:44:02 +01:00
Tim Visée
f1d5cfd3c3 Avoid logging /metrics and /telemetry in access log (#3257)
* Avoid logging /metrics and /telemetry in access log

* Move comment inside wrap body
2024-03-05 16:35:11 +01:00
Tim Visée
a159b909cf Synchronize nodes after collection creation (#3318)
* Synchronize nodes after creating collection in distributed mode

* Give slow CI machines more time for collection churning

* Improve comment

* Do not double-wait synchronizing nodes when creating shard key

* Only sync nodes when creating collection, shardkey or changing aliases

* Update comments
2024-01-29 14:15:54 +01:00
Ivan Pleshkov
bd6bd55033 Rename VectorType to DenseVector (#3192)
* rename vectortype to densevector

* rename enums

* are you happy fmt

* openapi

* revert type renamings
2023-12-19 19:26:50 +00:00
Roman Titov
8088a769c5 Fix /readyz if some nodes are unavailable (#3193, #3215) 2023-12-12 17:35:41 +01:00
Roman Titov
eb0f79e743 Fix /readyz when upgrading cluster from 1.6 to 1.7 (#3193, #3196)
Co-authored-by: Tim Visée <tim+github@visee.me>
2023-12-11 14:28:52 +01:00
golangboy
3f181aff32 fix: display the real bind addr (#3169) 2023-12-06 17:21:35 +01:00
Roman Titov
cb46a73609 Extend /readyz with shards readiness check (#3053, #3084)
Co-authored-by: generall <andrey@vasnetsov.com>
Co-authored-by: timvisee <tim@visee.me>
2023-12-06 17:20:29 +01:00
Arnaud Gourlay
0935ab5751 Fix naming gRPC shard snapshot service (#3135) 2023-12-06 17:19:01 +01:00
Ivan Pleshkov
3fc1f96564 Sparse index segment and collection config (#2802)
* quantization storage as separate entity

sparse index try to extend segment types

fix build

fix async scorer

codespell

update openapi

update vector index

remove code duplications

more fixes

more fixes

fix build

fix deserialization test

remove transform_into

are you happy clippy

update openapi

update openapi

are you happy clippy

fix build

optional serialize

more defaults

update openapi

fix comments

generic transpose_map_into_named_vector

rename fields in tests

remove obsolete parts

only named sparse config

VectorStruct without unnamed sparse

NamedVectorStruct without unnamed sparse

remove obsolete test

update openapi

mmap index

revert preprocess function

are you happy fmt

update openapi

fix build

fix tests

are you happy fmt

fix for client generation

fix sparse segment creation

fix basic sparse test

fix conflicts

remove obsolete convertion

fix build

config diffs

update openapi

review remarks

update openapi

fix batch upsert

add failing test showing bad ids matching

fix sparse vector insertion

remove on_disk flag

update openapi

revert debug assert

simplify conversions

update openapi

remove on disk storage flag

update openapi

default for vector config

update openapi comment

remove diffs

update openapi

* enable consensus test

* add comment

* update openapi
2023-12-06 17:16:06 +01:00
Andrey Vasnetsov
293745fa76 spare one extra worker by replacing spawn with block_on (#3086) 2023-12-06 17:11:57 +01:00
Wesley
8b7211cb20 Read-Only API keys (#2979)
* Read-only API keys

Co-authored-by: Luis Cossío <luis.cossio@outlook.com>

Correct placement of OpenAPI security

Place regex dep with actix/tonic

* Read-only API keys

* Replace with pytests

* API Key tests run on the same job

* Drop allow dead-code

* Rename setting key

* Containerized tests

* No special config files

* DRY

* refactor: re-use can_write method

* refactor: replace static by constants

* refactor: get PID from `$!`

* refactor: use explicit brackets on boolean condition

* style: fix identation

* small fixes + account for new APIs

* specify security in openapi

* small fix + chmod for .sh testfile

* add best-efford check for api consistency

---------

Co-authored-by: Amr Hassan <amr.hassan@gmail.com>
Co-authored-by: generall <andrey@vasnetsov.com>
2023-12-06 17:11:33 +01:00
Ivan Pleshkov
47690244bc Sparse vector grpc definition (#3070)
* Sparse vector grpc definition

remove obsolete use

update grpc docs

update openapi

more convertion fixes

update grpc docs

* validations

* review renamings

* add todos
2023-12-06 17:11:06 +01:00
Luis Cossío
3fd3ff215a refactor: turn offset into an option (#3082)
* refactor: make offset optional

* update openapi

* add simple test
2023-12-06 17:11:00 +01:00
Tim Visée
a1f5f334f7 Only use ANSI in logging if we should colorize (#3073) 2023-12-06 17:09:17 +01:00
Ivan Pleshkov
13f15955fc Sparse vectors rest search and upsert (#3051)
* sparse vector sparse search and upsert

are you happy fmt

fix build

update openapi

batch changes

update openapi

named sparse vector

* review remarks

* cowvalue to cowvector
2023-12-06 17:08:37 +01:00
Arnaud Gourlay
7d4497fb1d Register Sparse JSON schema (#3050) 2023-12-06 17:06:46 +01:00
Tim Visée
9b177d5632 Refactor shard transfer logic (#2991)
* Extract shard transfer implementations into modules

* Extract shard transfer helpers into module

* Extract functions driving shard transfer into module

* Move implementation below struct definition
2023-12-06 17:05:50 +01:00
Andrey Vasnetsov
1fcadcd0c3 Shard key create confirmation (#3027)
* create dedicated API for creating shards with explicit avait on the consensus

* fmt

* update api definitions
2023-12-06 17:04:39 +01:00
Tim Visée
73b9f39ac7 Simplify batch_requests signature (#3014) 2023-12-06 17:03:12 +01:00
Andrey Vasnetsov
2810672598 Huge refactoring to make read requests aware of shard key selector (#3004)
* huge refactoring to make read requests avare of shard key selector

* fix integration test

* review fixes

* allow lookup_from specific shards
2023-12-06 17:02:20 +01:00
Andrey Vasnetsov
91dbc8b096 check that there are no pending operations, before syncing local state (#2969) 2023-12-06 17:00:40 +01:00
Andrey Vasnetsov
cae3c45bf5 Remove deprecated search methods (#2970)
* remove duplicated search methods, introduced for compatibility in last version

* Use `with_capacity` rather than a manual reserve

* explicit Arc clones

* get rid of batching by runs of same strategy

* avoid refactor in group by

* more explicit arc clones, remove one .expect()

* little extra refactor on recommendations.rs

* refactor grouping_test.rs too

---------

Co-authored-by: timvisee <tim@visee.me>
Co-authored-by: Luis Cossío <luis.cossio@outlook.com>
2023-12-06 17:00:04 +01:00
Andrey Vasnetsov
d3aada0e96 Shard key index consistency (#2938)
* WIP: collection-level storage for payload indexe scheme

* introduce consensus-level operation for creating payload index

* make operation_id optional in the UpdateResult

* set payload index in newly created shards

* upd api definitions

* include payload index schema into collection consensus state

* include payload index schema into shard snapshot

* review fixes
2023-12-06 16:59:45 +01:00
Roman Titov
4c14eae798 Improve abort/cancellation support for shard transfer (#2926)
* Ensure shard snapshot methods and API are cancel safe

* Remove resolved TODOs

* Extend comment on why we don't unproxify queue in a normal way

* fixup! Remove resolved TODOs

* Restructure `spawn_transfer_task`

* Update lib/collection/src/shards/transfer/shard_transfer.rs

Co-authored-by: Roman Titov <ffuugoo@users.noreply.github.com>

* fixup! Restructure `spawn_transfer_task`

Make `spawn_transfer_task` more readable

---------

Co-authored-by: timvisee <tim@visee.me>
Co-authored-by: Tim Visée <tim+github@visee.me>
2023-12-06 16:59:21 +01:00
Roman Titov
eb9466fd67 Add custom TLS certificate support for remote snapshot downloads to snapshot recover APIs (#2895)
* WIP: Add proper HTTPS support for remote snapshot downloads to snapshot recover APIs

* Implement HTTPS client configuration

* fixup! Implement HTTPS client configuration

Move HTTPS client configuration from `actix/certificate_helpers.rs` to
`common/http_client.rs`

* Initialize and propagate HTTPS client to shard snapshot API

* Use reqwest client reference where possible

* Add integration test

* Simplify HTTP(S) client initialization

* fixup! Simplify HTTP(S) client initialization

* Fix lifetime conflicts after rebase on dev

* Add comment to elaborate on PEM concatenation

* fixup! Add integration test

Add `test_tls_snapshot_shard_transfer.sh` run to the existing TLS test job
instead of creating a new one

---------

Co-authored-by: timvisee <tim@visee.me>
2023-12-06 16:59:15 +01:00
Andrey Vasnetsov
816b5a7448 Shard key routing for update requests (#2909)
* add shard_key into output data structures for points

* fmt

* add shard selector for point update operations

* fix creating index without sharding

* Merge serde attributes

* Code review changes

* review fixes

* upd openapi

---------

Co-authored-by: timvisee <tim@visee.me>
2023-12-06 16:58:27 +01:00
Luis Cossío
91eb3f36e2 Discovery API (#2861)
* create and connect discovery http and grpc interfaces

* add openapi tests

* fix bad rebase

* Add better descriptions

* remove numpy from openapi tests

* fix rebase artifact

* remove already addressed TODO

* add more tests

* 🤡🔫 (cfg batch handler)

* add timeout query param for discover requests

* More gRPC validation

* make fields pydantic_openapi_generator_v3 friendly

* `context_pairs` -> `context` with struct for pairs

* discovery api is only discovery or context,
move struct description to fields

---------

Co-authored-by: timvisee <tim@visee.me>
2023-12-06 16:57:14 +01:00