Commit Graph
23 Commits
Author SHA1 Message Date
Arnaud GourlayandClaude Opus 5 5b338115f2 Replace cgroups-rs with direct cgroup memory file reads (#10295)
* Replace cgroups-rs with direct cgroup memory file reads

We used cgroups-rs in exactly one place, to read the memory limit and
usage of our own cgroup, so read those files directly instead. Drops 34
crates from the lockfile, including the zbus stack that carries
RUSTSEC-2026-0221.

Also fixes two latent cgroup v1 bugs (the LONG_MAX unlimited sentinel
reported ~9 EB of total memory, an unreadable limit file reported 0
bytes) and the hierarchy mix-up on hybrid hosts.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Decline cgroup memory reporting when the usage read fails

Reporting a usage of 0 made available_memory_bytes claim the whole cgroup
limit as free. Fall back to sysinfo when the usage file cannot be read at
init, and keep the last known value on a failed refresh.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Keep the last known memory limit when its read fails

A transient read failure cleared the cached limit and silently fell back
to host memory while the process was still capped, the same direction of
over-reporting as the usage read. Both now keep their last known value,
and a limit lifted at runtime still clears.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Treat a malformed memory limit as an error, not as unlimited

Parse failures returned Ok(None), so garbage in the limit file cleared a
valid cached limit on refresh and read as unlimited at init. Reserve
Ok(None) for "max" and the v1 sentinel, and report anything else as
InvalidData so the last known limit survives.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 15:08:00 +02:00
Kumar ShivenduandClaude Opus 4.8 7743616b3b Report effective (cgroup) CPU, RAM and disk in telemetry (#9891)
* Report effective (cgroup) CPU, RAM and disk in telemetry

The `system` block reported host-level figures that ignore the limits the
kernel actually enforces on the process:

- `cores`     <- sys_info::cpu_num()   (host socket count)
- `ram_size`  <- sys_info::mem_info()  (host total RAM)
- `disk_size` <- sys_info::disk_info() (container root fs)

On any cgroup-limited deployment (containers, Kubernetes pods, systemd
slices) these overstate what Qdrant can use, are misleading for capacity /
oversubscription analysis, and don't match how Qdrant sizes itself.

Report the effective values instead, reusing existing helpers:

- `cores`     -> common::cpu::get_num_cpus()          (already drives sizing)
- `ram_size`  -> segment::utils::mem::total_memory_bytes()
                 (cgroup limit via cgroups_rs, else sysinfo host total)
- `disk_size` -> common::disk_usage::disk_usage(storage_path)
                 (data-volume capacity, cached; sys_info host disk fallback)

`Mem::new()` is not free (it builds a sysinfo System and loads the cgroup
memory controller), so `total_memory_bytes()` caches with a 5s TTL — matching
the disk-usage cache — instead of recomputing per call. The TTL (rather than
caching once) means an in-place cgroup memory resize is reflected within a few
seconds, consistent with how `disk_size` and `cores` already behave. The
strict-mode helper in `collection` now delegates to this shared accessor
(dropping its own OnceLock), so it too becomes resize-aware.

ram_size/disk_size stay in KiB to match the previous unit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Simplify comments and code

* Simplify openapi spec

* minor comment improve

* mem: cache total_memory_bytes like disk_usage (5s TTL)

`total_memory_bytes()` mirrors `common::disk_usage::disk_usage`: a small 5s
TTL cache over `Mem::new().total_memory_bytes()`. `Mem::new()` is not free
(builds a sysinfo System + loads the cgroup controller), and the short TTL
keeps the value in step with an in-place cgroup memory resize rather than
freezing at startup. Shared by telemetry and strict-mode, like the disk cache.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Regenerate OpenAPI spec

Add the ram_size / disk_size field descriptions produced by schemars from the
updated telemetry doc comments, keeping the generated spec consistent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* mem: address review — parking_lot mutex, hold lock, saturating_duration_since

- Use parking_lot::Mutex (no poisoning; lock() returns the guard directly).
- Hold the lock across the whole method — single acquisition, simpler.
- saturating_duration_since instead of duration_since (no panic on a cached
  timestamp spuriously ahead of now).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-02 14:31:06 +02:00
dependabot[bot]andCursor Agent 328a6d8819 build(deps): bump cgroups-rs from 0.3.4 to 0.5.0 (#8270)
* build(deps): bump cgroups-rs from 0.3.4 to 0.5.0

Bumps [cgroups-rs](https://github.com/kata-containers/cgroups-rs) from 0.3.4 to 0.5.0.
- [Release notes](https://github.com/kata-containers/cgroups-rs/releases)
- [Commits](https://github.com/kata-containers/cgroups-rs/compare/v0.3.4...v0.5.0)

---
updated-dependencies:
- dependency-name: cgroups-rs
  dependency-version: 0.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* fix: use cgroups_rs::fs API for cgroups-rs 0.5 compatibility

Made-with: Cursor

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Cursor Agent <agent@cursor.com>
2026-03-03 14:50:28 +01:00
xzfc a0d62330c7 Use fs-err (#7319) 2025-09-29 12:47:10 +00:00
Arnaud Gourlay 255dd51e5a Fix Clippy 1.89 (#6981) 2025-08-05 18:06:04 +02:00
Andrey VasnetsovandArnaud Gourlay f47e499825 fix check for pure primary condition filter (#6840)
* fix check for pure primary condition filter

* avoid cloning has_id for primary condition

* fix test

* add test

---------

Co-authored-by: Arnaud Gourlay <arnaud.gourlay@gmail.com>
2025-07-10 11:40:11 +02:00
Jojii 64364f37b3 Fix enormous memory usage in Distance Matrix API on high sample size (#6640)
* Fix memory leak in distance API

* Add tests
2025-06-05 17:46:26 +02: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
dependabot[bot]andArnaud Gourlay 91360f5ee8 build(deps): bump sysinfo from 0.32.1 to 0.33.0 (#5623)
* build(deps): bump sysinfo from 0.32.1 to 0.33.0

Bumps [sysinfo](https://github.com/GuillaumeGomez/sysinfo) from 0.32.1 to 0.33.0.
- [Changelog](https://github.com/GuillaumeGomez/sysinfo/blob/master/CHANGELOG.md)
- [Commits](https://github.com/GuillaumeGomez/sysinfo/commits)

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

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

* fix api change

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Arnaud Gourlay <arnaud.gourlay@gmail.com>
2024-12-16 14:08:08 +01:00
Arnaud Gourlay b6caf4e55b Clippy 1.83 (#5513)
* Clippy 1.83

* there is more
2024-11-27 11:24:58 +01:00
xzfc 761069bc0a Restore SnapshotFormat::Streamable snapshots (#5179) 2024-10-04 16:39:56 +00:00
xzfc 98c4e605ae Support SnapshotFormat::Streamable, add REST endpoint (#5178) 2024-10-04 16:36:19 +00:00
Arnaud Gourlay b2d22c9792 Remove unecessary clippy allow deadcode (#5033) 2024-09-06 12:04:49 +02:00
xzfc a0ea3caccf Enable some of the pedantic clippy lints (#4715)
* Use workspace lints

* Enable lint: manual_let_else

* Enable lint: enum_glob_use

* Enable lint: filter_map_next

* Enable lint: ref_as_ptr

* Enable lint: ref_option_ref

* Enable lint: manual_is_variant_and

* Enable lint: flat_map_option

* Enable lint: inefficient_to_string

* Enable lint: implicit_clone

* Enable lint: inconsistent_struct_constructor

* Enable lint: unnecessary_wraps

* Enable lint: needless_continue

* Enable lint: unused_self

* Enable lint: from_iter_instead_of_collect

* Enable lint: uninlined_format_args

* Enable lint: doc_link_with_quotes

* Enable lint: needless_raw_string_hashes

* Enable lint: used_underscore_binding

* Enable lint: ptr_as_ptr

* Enable lint: explicit_into_iter_loop

* Enable lint: cast_lossless
2024-07-22 08:19:19 +00:00
Luis Cossíoandgenerall 57aee5addf universal-query: Impl of query_internal in collection (#4331)
* move ScoredPointTies to segment, make inner by reference

* `query_internal` implementation

* remove empty utils mod

* use `then_with`

* Improve readability, remove duplicated code

* refactoring suggestions

* don't collect eagerly

* remove unused import

* dont panic on empty transpose input

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-05-31 08:56:06 -04:00
Tim Visée a54d86df54 Bump sysinfo to 0.30.3 (#3310)
* Bump sysinfo to 0.30.3

* Remove redundant refresh, new_with_specifics already refreshes
2024-01-04 12:22:47 +01:00
Arnaud Gourlay 2e4729a1f3 Promote operation error to dedicated file (#2736) 2023-09-29 16:23:24 +02:00
Andrey Vasnetsov 0f10a7c635 check integrity of snapshot (#2122)
* check integrity of snapshot

* rename check_symlinks to find_symlink
2023-06-21 17:02:31 +02:00
Tim 0ca6c647e1 Fix warnings pointed out by cargo doc (#1997) 2023-06-05 10:20:21 +02:00
Roman TitovandAndrey Vasnetsov 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
Roman Titov e240740ff3 Fix payload index snapshot restoration (#1775) 2023-04-24 21:41:11 +02: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
Roman TitovandAndrey Vasnetsov ced0abb4c7 Fix segment snapshotting (#1321) (#1334)
* WIP: Fix `Segment::take_snapshot`

TODO:
- This commit, probably, breaks snapshotting of segments with memmapped vector storage
- `ProxySegment::take_snapshot` seems to potentially similar bug

* WIP: Fix `Segment::take_snapshot`

- Fix snapshotting of `StructPayloadIndex`
- Fix snapshotting of segments with memmapped vector storage
- Temporarily break `ProxySegment::take_snapshot`

* Fix `ProxySegment::take_snapshot`

* Remove `copy_segment_directory` test

* nitpicking

* clippy fixes

* use OperationError::service_error

* Cleanup `TinyMap` trait bounds and derive `Debug`

* Fix `test_snapshot` test

- Derive `Debug` for `NamedVectors`

* Move utility functions from `segment.rs` to `utils` module

* Contextualize `segment::utils::fs::move_all` a bit more carefully

* Fix a typo

* add backward compatibility with old snapshot formats

* fmt

* add snapshot for compatibility test

* git lfs is a piece of shit

* Nitpicking

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-01-13 11:44:42 +01:00