Commit Graph

27 Commits

Author SHA1 Message Date
Andrey Vasnetsov
076aa13399 HTTPS snapshot links (#8095)
* [manual] generate snapshot download link with respect of enabled tls

* Simplify http(s) selection

---------

Co-authored-by: Tim Visée <tim+github@visee.me>
2026-02-10 18:13:15 +01:00
Andrey Vasnetsov
921b1ce83d Prevent unoptimized updates (#7643)
* wip: wait for optimization before applying update

* implement api parameter

* nits

* fix deadloack when no optimizers are running

* release handle mutex

* Derive PartialEq

* Remove unused function

* fix missing kb conversion in threshold

* Update lib/api/src/grpc/proto/collections.proto

Co-authored-by: Tim Visée <tim+github@visee.me>

* sync comment change

---------

Co-authored-by: Arnaud Gourlay <arnaud.gourlay@gmail.com>
Co-authored-by: timvisee <tim@visee.me>
Co-authored-by: Tim Visée <tim+github@visee.me>
2026-01-14 16:37:03 +01:00
Andrey Vasnetsov
dba26be155 Merge pull request #7835
* alt api key

* rm typo

* fix key length check logic

* differnt dirs for tests

* fix tests

* rm unused
2026-01-02 13:18:53 +01:00
Andrey Vasnetsov
152172f143 refactor replica set (#7706)
* peer-id change on snapshot recovery

* move peer state management into a dedicated file
2025-12-09 14:09:52 +01:00
Andrey Vasnetsov
e744bd6014 implement custom collection metadata (#7123)
* implement custom collection metadata

* persist metadata change

* Also unset a key in the test

---------

Co-authored-by: timvisee <tim@visee.me>
2025-08-26 11:49:17 +02:00
Kumar Shivendu
34e18eb22c Allow retaining more closed segments (#6976)
* Retain more closed segments

* Add back rocksdb

* Update WalOptions/WalConfig across the code

* Use NonZeroUsize

* Expose via APIs

* Update gRPC docs

* Fix stoarge compat test

* recompile openapi.json with rocksdb

* default wal retain closed fn

* update openapi.json

* Use qdrant/wal latest commit and remove from config.yaml
2025-08-07 13:44:26 +02:00
Tim Visée
a5869beb99 Deprecations for Qdrant 1.15.0 (#6892)
* Deprecate init_from

* Mark memmap_threshold as deprecated

* Mark locks API as deprecated

* Mark RBAC collection access payload filter as deprecated

* Allow deprecations in tests and benchmarks
2025-07-17 16:10:45 +02:00
Arnaud Gourlay
21dd277213 Use CollectionResult where possible (#6463) 2025-04-30 09:49:04 +02:00
Tim Visée
5aead9c99b Fix consensus snapshot not applying shard key mappings (#6212)
* Propagate shard key mapping wrapper deeper

* Also bump reverse shard mapping when applying shard keys from snapshot

* Also apply new shard key mappings to existing replicas

* Apply shard key to replica set through apply_state directly

* Set both new shard key mappings through utility function

* Set shard key mappings directly during directory creation

* Rename get_key to key

* Update comment
2025-03-21 09:33:42 +01:00
Tim Visée
3e536347e1 Bump Rust edition to 2024 (#6042)
* Bump Rust edition to 2024

* gen is a reserved keyword now

* Remove ref mut on references

* Mark extern C as unsafe

* Wrap unsafe function bodies in unsafe block

* Geo hash implements Copy, don't reference but pass by value instead

* Replace secluded self import with parent

* Update execute_cluster_read_operation with new match semantics

* Fix lifetime issue

* Replace map_or with is_none_or

* set_var is unsafe now

* Reformat
2025-02-25 11:21:25 +01:00
Andrey Vasnetsov
f7d0814ab6 IO resource usage permit (#6015)
* rename cpu_budget -> resource_budget

* clippy

* add io budget to resources

* fmt

* move budget structures into a separate file

* add extend permit function

* dont extend existing permit

* switch from IO to CPU permit

* do not release resource before aquiring an extension

* fmt

* Review remarks

* Improve resource permit number assertion

* Make resource permit replace_with only acquire extra needed permits

* Remove obsolete drop implementation

* allocate IO budget same as CPU

* review fixes

---------

Co-authored-by: timvisee <tim@visee.me>
2025-02-20 09:05:00 +01:00
Roman Titov
7e7348613e Add UUID to collection config (#5378)
* Add UUID to collection...

...and recreate collection, when applying Raft snapshot, if UUID of collection is different

* fixup! Add UUID to collection...

Remove UUID field from gRPC and exclude it from OpenAPI spec 🤡

* fixup! fixup! Add UUID to collection...

Always generate collection UUID 🤦‍♀️

* Raft snapshot recreate collection no expose UUID (#5452)

* separate colleciton config structure from API

* fmt

* Update lib/collection/src/operations/types.rs

Co-authored-by: Tim Visée <tim+github@visee.me>

---------

Co-authored-by: Tim Visée <tim+github@visee.me>

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
Co-authored-by: Tim Visée <tim+github@visee.me>
2024-11-15 19:03:50 +01:00
Tim Visée
4989630d8b Fix killing replicas too earily on state switches (#5343)
* Send current replica state with disable replica proposals

* Don't be strict about from state if in shard transfer related state

* Link to PR, update formatting

* Fix typo

* Fix test compilation failures

* Provide peer state when deactivating leader, remove unnecessary TODO

* ReplicaState is Copy
2024-11-01 20:19:16 +01:00
Jojii
e9bad464ff [Strict-Mode] Basic implementation (#4887)
* add CollectionRequestVerification

* add to api

* rebase

* improve implementation

* implement strict mode for SearchRequest+Batch

* improve code + fix Clippy

* improve error handling

* restructure StrictModeVerification trait

* generate docs

* check `enabled` option

* review remarks

* rename StrictModeConfigDiff in grpc

* use missing payload detection from issue api

* performance improvement

* decouple extractor from issues (#4945)

* some review remarks

* don't default to empty functions in StrictModeVerification trait

* update openapi

* filter_limit => query_limit

* replace discovery_max_context_size and recommend_max_examples with max_input_examples

* review remarks

* review fix: include possible index types into error message

* review remarks

---------

Co-authored-by: Luis Cossío <luis.cossio@qdrant.com>
Co-authored-by: generall <andrey@vasnetsov.com>
2024-08-29 10:49:23 +02:00
Arnaud Gourlay
8fd1f3c192 Remove unecessary Clippy allows (#4456) 2024-06-12 17:11:09 +02:00
Jojii
3005de2a01 Add optimizer_overwrite config option (#4317)
* add config option

* add optimizers_config to optimizer calls

* also add for tests

* add to build_optimizers

* rename function parameter
2024-05-31 09:02:44 +02:00
xzfc
cb31c533bf Introduce Cargo feature "testing" (#4192) 2024-05-07 16:14:46 +00:00
Tim Visée
8723b7e93e Add API key field to snapshot restore, fix snapshot recovery with API key (#4155)
* Add API key to HTTP client

* Add API key field to snapshot recovery requests

* Add API key to channel service

* Provide API key when doing snapshot transfer

* Configure API key header name constant in a central place

* Reformat

* Update OpenAPI spec

* Remove suffixed spaces from configuration file

* Allow to specify HTTP headers in some consensus test utility functions

* Add snapshot transfer test with configured API key

* Use random API key in test

* Fix compilation errors and clippy warnings
2024-05-02 17:10:34 +02:00
Andrey Vasnetsov
44f2744d74 Byte storage api support (#4065)
* wip: include datatype in vector params API

* generate api schemas

* propagate datatype to segment creation

* fix review

* fmt
2024-04-18 15:22:28 +02:00
xzfc
0ed86ce057 Introduce JsonPathString (#3674)
* Introduce JsonPathString

* Fix fomatting
2024-02-23 15:38:40 +01:00
Tim Visée
56171c6087 Dynamic CPU saturation integration (#3115)
* Integrate dynamic CPU saturation with public API changes

This reverts commit 08930fefa9.

* Call num_cpus only once
2024-02-05 14:08:02 +01:00
Luis Cossío
b0aab16b0d 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-02-04 18:46:22 +01:00
Tim Visée
0301e39943 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-01-31 11:56:34 +01:00
Roman Titov
47f18f0bf7 Abort shard transfer during sync_local_state, if transfer-sender node failed (#2975, #3012) 2023-11-21 16:23:04 +01:00
Tim Visée
c75eae0c4a Shard snapshot transfer integration (#2467)
* Clone inside blocks

* Add shard transfer method to distinguish between batching and snapshots

* Add stub method to drive snapshot transfer

* Store remote shard in forward proxy, merge unproxy methods

* On snapshot shard transfer, create a shard snapshot

* Unify logic for unproxifying forward and queue proxy

* Error snapshot transfer if shard is not a queue proxy

* Add remote shard function to request remote HTTP port

* Handle all specific shard types when proxifying

* Allow queue proxy for some shard holder snapshot methods

* Bring local and remote shard snapshot transfer URLs into transfer logic

* Expose optional shard transfer method parameter in REST and gRPC API

* Expose shard transfer method in list of active transfers

* Fix off-by-one error in queue proxy shard batch transfer logic

* Do not set max ack version for WAL twice, already set when finalizing

* Merge comment for two similar calls

* Use reqwest client to transfer and recover shard snapshot on remote

Using the reqwest client should be temporary. We better switch to a gRPC
call here eventually to use our existing channels. That way we don't
require an extra HTTP client (and dependency) just for this.

* Send queue proxy updates to remote when shard is transferred

* On shard queue transfer, set max WAL ack to last transferred

* Add safe queue proxy destructor, skip destructing in error

This adds a finalize method to safely destruct a queue proxy shard. It
ensures that all remaining updates are transferred to the remote, and
that the max acknowledged version for our WAL is released. Only then is
the queue proxy shard destructed unwrapping the inner local shard.

Our unproxify logic now ensures that the queue proxy shard remains if
transferring the updates fails.

* Clean up method driving shard snapshot transfer a bit

* Change default shard transfer method to stream records

This changes the default transfer method to stream records rather than
using a snaphsot transfer. We can switch this once snapshot transfer is
fully integrated.

* Improve error handling, don't panic but return proper error

* Do not unwrap in type conversions

* Update OpenAPI and gRPC specification

* Resolve and remove some TODOs

* During shard snapshot transfer, use REST port from config

* Always release max acknowledged WAL version on queue proxy finalize

* Rework queue unproxying, transform into forward proxy to handle errors

When a queue or forward proxy shard needs to be unproxified into a local
shard again we typically don't have room to handle errors. A queue proxy
shard may error if it fails to send updates to the remote shard, while a
forward proxy does not fail at all when transforming.

We now transfer queued updates before a shard is unproxified. This
allows for proper error handling. After everything is transferred the
shard is transformed into a forward proxy which can eventually be safely
unproxified later.

* Add trace logging for transferring queue proxy updates in batch

* Simplify snapshot method conversion from gRPC

* Remove remote shard parameter

* Add safe guard to queue proxy handler, panic in debug if not finalized

* Improve safety and architecture of queue proxy shard

Switch from an explicit finalized flag to an outer-inner architecture.
This improves the interface and robustness of the type.

* Do not panic on drop if already unwinding

* Make REST port interface in channel service for local node explicitly

* Recover shard on remote over gRPC, remove reqwest client

* Use shard transfer priority for shard snapshot recovery

* Remove obsolete comment

* Simplify qualified path with use

* Don't construct URLs ourselves as a string, use `parse` and `set_port`

* Use `set_path` when building shard download URL

* Fix error handling in queue to forward proxy transformation

Before, we didn't handle finalization errors properly. If this failed,
tie shard would be lost.  With this change the queue proxy shard is put
back.

* Set default shard transfer method to stream records, eliminate panics

* Fix shard snapshot transfer not correctly aborting due to queue proxy

When a shard transfer fails (for any reason), the transfer is aborted.
If we still have a queue proxy shard it should also be reverted, and
collected updates should be forgotten. Before this change it would try
to send all collected updates to the remote, even if the transfer
failed.

* Review fixes

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

* Review fixes

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

* Initiate forward and queue proxy shard in specialized transfer methods

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

* Add consensus interface to shard transfer, repurpose dispatcher (#2873)

* Add shard transfer consensus interface

* Integrate shard transfer consensus interface into toc and transfer logic

* Repurpose dispatcher for getting consensus into shard transfer

* Derive clone

* Mark consensus as unused for now

* Use custom dispatcher with weak ref to prevent Arc cycle for ToC

* Add comment on why a weak reference is used

* Do exhaustive match in shard unproxy logic

* Restructure match statement, use match if

* When queue proxifying shard, allow forward proxy state if same remote

* Before retrying a shard transfer after error, destruct queue proxy

* Synchronize consensus across all nodes for shard snapshot transfer (#2874)

* Move await consensus commit functions into channel service

* Add shard consensus method to synchronize consensus across all nodes

* Move transfer config, channels and local address into snapshot transfer

* Await other nodes to reach consensus before finalizing shard transfer

* Do not fail right away awaiting consensus if still on older term

Instead, give the node time to reach the same term.

* Fix `await_commit_on_all_peers` not catching peer errors properly

* Change return type of `wait_for_consensus_commit` to `Result`

This is of course more conventional, and automatically sets `must_use`.

* Explicitly note number of peers when awaiting consensus

* Before consensus sync, wait for local shard to reach partial state

* Fix timeout error handling when waiting for replica set state

* Wait for replica set to have remote in partial state instead

* Set `(Partial)Snapshot` states for shard snapshot transfer through consensus (#2881)

* When doing a shard snapshot transfer, set shard to `PartialSnapshot`

* Add shard transfer method to set shard state to partial

It currently uses a naive implementation. Using a custom consensus
operation to also confirm a transfer is still active will be implemented
later.

* Add consensus snapshot transfer operation to change shard to partial

The operation `ShardTransferOperations::SnapshotRecovered` is called
after the shard snapshot is recovered on the remote and it progresses
the transfer further.

The operation sets the shard state from `PartialSnapshot` to `Partial`
and ensures the transfer is still active.

* Confirm consensus put shard into partial state, retry 3 times

* Get replica set once

* Add extensive shard snapshot transfer process docs, clean up function

* Fix typo

* Review suggestion

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

* Add delay between consensus confirmation retries

* Rename retry timeout to retry delay

---------

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

* On replicate shard, remember specified method

---------

Co-authored-by: Roman Titov <ffuugoo@users.noreply.github.com>
Co-authored-by: Luis Cossío <luis.cossio@qdrant.com>
2023-10-30 12:44:39 +01:00
Roman Titov
789992d3f7 Fan out read operations if local shard is updated (#2642)
* Fan-out read operations if local shard is being updated

* Implement `is_update_in_progress` check for all shard types

* fixup! Implement `is_update_in_progress` check for all shard types

Reverse conditional 🤦‍♀️

* WIP: Add `read_fan_out_factor` collection parameter...

...and refactor `execute_read_operation`/`execute_and_resolve_read_operation` to use it reasonably

* WIP: Refactor `info` and `count` requests to utilize `read_fan_out_factor` properly

* fixup! WIP: Refactor `info` and `count` requests to utilize `read_fan_out_factor` properly

Fix typo

* fixup! WIP: Add `read_fan_out_factor` collection parameter...

Initialize `read_fan_out_factor` in tests

* fixup! WIP: Add `read_fan_out_factor` collection parameter...

Add `TODO` marker (:

* fixup! WIP: Add `read_fan_out_factor` collection parameter...

* fixup! fixup! WIP: Add `read_fan_out_factor` collection parameter...

* fixup! fixup! fixup! WIP: Add `read_fan_out_factor` collection parameter...

🤦‍♀️

* Add `read_fan_out_factor` to required HTTP and gRPC APIs

* WIP: Generate OpenAPI spec and gRPC docs

* fixup! Add `read_fan_out_factor` to required HTTP and gRPC APIs

* fixup! WIP: Add `read_fan_out_factor` collection parameter...

Fix the comment

* Add documentation

* fixup! Add documentation

Update OpenAPI spec and gRPC docs

* optional param by default + comment

* fmt

* rollback test fixes

* review changes

* fmt

* revert api changes

* upd openapi

* upd comment

* fix info api

* resolve merge conflicts

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2023-09-22 21:56:10 +02:00
Arnaud Gourlay
2763ecff0a merge integration binaries (collection) (#2037) 2023-06-07 11:32:00 +02:00