Compare commits

..
8 changed files with 216 additions and 457 deletions

No files matched your search

@@ -46,6 +46,6 @@
- Fixed signing in to a mailbox when your username or password contains characters beyond ASCII, such as umlauts, accents, or Asian characters. Depending on its configuration, a mail server may expect them in another encoding than UTF-8. You can now choose the encoding in the server details of the mailbox, and after a failed sign-in, AI Studio offers to test the connection once more with the encoding common in your region. - Fixed signing in to a mailbox when your username or password contains characters beyond ASCII, such as umlauts, accents, or Asian characters. Depending on its configuration, a mail server may expect them in another encoding than UTF-8. You can now choose the encoding in the server details of the mailbox, and after a failed sign-in, AI Studio offers to test the connection once more with the encoding common in your region.
- Upgraded several libraries to improve security. - Upgraded several libraries to improve security.
- Upgraded Tauri to v2.12.7. - Upgraded Tauri to v2.12.7.
- Upgraded PDFium to v158.0.8125.0. - Upgraded PDFium to v158.0.8125.0 and Qdrant Edge to v0.9.0.
- Upgraded to Rust v1.100.0. - Upgraded to Rust v1.100.0.
- Upgraded to .NET v10.0.15. - Upgraded to .NET v10.0.15.
@@ -1,7 +1,8 @@
# Qdrant Edge WAL Compaction # Qdrant Edge WAL Compaction
- Status: Active - Status: Removed
- Introduced: 2026-10-09 - Introduced: 2026-10-09
- Removed: 2026-11-24, with qdrant-edge 0.9.0, which acknowledges its WAL in `EdgeShard::flush` ([qdrant/qdrant#11082](https://github.com/qdrant/qdrant/pull/11082)). Stores of older versions get their WAL marked as acknowledged instead, see `2026-11-qdrant-edge-legacy-wal.md`.
- Remove after: when a qdrant-edge release acknowledges its WAL in `EdgeShard::flush` by itself, see [qdrant/qdrant#11068](https://github.com/qdrant/qdrant/issues/11068) - Remove after: when a qdrant-edge release acknowledges its WAL in `EdgeShard::flush` by itself, see [qdrant/qdrant#11068](https://github.com/qdrant/qdrant/issues/11068)
- Code references: - Code references:
- `runtime/src/qdrant_edge_database.rs` (`compact_wal`, `has_obsolete_wal_segments`, `remove_obsolete_wal_segments`, `wal_file_names`, `obsolete_wal_segments`, `optimize_store`) - `runtime/src/qdrant_edge_database.rs` (`compact_wal`, `has_obsolete_wal_segments`, `remove_obsolete_wal_segments`, `wal_file_names`, `obsolete_wal_segments`, `optimize_store`)
@@ -0,0 +1,27 @@
# Qdrant Edge Legacy WAL
- Status: Active
- Introduced: 2026-11-24
- Remove after: when a qdrant-edge release skips the operations of the WAL which its segments already persisted when it loads a store
- Code references:
- `runtime/src/qdrant_edge_database.rs` (`acknowledge_legacy_wal`, `WAL_FIRST_INDEX_FILE`, `WAL_FIRST_INDEX_FILE_TEMP`)
## User Impact
Up to qdrant-edge 0.8.0, Qdrant Edge wrote every update of a vector store to its write-ahead log (WAL), but never acknowledged the WAL. Since 0.9.0, loading a store applies every operation of the WAL again which is not marked as acknowledged. The first load of a store written by an older version of AI Studio therefore applies its whole WAL once more.
That WAL holds thousands of operations. Each deletion of a document in there reads and parses every payload of the store, because the fields it filters on have no payload index. For a real store of 317 MB with 20,316 operations in its WAL, the first load had not finished after more than 12 minutes. Meanwhile, every request to the vector database waits, and when the user quits AI Studio before the load is done, the next start begins again.
## Compatibility Behavior
Right before AI Studio loads a vector store, it checks whether the WAL directory of the store holds the file `first-index`, in which Qdrant Edge notes how far its WAL is acknowledged. A store of an older version lacks it, because Qdrant Edge 0.9 writes it only with the first flush after an update; so does a new store before its first update, whose WAL holds nothing to apply anyway. For such a store, AI Studio writes the file with the highest possible index, `{"ack_index":18446744073709551615}`, through a temporary file. Qdrant Edge lowers this index to the last entry of the WAL when it opens the WAL, so loading the store applies only that one operation once more.
This is safe because AI Studio flushes after every update, so the segments already hold everything the WAL contains, and because qdrant-edge 0.8 never applied its WAL anyway. A failed write is logged as a warning and does not block loading the store; the load then takes long, but nothing gets lost. The file has the same format in qdrant-edge 0.8 and 0.9, so an older version of AI Studio still opens the store.
## Removal Checklist
- Check that the new qdrant-edge release no longer applies operations which the segments already persisted, e.g., by starting the WAL replay at the highest version the segments persisted.
- Remove `acknowledge_legacy_wal` and the constants `WAL_FIRST_INDEX_FILE` and `WAL_FIRST_INDEX_FILE_TEMP`, unless the tests still need them.
- Remove the `acknowledge_legacy_wal` calls from `get_or_create_store` and `get_existing_store`.
- Remove the test `a_store_of_an_older_version_gets_its_wal_acknowledged_and_keeps_its_points`, and keep `an_acknowledged_wal_stays_as_it_is` only if it still checks something of AI Studio.
- Update this document's status to `Removed`.
+1 -1
View File
@@ -8,4 +8,4 @@
2.12.7 2.12.7
9d1768e2f40, release 9d1768e2f40, release
158.0.8125.0 158.0.8125.0
0.8.0 0.9.0
+61 -256
View File
@@ -245,15 +245,6 @@ dependencies = [
"syn 2.0.119", "syn 2.0.119",
] ]
[[package]]
name = "arrayvec"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9"
dependencies = [
"nodrop",
]
[[package]] [[package]]
name = "arrayvec" name = "arrayvec"
version = "0.7.8" version = "0.7.8"
@@ -583,7 +574,7 @@ dependencies = [
"aligned", "aligned",
"anyhow", "anyhow",
"arg_enum_proc_macro", "arg_enum_proc_macro",
"arrayvec 0.7.8", "arrayvec",
"log", "log",
"num-rational", "num-rational",
"num-traits", "num-traits",
@@ -601,7 +592,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cfddb07216410377231960af4fcab838eaa12e013417781b78bd95ee22077f8" checksum = "8cfddb07216410377231960af4fcab838eaa12e013417781b78bd95ee22077f8"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arrayvec 0.7.8", "arrayvec",
"log", "log",
"nom 8.0.0", "nom 8.0.0",
"num-rational", "num-rational",
@@ -614,7 +605,7 @@ version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7178fe5f7d460b13895ebb9dcb28a3a6216d2df2574a0806cb51b555d297f38" checksum = "e7178fe5f7d460b13895ebb9dcb28a3a6216d2df2574a0806cb51b555d297f38"
dependencies = [ dependencies = [
"arrayvec 0.7.8", "arrayvec",
] ]
[[package]] [[package]]
@@ -806,12 +797,6 @@ dependencies = [
"bit-vec 0.10.2", "bit-vec 0.10.2",
] ]
[[package]]
name = "bit-vec"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
[[package]] [[package]]
name = "bit-vec" name = "bit-vec"
version = "0.8.0" version = "0.8.0"
@@ -893,16 +878,6 @@ dependencies = [
"wyz", "wyz",
] ]
[[package]]
name = "blake2-rfc"
version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400"
dependencies = [
"arrayvec 0.4.12",
"constant_time_eq 0.1.5",
]
[[package]] [[package]]
name = "blink-alloc" name = "blink-alloc"
version = "0.4.0" version = "0.4.0"
@@ -1012,6 +987,12 @@ version = "3.20.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db" checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db"
[[package]]
name = "bytecount"
version = "0.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "175812e0be2bccb6abe50bb8d566126198344f707e304f45c648fd8f2cc0365e"
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
version = "1.25.2" version = "1.25.2"
@@ -1179,9 +1160,9 @@ dependencies = [
[[package]] [[package]]
name = "cedarwood" name = "cedarwood"
version = "0.4.6" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d910bedd62c24733263d0bed247460853c9d22e8956bd4cd964302095e04e90" checksum = "c0524a528a6a0288df1863c3c20fe92c301875b4941e7b6c4b394ab08c5a4c55"
dependencies = [ dependencies = [
"smallvec", "smallvec",
] ]
@@ -1225,20 +1206,6 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
[[package]]
name = "cgroups-rs"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25ae79ba89081d30804e3312bb1163ab82cc8dca0a1b16275e55fb19fce4e89b"
dependencies = [
"bit-vec 0.6.3",
"libc",
"log",
"nix 0.25.1",
"thiserror 1.0.69",
"zbus",
]
[[package]] [[package]]
name = "chacha20" name = "chacha20"
version = "0.10.2" version = "0.10.2"
@@ -1252,9 +1219,9 @@ dependencies = [
[[package]] [[package]]
name = "charabia" name = "charabia"
version = "0.9.9" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51689ee7cc84c8de789fc2874711d816055b93406cfd4135c40d1c82dd24b928" checksum = "27d98f4c66de52108210ee491c9c991513021dfd259bf65e4bbd889687b488d7"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"csv", "csv",
@@ -1430,12 +1397,6 @@ version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a" checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a"
[[package]]
name = "constant_time_eq"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
[[package]] [[package]]
name = "constant_time_eq" name = "constant_time_eq"
version = "0.6.1" version = "0.6.1"
@@ -2145,11 +2106,6 @@ name = "duplicate"
version = "2.0.1" version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e92f10a49176cbffacaedabfaa11d51db1ea0f80a83c26e1873b43cd1742c24" checksum = "8e92f10a49176cbffacaedabfaa11d51db1ea0f80a83c26e1873b43cd1742c24"
dependencies = [
"heck 0.5.0",
"proc-macro2",
"proc-macro2-diagnostics",
]
[[package]] [[package]]
name = "dyn-clone" name = "dyn-clone"
@@ -2163,15 +2119,6 @@ version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a742b95783b1f45b900129082cbc47717b6a77ee8d17eea70a8ea62462f5de3" checksum = "4a742b95783b1f45b900129082cbc47717b6a77ee8d17eea70a8ea62462f5de3"
[[package]]
name = "earcut"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88459a2a8e3a514b6e6de38cf3aaa9250a894cb098f74a932db77fcc8341b6d0"
dependencies = [
"num-traits",
]
[[package]] [[package]]
name = "ebml-iterable" name = "ebml-iterable"
version = "0.6.3" version = "0.6.3"
@@ -2830,7 +2777,6 @@ version = "0.33.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30eb1fdc57c1e5cfd11826fe0caec4b9dc7901f3758263bb506228d88c8d9e9a" checksum = "30eb1fdc57c1e5cfd11826fe0caec4b9dc7901f3758263bb506228d88c8d9e9a"
dependencies = [ dependencies = [
"earcut",
"float_next_after", "float_next_after",
"geo-types", "geo-types",
"geographiclib-rs", "geographiclib-rs",
@@ -2842,7 +2788,6 @@ dependencies = [
"robust", "robust",
"rstar", "rstar",
"sif-itree", "sif-itree",
"spade",
] ]
[[package]] [[package]]
@@ -2853,10 +2798,8 @@ checksum = "777d18aa0f12f8b285331cd867133ee14422b3f023f6d388034c47d43e28786a"
dependencies = [ dependencies = [
"approx", "approx",
"num-traits", "num-traits",
"rayon",
"rstar", "rstar",
"serde", "serde",
"spade",
"thiserror 2.0.21", "thiserror 2.0.21",
] ]
@@ -3162,16 +3105,6 @@ version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hashbrown"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
dependencies = [
"ahash",
"allocator-api2 0.2.21",
]
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.15.5" version = "0.15.5"
@@ -3382,19 +3315,6 @@ dependencies = [
"tower-service", "tower-service",
] ]
[[package]]
name = "hyper-timeout"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0"
dependencies = [
"hyper",
"hyper-util",
"pin-project-lite",
"tokio",
"tower-service",
]
[[package]] [[package]]
name = "hyper-util" name = "hyper-util"
version = "0.1.21" version = "0.1.21"
@@ -3435,9 +3355,6 @@ name = "i_key_sort"
version = "0.10.3" version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d73d122b937fca067feb0ad74f62388920272b27c356d4df2d0cfdd59e044cf0" checksum = "d73d122b937fca067feb0ad74f62388920272b27c356d4df2d0cfdd59e044cf0"
dependencies = [
"rayon",
]
[[package]] [[package]]
name = "i_overlay" name = "i_overlay"
@@ -3449,7 +3366,6 @@ dependencies = [
"i_key_sort", "i_key_sort",
"i_shape", "i_shape",
"i_tree", "i_tree",
"rayon",
] ]
[[package]] [[package]]
@@ -3868,24 +3784,24 @@ dependencies = [
[[package]] [[package]]
name = "jieba-macros" name = "jieba-macros"
version = "0.8.1" version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "348294e44ee7e3c42685da656490f8febc7359632544019621588902216da95c" checksum = "455f837e9d0255b68a712200db247c68fdad4941b72471b76bfa61c3b0c1f79f"
dependencies = [ dependencies = [
"phf_codegen 0.13.1", "phf_codegen 0.13.1",
] ]
[[package]] [[package]]
name = "jieba-rs" name = "jieba-rs"
version = "0.8.1" version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "766bd7012aa5ba49411ebdf4e93bddd59b182d2918e085d58dec5bb9b54b7105" checksum = "b6a8bbb0f77ee810f0689a30b7cec56b875751ef4ec2e74fd995613dc52b3ae1"
dependencies = [ dependencies = [
"bytecount",
"cedarwood", "cedarwood",
"include-flate", "include-flate",
"jieba-macros", "jieba-macros",
"phf 0.13.1", "phf 0.13.1",
"regex",
"rustc-hash", "rustc-hash",
] ]
@@ -4661,18 +4577,6 @@ version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
[[package]]
name = "nix"
version = "0.25.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4"
dependencies = [
"autocfg",
"bitflags 1.3.2",
"cfg-if",
"libc",
]
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.31.4" version = "0.31.4"
@@ -4706,12 +4610,6 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "nodrop"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
[[package]] [[package]]
name = "nom" name = "nom"
version = "7.1.3" version = "7.1.3"
@@ -4811,6 +4709,17 @@ dependencies = [
"syn 2.0.119", "syn 2.0.119",
] ]
[[package]]
name = "num-derive"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4e98dc3b890f6c23a0f9d3d491a2823d0dea0fa656302a13dd225fa924112a8"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.10",
]
[[package]] [[package]]
name = "num-integer" name = "num-integer"
version = "0.1.47" version = "0.1.47"
@@ -5433,15 +5342,6 @@ version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
[[package]]
name = "permutation_iterator"
version = "0.1.2"
source = "git+https://github.com/SommerEngineering/permutation-iterator-rs.git?rev=76836ed316d18dfef530ba908f58481c343e80d7#76836ed316d18dfef530ba908f58481c343e80d7"
dependencies = [
"blake2-rfc",
"rand 0.8.8",
]
[[package]] [[package]]
name = "petgraph" name = "petgraph"
version = "0.6.5" version = "0.6.5"
@@ -5583,26 +5483,6 @@ dependencies = [
"siphasher", "siphasher",
] ]
[[package]]
name = "pin-project"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6c2123f4708bbd422630a6dae7c03f678b1ce1f1c99e4c4b3beac69c8174cc9"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "358938fd6df944c1e44bb328b60fb275f13c804aac47ba26a1165d45a3f87756"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.10",
]
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.2.18" version = "0.2.18"
@@ -5824,18 +5704,6 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "proc-macro2-diagnostics"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.119",
"version_check",
]
[[package]] [[package]]
name = "procfs" name = "procfs"
version = "0.18.0" version = "0.18.0"
@@ -5884,13 +5752,14 @@ checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea"
[[package]] [[package]]
name = "qdrant-edge" name = "qdrant-edge"
version = "0.8.0" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b8072302c87506a34bffec9bc16dbdcd36df8ab1321406b6e141530348c7e54" checksum = "0bf059f7c7f5145aea9b8ccfea3e6f9bcf7d0fd2440132a1489c02124473468c"
dependencies = [ dependencies = [
"ahash", "ahash",
"aligned-vec", "aligned-vec",
"arrayvec 0.7.8", "arc-swap",
"arrayvec",
"atomic_refcell", "atomic_refcell",
"atomicwrites", "atomicwrites",
"bincode 1.3.3", "bincode 1.3.3",
@@ -5900,7 +5769,6 @@ dependencies = [
"bytemuck", "bytemuck",
"byteorder", "byteorder",
"cc", "cc",
"cgroups-rs",
"charabia", "charabia",
"chrono", "chrono",
"core_affinity", "core_affinity",
@@ -5914,6 +5782,7 @@ dependencies = [
"fs-err", "fs-err",
"fs4", "fs4",
"fs_extra", "fs_extra",
"futures",
"geo", "geo",
"geohash", "geohash",
"half 2.7.1", "half 2.7.1",
@@ -5925,26 +5794,26 @@ dependencies = [
"log", "log",
"lz4_flex", "lz4_flex",
"macro_rules_attribute", "macro_rules_attribute",
"memchr",
"memmap2", "memmap2",
"murmur3_32", "murmur3_32",
"nix 0.31.4", "nix 0.31.4",
"nom 8.0.0", "nom 8.0.0",
"num-cmp", "num-cmp",
"num-derive", "num-derive 0.5.1",
"num-traits", "num-traits",
"num_cpus", "num_cpus",
"once_cell", "once_cell",
"ordered-float 5.5.1", "ordered-float 5.5.1",
"parking_lot", "parking_lot",
"permutation_iterator",
"ph", "ph",
"pin-project-lite",
"procfs", "procfs",
"qdrant-rust-stemmers", "qdrant-rust-stemmers",
"quick_cache", "quick_cache",
"rand 0.10.4", "rand 0.10.4",
"rand_distr", "rand_distr",
"rayon", "rayon",
"rmp-serde",
"roaring", "roaring",
"rustix 1.1.6", "rustix 1.1.6",
"schemars 0.8.22", "schemars 0.8.22",
@@ -5961,6 +5830,7 @@ dependencies = [
"slab", "slab",
"smallvec", "smallvec",
"strum", "strum",
"stumpalo",
"sysinfo", "sysinfo",
"tap", "tap",
"tar", "tar",
@@ -5969,12 +5839,12 @@ dependencies = [
"thread-priority", "thread-priority",
"tinyvec", "tinyvec",
"tokio", "tokio",
"tonic",
"uuid", "uuid",
"validator", "validator",
"vaporetto", "vaporetto",
"walkdir", "walkdir",
"zerocopy", "zerocopy",
"zstd",
] ]
[[package]] [[package]]
@@ -6066,8 +5936,6 @@ version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c"
dependencies = [ dependencies = [
"libc",
"rand_chacha 0.3.1",
"rand_core 0.6.4", "rand_core 0.6.4",
"serde", "serde",
] ]
@@ -6093,16 +5961,6 @@ dependencies = [
"rand_core 0.10.1", "rand_core 0.10.1",
] ]
[[package]]
name = "rand_chacha"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core 0.6.4",
]
[[package]] [[package]]
name = "rand_chacha" name = "rand_chacha"
version = "0.9.0" version = "0.9.0"
@@ -6129,7 +5987,6 @@ version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [ dependencies = [
"getrandom 0.2.17",
"serde", "serde",
] ]
@@ -6176,7 +6033,7 @@ dependencies = [
"aligned-vec", "aligned-vec",
"arbitrary", "arbitrary",
"arg_enum_proc_macro", "arg_enum_proc_macro",
"arrayvec 0.7.8", "arrayvec",
"av-scenechange", "av-scenechange",
"av1-grain", "av1-grain",
"bitstream-io", "bitstream-io",
@@ -6190,7 +6047,7 @@ dependencies = [
"maybe-rayon", "maybe-rayon",
"new_debug_unreachable", "new_debug_unreachable",
"noop_proc_macro", "noop_proc_macro",
"num-derive", "num-derive 0.4.2",
"num-traits", "num-traits",
"paste", "paste",
"profiling", "profiling",
@@ -6268,6 +6125,12 @@ dependencies = [
"yasna", "yasna",
] ]
[[package]]
name = "readme-rustdocifier"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08ad765b21a08b1a8e5cdce052719188a23772bcbefb3c439f0baaf62c56ceac"
[[package]] [[package]]
name = "realfft" name = "realfft"
version = "3.5.1" version = "3.5.1"
@@ -6442,25 +6305,6 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422" checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422"
[[package]]
name = "rmp"
version = "0.8.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ba8be72d372b2c9b35542551678538b562e7cf86c3315773cae48dfbfe7790c"
dependencies = [
"num-traits",
]
[[package]]
name = "rmp-serde"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72f81bee8c8ef9b577d1681a70ebbc962c232461e397b22c208c43c04b67a155"
dependencies = [
"rmp",
"serde",
]
[[package]] [[package]]
name = "roaring" name = "roaring"
version = "0.11.5" version = "0.11.5"
@@ -6591,7 +6435,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf"
dependencies = [ dependencies = [
"aws-lc-rs", "aws-lc-rs",
"log",
"once_cell", "once_cell",
"ring", "ring",
"rustls-pki-types", "rustls-pki-types",
@@ -7242,18 +7085,6 @@ dependencies = [
"system-deps", "system-deps",
] ]
[[package]]
name = "spade"
version = "2.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9699399fd9349b00b184f5635b074f9ec93afffef30c853f8c875b32c0f8c7fa"
dependencies = [
"hashbrown 0.16.1",
"num-traits",
"robust",
"smallvec",
]
[[package]] [[package]]
name = "spm_precompiled" name = "spm_precompiled"
version = "0.1.4" version = "0.1.4"
@@ -7371,6 +7202,16 @@ dependencies = [
"syn 2.0.119", "syn 2.0.119",
] ]
[[package]]
name = "stumpalo"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7087fbef8befbb581d82b2040acf5aae5c851f60427adfcc30fefd54124fb62"
dependencies = [
"readme-rustdocifier",
"rustc_version",
]
[[package]] [[package]]
name = "subtle" name = "subtle"
version = "2.6.1" version = "2.6.1"
@@ -8504,38 +8345,6 @@ version = "1.2.0+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "009dbb7700f11c55ef83aebbe4c0e9cf1f1ac0844bd8d6f00dc38f302026e13a" checksum = "009dbb7700f11c55ef83aebbe4c0e9cf1f1ac0844bd8d6f00dc38f302026e13a"
[[package]]
name = "tonic"
version = "0.14.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2cdfc673aabd30fe8fee92e65837b644c37c5d47f0f97ae6d5e0f1237d15e1b"
dependencies = [
"async-trait",
"axum",
"base64 0.22.1",
"bytes",
"flate2",
"h2",
"http",
"http-body",
"http-body-util",
"hyper",
"hyper-timeout",
"hyper-util",
"percent-encoding",
"pin-project",
"socket2",
"sync_wrapper",
"tokio",
"tokio-rustls",
"tokio-stream",
"tokio-util",
"tower",
"tower-layer",
"tower-service",
"tracing",
]
[[package]] [[package]]
name = "tower" name = "tower"
version = "0.5.3" version = "0.5.3"
@@ -8544,12 +8353,9 @@ checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"futures-util", "futures-util",
"indexmap 2.14.2",
"pin-project-lite", "pin-project-lite",
"slab",
"sync_wrapper", "sync_wrapper",
"tokio", "tokio",
"tokio-util",
"tower-layer", "tower-layer",
"tower-service", "tower-service",
"tracing", "tracing",
@@ -9275,12 +9081,11 @@ checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88"
[[package]] [[package]]
name = "whatlang" name = "whatlang"
version = "0.16.4" version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "471d1c1645d361eb782a1650b1786a8fb58dd625e681a04c09f5ff7c8764a7b0" checksum = "f5e8f38b596e2a359b755342473520a99421e43658548c79489ee221b728c107"
dependencies = [ dependencies = [
"hashbrown 0.14.5", "hashbrown 0.15.5",
"once_cell",
] ]
[[package]] [[package]]
@@ -10149,7 +9954,7 @@ version = "9.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9534624d547e3f516ecde0ed9a70d37788f01d340efcfdd03bf3ea8e163c1d0" checksum = "a9534624d547e3f516ecde0ed9a70d37788f01d340efcfdd03bf3ea8e163c1d0"
dependencies = [ dependencies = [
"constant_time_eq 0.6.1", "constant_time_eq",
"crc32fast", "crc32fast",
"flate2", "flate2",
"getrandom 0.4.3", "getrandom 0.4.3",
+1 -7
View File
@@ -90,7 +90,7 @@ tempfile = "3.27.0"
strum_macros = "0.28.0" strum_macros = "0.28.0"
sysinfo = "0.39.6" sysinfo = "0.39.6"
bytes = "1.12.2" bytes = "1.12.2"
qdrant-edge = "0.8.0" qdrant-edge = "0.9.0"
# Prompt-injection detection. `regex` gives us linear-time matching without backtracking, so # Prompt-injection detection. `regex` gives us linear-time matching without backtracking, so
# a hostile document cannot make a scan blow up, and `aho-corasick` matches the ~1600 fixed # a hostile document cannot make a scan blow up, and `aho-corasick` matches the ~1600 fixed
@@ -105,12 +105,6 @@ tokenizers = "0.23.2"
# Sends requests through the runtime API router in tests, without starting a server. # Sends requests through the runtime API router in tests, without starting a server.
tower = { version = "0.5.3", features = ["util"] } tower = { version = "0.5.3", features = ["util"] }
[patch.crates-io]
# Issue: This repo was not updated since 2020. The rand crate was outdated. We patched it to use a newer version of rand.
# State: There is a PR for a long time, but it was not merged. We use the git version for now. Qdrant Edge still depends
# on this crate in version 0.1.2, so the patch stays relevant: https://github.com/asimihsan/permutation-iterator-rs/pull/14
permutation_iterator = { git = "https://github.com/SommerEngineering/permutation-iterator-rs.git", rev = "76836ed316d18dfef530ba908f58481c343e80d7" }
[target.'cfg(target_os = "windows")'.dependencies] [target.'cfg(target_os = "windows")'.dependencies]
windows-registry = "0.6.1" windows-registry = "0.6.1"
windows-native-keyring-store = "1.1.0" windows-native-keyring-store = "1.1.0"
-36
View File
@@ -1,36 +0,0 @@
# Runtime Patches
This directory documents temporary patches for third-party Rust dependencies.
## permutation_iterator
`qdrant-edge` depends on `permutation_iterator 0.1.2`, and that crate has seen no release since
2019. Its published version pulls in an outdated `rand` line, which drags a second copy of the
whole `rand` family into our dependency tree: `rand 0.7.3`, `rand_core 0.5.1`, `rand_chacha 0.2`,
`rand_hc`, `getrandom 0.1.16`, `wasi 0.9` and `cfg-if 0.1`, next to the current ones everything
else uses.
The fork `SommerEngineering/permutation-iterator-rs` is the published 0.1.2 with `rand` raised to
0.8, so it still satisfies what `qdrant-edge` asks for. AI Studio pins it in `runtime/Cargo.toml`:
```toml
[patch.crates-io]
permutation_iterator = { git = "https://github.com/SommerEngineering/permutation-iterator-rs.git", rev = "..." }
```
The same change was offered upstream in
[asimihsan/permutation-iterator-rs#14](https://github.com/asimihsan/permutation-iterator-rs/pull/14),
where it has been waiting since 2021. This is tree hygiene, not a build failure: without the patch
the runtime still builds, it just carries the old `rand` family along.
### When this patch can go
Either of these is enough, and both are worth a look whenever `qdrant-edge` is updated:
- crates.io carries a `permutation_iterator` newer than 0.1.2 which uses a current `rand`. Then the
`[patch.crates-io]` entry goes, and `qdrant-edge`'s own requirement decides the version.
- `qdrant-edge` stops depending on `permutation_iterator` at all. Check with
`cargo tree -i permutation_iterator` after the update.
Afterward, `grep 'name = "rand"' -A 2 runtime/Cargo.lock` must not show a 0.7 version anymore.
`SommerEngineering/permutation-iterator-rs` can then be deleted.
+123 -155
View File
@@ -32,7 +32,10 @@ const STORE_INITIALIZATION_MARKER_TEMP: &str = "store_name.tmp";
const STORE_DISPLAY_NAME_MARKER: &str = "data_source_name.txt"; const STORE_DISPLAY_NAME_MARKER: &str = "data_source_name.txt";
const STORE_DISPLAY_NAME_MARKER_TEMP: &str = "data_source_name.tmp"; const STORE_DISPLAY_NAME_MARKER_TEMP: &str = "data_source_name.tmp";
const WAL_DIRECTORY: &str = "wal"; const WAL_DIRECTORY: &str = "wal";
const CLOSED_WAL_SEGMENT_PREFIX: &str = "closed-";
/// The file in which Qdrant Edge notes how far its WAL is acknowledged, see `acknowledge_legacy_wal`.
const WAL_FIRST_INDEX_FILE: &str = "first-index";
const WAL_FIRST_INDEX_FILE_TEMP: &str = "first-index.tmp";
/// The directory below the data directory in which a backup collects its copies, one directory per /// The directory below the data directory in which a backup collects its copies, one directory per
/// backup. The app removes a backup's directory once the backup is written. /// backup. The app removes a backup's directory once the backup is written.
@@ -338,7 +341,7 @@ impl QdrantEdgeDatabase {
} }
let shard = if is_initialized { let shard = if is_initialized {
compact_wal(&path, store_name); acknowledge_legacy_wal(&path, store_name);
match EdgeShard::load(&path, None) { match EdgeShard::load(&path, None) {
Ok(shard) => shard, Ok(shard) => shard,
Err(error) => return Err(StoreUnreadableError::new(store_name, &path, error).into()), Err(error) => return Err(StoreUnreadableError::new(store_name, &path, error).into()),
@@ -380,7 +383,7 @@ impl QdrantEdgeDatabase {
return Ok(None); return Ok(None);
} }
compact_wal(&path, store_name); acknowledge_legacy_wal(&path, store_name);
let shard = match EdgeShard::load(&path, None) { let shard = match EdgeShard::load(&path, None) {
Ok(shard) => shard, Ok(shard) => shard,
Err(error) => return Err(StoreUnreadableError::new(store_name, &path, error).into()), Err(error) => return Err(StoreUnreadableError::new(store_name, &path, error).into()),
@@ -618,16 +621,6 @@ impl QdrantEdgeDatabase {
info!(Source = "Qdrant Edge"; "Optimized vector store '{}'.", store_name); info!(Source = "Qdrant Edge"; "Optimized vector store '{}'.", store_name);
} }
shard.flush()?; shard.flush()?;
// Temporary compatibility shim, see compact_wal: without this, the WAL of a long session
// keeps growing until the next start. The store has to be unloaded first, because Windows
// cannot delete memory-mapped files. The next request loads it again.
let path = self.store_path(store_name)?;
if has_obsolete_wal_segments(&path) {
drop(self.shards.remove(store_name));
compact_wal(&path, store_name);
}
Ok(()) Ok(())
} }
@@ -1140,15 +1133,25 @@ fn remove_obsolete_qdrant_path(path: &Path) {
} }
} }
// `on_disk` and `on_disk_payload` are deprecated in favor of `memory` and `payload_memory`. We keep
// them on purpose, so that a new store looks exactly like the existing ones. Older versions of AI
// Studio use qdrant-edge 0.8, which knows no `memory` for vectors: it would take such a store for
// one kept in RAM, find that its segments disagree, and refuse to open it. Leaving the flags unset is
// not an option either: the effective placement would fall back to cached instead of on-disk, which
// is a real change and would have the optimizers rebuild the HNSW graph.
#[allow(deprecated)]
fn edge_config(vector_size: usize) -> EdgeConfig { fn edge_config(vector_size: usize) -> EdgeConfig {
EdgeConfig { EdgeConfig {
on_disk_payload: Some(true), on_disk_payload: Some(true),
payload_memory: None,
id_tracker_memory: None,
vectors: HashMap::from([( vectors: HashMap::from([(
VECTOR_NAME.to_string(), VECTOR_NAME.to_string(),
EdgeVectorParams { EdgeVectorParams {
size: vector_size, size: vector_size,
distance: Distance::Cosine, distance: Distance::Cosine,
on_disk: Some(true), on_disk: Some(true),
memory: None,
quantization_config: None, quantization_config: None,
multivector_config: None, multivector_config: None,
datatype: None, datatype: None,
@@ -1160,15 +1163,15 @@ fn edge_config(vector_size: usize) -> EdgeConfig {
quantization_config: None, quantization_config: None,
optimizers: Some(edge_optimizers_config()), optimizers: Some(edge_optimizers_config()),
wal_options: None, wal_options: None,
// Keeps the WAL, like every existing store. Qdrant Edge fixes this choice when it creates a store.
wal_enabled: None,
max_search_threads: None, max_search_threads: None,
search_pool_core: None, search_pool_core: None,
} }
} }
// `on_disk` is deprecated in favor of `memory`, but Qdrant Edge does not re-export the `Memory` // See edge_config for why this sets the deprecated `on_disk`.
// type, so the new field cannot be named from here. Leaving both unset is not an option either:
// the effective placement would fall back to cached instead of on-disk, which is a real change
// and would have the optimizers rebuild the HNSW graph.
#[allow(deprecated)] #[allow(deprecated)]
fn hnsw_config() -> HnswIndexConfig { fn hnsw_config() -> HnswIndexConfig {
HnswIndexConfig { HnswIndexConfig {
@@ -1240,77 +1243,27 @@ fn remove_partial_store(path: &Path) -> String {
} }
} }
// Temporary compatibility shim until a qdrant-edge release acknowledges its WAL by itself: // Temporary compatibility shim until a qdrant-edge release skips already persisted operations when
// documentation/compatibility-shims/2026-10-qdrant-edge-wal-compaction.md // it loads a store: documentation/compatibility-shims/2026-11-qdrant-edge-legacy-wal.md
// //
// Qdrant Edge writes every update to its WAL, but never acknowledges the WAL and never replays it, // Up to qdrant-edge 0.8, Qdrant Edge never acknowledged its WAL. Since 0.9, loading a store applies
// so the WAL grows with every update. We flush after every update, which means the segments already // every operation of the WAL again which is not marked as acknowledged, so the first load of a store
// hold everything the WAL contains. The store must not be loaded while this runs. // from an older version would apply its whole WAL once more. Each deletion of a document in there
fn compact_wal(store_path: &Path, store_name: &str) { // reads every payload of the store, which takes minutes to hours for a large one, and all requests
match remove_obsolete_wal_segments(&store_path.join(WAL_DIRECTORY)) { // to the vector database wait meanwhile. We flush after every update, so the segments already hold
Ok((0, _)) => {}, // everything the WAL contains, and marking all of it as acknowledged loses nothing. Qdrant Edge
Ok((removed_segments, removed_bytes)) => info!(Source = "Qdrant Edge"; "Removed {removed_segments} obsolete WAL segment(s) with {:.1} MiB from vector store '{store_name}'.", removed_bytes as f64 / (1024.0 * 1024.0)), // lowers the mark to the last entry of the WAL. The store must not be loaded while this runs.
Err(error) => warn!(Source = "Qdrant Edge"; "Could not remove the obsolete WAL segments of vector store '{store_name}': {error}"), fn acknowledge_legacy_wal(store_path: &Path, store_name: &str) {
} let wal_path = store_path.join(WAL_DIRECTORY);
} if !wal_path.is_dir() || wal_path.join(WAL_FIRST_INDEX_FILE).exists() {
return;
/// Whether the store's WAL holds segments which `compact_wal` would remove.
fn has_obsolete_wal_segments(store_path: &Path) -> bool {
wal_file_names(&store_path.join(WAL_DIRECTORY))
.is_ok_and(|file_names| !obsolete_wal_segments(&file_names).is_empty())
}
/// Removes the obsolete closed segments, oldest first, and returns their number and size. When a
/// removal fails, the segments left over are still contiguous, so Qdrant Edge can open the WAL.
fn remove_obsolete_wal_segments(wal_path: &Path) -> std::io::Result<(usize, u64)> {
let mut removed_segments = 0;
let mut removed_bytes = 0;
for file_name in obsolete_wal_segments(&wal_file_names(wal_path)?) {
let segment_path = wal_path.join(file_name);
let segment_size = fs::metadata(&segment_path)?.len();
fs::remove_file(&segment_path)?;
removed_segments += 1;
removed_bytes += segment_size;
} }
Ok((removed_segments, removed_bytes)) let acknowledged_everything = json!({ "ack_index": u64::MAX }).to_string();
} match write_store_marker(&wal_path, WAL_FIRST_INDEX_FILE, WAL_FIRST_INDEX_FILE_TEMP, &acknowledged_everything) {
Ok(()) => info!(Source = "Qdrant Edge"; "Marked the WAL of vector store '{store_name}' as acknowledged, since an older version of AI Studio wrote it."),
fn wal_file_names(wal_path: &Path) -> std::io::Result<Vec<String>> { Err(error) => warn!(Source = "Qdrant Edge"; "Could not mark the WAL of vector store '{store_name}' as acknowledged, so loading the store applies the whole WAL once more: {error}"),
if !wal_path.is_dir() {
return Ok(Vec::new());
} }
// Every file counts: a closed segment missing from this list would leave a gap behind.
let mut file_names = Vec::new();
for entry in fs::read_dir(wal_path)? {
let entry = entry?;
if entry.file_type()?.is_file() && let Ok(file_name) = entry.file_name().into_string() {
file_names.push(file_name);
}
}
Ok(file_names)
}
/// The closed WAL segments which may go, oldest first. That is all of them except the newest:
/// Qdrant Edge numbers its operations from the first closed segment and would start again at zero
/// without one. The segments then ignore every later update of a point they already know.
fn obsolete_wal_segments(file_names: &[String]) -> Vec<String> {
let mut closed_segments = file_names
.iter()
.filter_map(|file_name| {
let start_index = file_name.strip_prefix(CLOSED_WAL_SEGMENT_PREFIX)?.parse::<u64>().ok()?;
Some((start_index, file_name.clone()))
})
.collect::<Vec<_>>();
closed_segments.sort_unstable_by_key(|(start_index, _)| *start_index);
closed_segments.pop();
closed_segments
.into_iter()
.map(|(_, file_name)| file_name)
.collect()
} }
fn validate_vector_size(vector_size: usize) -> QdrantEdgeResult<()> { fn validate_vector_size(vector_size: usize) -> QdrantEdgeResult<()> {
@@ -1845,85 +1798,79 @@ mod tests {
} }
#[test] #[test]
fn obsolete_wal_segments_keeps_the_newest_closed_segment() { fn the_wal_keeps_only_the_newest_closed_segment() {
let file_names = ["closed-120", "open-7", "closed-0", "tmp-open-8", "closed-40", ".wal", "first-index", "closed-abc"].map(String::from); let test_directory = test_directory("wal-acknowledged");
let (database, _, most_closed_segments_at_once) = store_with_a_rolled_over_wal(&test_directory);
// Sorted by number, not by name: as text, "closed-40" would come after "closed-120". // Qdrant Edge acknowledges its WAL when it flushes, and keeps the newest closed segment to
assert_eq!(obsolete_wal_segments(&file_names), vec!["closed-0", "closed-40"]); // number its operations on. Should this fail, the WAL grows with every update again, as it
// did up to qdrant-edge 0.8.
assert_eq!(most_closed_segments_at_once, 1);
assert!(obsolete_wal_segments(&["closed-0", "open-1"].map(String::from)).is_empty()); drop(database);
assert!(obsolete_wal_segments(&["open-1"].map(String::from)).is_empty()); fs::remove_dir_all(test_directory).unwrap();
} }
#[test] #[test]
fn a_reloaded_store_drops_obsolete_wal_segments_and_keeps_its_points() { fn an_update_after_a_reload_replaces_the_existing_point() {
let test_directory = test_directory("wal-reload"); let test_directory = test_directory("wal-reload");
let (database, point_ids) = store_with_several_closed_wal_segments(&test_directory); let (mut database, point_ids, _) = store_with_a_rolled_over_wal(&test_directory);
let store_path = database.store_path(SEARCH_STORE).unwrap();
drop(database);
let mut database = QdrantEdgeDatabase::new(test_directory.clone());
let found = database.search_embedding(SEARCH_STORE, search_vector(), point_ids.len(), None, &[]).unwrap();
assert_eq!(closed_wal_segments(&store_path).len(), 1);
assert_eq!(
found_point_ids(&found).into_iter().collect::<HashSet<_>>(),
point_ids.iter().map(String::as_str).collect::<HashSet<_>>(),
"the points live in the segments, so removing WAL segments must not lose any of them"
);
drop(database);
fs::remove_dir_all(test_directory).unwrap();
}
#[test]
fn an_update_after_wal_compaction_replaces_the_existing_point() {
let test_directory = test_directory("wal-update");
let (database, point_ids) = store_with_several_closed_wal_segments(&test_directory);
drop(database);
// The newest point carries the highest operation number so far. Should the numbering start
// again after the compaction, the segment would ignore this update as outdated.
let newest_point_id = point_ids.last().unwrap();
let mut updated_point = test_point(newest_point_id, vec![0.0, 0.0, 1.0]);
updated_point.text = "Updated text.".to_string();
let mut database = QdrantEdgeDatabase::new(test_directory.clone());
database.insert_embedding(SEARCH_STORE, vec![updated_point]).unwrap();
let found = database
.search_embedding(SEARCH_STORE, search_vector(), 1, Some(vec![newest_point_id.clone()]), &[])
.unwrap();
assert_eq!(found.len(), 1);
assert_eq!(found[0].text, "Updated text.");
drop(database);
fs::remove_dir_all(test_directory).unwrap();
}
#[test]
fn optimize_removes_obsolete_wal_segments_of_a_loaded_store() {
let test_directory = test_directory("wal-optimize");
let (mut database, point_ids) = store_with_several_closed_wal_segments(&test_directory);
let store_path = database.store_path(SEARCH_STORE).unwrap();
database.optimize_store(SEARCH_STORE).unwrap(); database.optimize_store(SEARCH_STORE).unwrap();
assert_eq!(closed_wal_segments(&store_path).len(), 1); drop(database);
// The next request loads the store again, with all its points and still taking updates.
let newest_point_id = point_ids.last().unwrap();
let mut updated_point = test_point(newest_point_id, vec![0.0, 0.0, 1.0]);
updated_point.text = "Updated text.".to_string();
database.insert_embedding(SEARCH_STORE, vec![updated_point]).unwrap();
let mut database = QdrantEdgeDatabase::new(test_directory.clone());
let found = database.search_embedding(SEARCH_STORE, search_vector(), point_ids.len(), None, &[]).unwrap(); let found = database.search_embedding(SEARCH_STORE, search_vector(), point_ids.len(), None, &[]).unwrap();
assert_eq!( assert_eq!(
found_point_ids(&found).into_iter().collect::<HashSet<_>>(), found_point_ids(&found).into_iter().collect::<HashSet<_>>(),
point_ids.iter().map(String::as_str).collect::<HashSet<_>>() point_ids.iter().map(String::as_str).collect::<HashSet<_>>()
); );
let updated = found.iter().find(|result| &result.point_id == newest_point_id).unwrap(); // The newest point carries the highest operation number so far. Should the numbering start
assert_eq!(updated.text, "Updated text."); // again after the reload, the segment would ignore this update as outdated.
assert_update_of_the_newest_point_takes_effect(&mut database, &point_ids);
drop(database);
fs::remove_dir_all(test_directory).unwrap();
}
#[test]
fn a_store_of_an_older_version_gets_its_wal_acknowledged_and_keeps_its_points() {
let test_directory = test_directory("wal-legacy");
let (database, point_ids, _) = store_with_a_rolled_over_wal(&test_directory);
let first_index_path = database.store_path(SEARCH_STORE).unwrap().join(WAL_DIRECTORY).join(WAL_FIRST_INDEX_FILE);
drop(database);
// Up to qdrant-edge 0.8, a WAL had no such file.
fs::remove_file(&first_index_path).unwrap();
let mut database = QdrantEdgeDatabase::new(test_directory.clone());
let found = database.search_embedding(SEARCH_STORE, search_vector(), point_ids.len(), None, &[]).unwrap();
let first_index: Value = fs::read_to_string(&first_index_path).unwrap().parse().unwrap();
assert_eq!(first_index["ack_index"].as_u64(), Some(u64::MAX));
assert_eq!(
found_point_ids(&found).into_iter().collect::<HashSet<_>>(),
point_ids.iter().map(String::as_str).collect::<HashSet<_>>(),
"the points live in the segments, so marking the WAL as acknowledged must not lose any of them"
);
// Marking the WAL must not start the numbering of operations again.
assert_update_of_the_newest_point_takes_effect(&mut database, &point_ids);
drop(database);
fs::remove_dir_all(test_directory).unwrap();
}
#[test]
fn an_acknowledged_wal_stays_as_it_is() {
let test_directory = test_directory("wal-first-index");
let database = store_with_one_point_per_axis(&test_directory);
let first_index_path = database.store_path(SEARCH_STORE).unwrap().join(WAL_DIRECTORY).join(WAL_FIRST_INDEX_FILE);
drop(database);
let first_index = fs::read_to_string(&first_index_path).unwrap();
let mut database = QdrantEdgeDatabase::new(test_directory.clone());
database.search_embedding(SEARCH_STORE, search_vector(), 3, None, &[]).unwrap();
assert_eq!(fs::read_to_string(&first_index_path).unwrap(), first_index);
drop(database); drop(database);
fs::remove_dir_all(test_directory).unwrap(); fs::remove_dir_all(test_directory).unwrap();
@@ -2118,9 +2065,10 @@ mod tests {
database database
} }
/// A store with tiny WAL segments, filled one point at a time until the WAL has closed several /// A store with tiny WAL segments, filled one point at a time until the WAL has closed three of
/// of them. Returns the database with the store still loaded, and the IDs in insertion order. /// them. Returns the database with the store still loaded, the IDs in insertion order, and the
fn store_with_several_closed_wal_segments(test_directory: &Path) -> (QdrantEdgeDatabase, Vec<String>) { /// most closed segments the WAL kept at once.
fn store_with_a_rolled_over_wal(test_directory: &Path) -> (QdrantEdgeDatabase, Vec<String>, usize) {
const SMALL_WAL_SEGMENT_CAPACITY: usize = 8 * 1024; const SMALL_WAL_SEGMENT_CAPACITY: usize = 8 * 1024;
const MAX_POINTS: usize = 1_000; const MAX_POINTS: usize = 1_000;
@@ -2141,7 +2089,9 @@ mod tests {
write_store_initialization_marker(&store_path, SEARCH_STORE).unwrap(); write_store_initialization_marker(&store_path, SEARCH_STORE).unwrap();
let mut point_ids = Vec::new(); let mut point_ids = Vec::new();
while closed_wal_segments(&store_path).len() < 3 { let mut closed_segments_seen = HashSet::new();
let mut most_closed_segments_at_once = 0;
while closed_segments_seen.len() < 3 {
assert!(point_ids.len() < MAX_POINTS, "the WAL never closed enough segments"); assert!(point_ids.len() < MAX_POINTS, "the WAL never closed enough segments");
let point_id = Uuid::from_u128(point_ids.len() as u128 + 1).to_string(); let point_id = Uuid::from_u128(point_ids.len() as u128 + 1).to_string();
@@ -2149,19 +2099,37 @@ mod tests {
.insert_embedding(SEARCH_STORE, vec![test_point(&point_id, vec![1.0, point_ids.len() as f32, 1.0])]) .insert_embedding(SEARCH_STORE, vec![test_point(&point_id, vec![1.0, point_ids.len() as f32, 1.0])])
.unwrap(); .unwrap();
point_ids.push(point_id); point_ids.push(point_id);
let closed_segments = closed_wal_segments(&store_path);
most_closed_segments_at_once = most_closed_segments_at_once.max(closed_segments.len());
closed_segments_seen.extend(closed_segments);
} }
(database, point_ids) (database, point_ids, most_closed_segments_at_once)
} }
fn closed_wal_segments(store_path: &Path) -> Vec<String> { fn closed_wal_segments(store_path: &Path) -> Vec<String> {
fs::read_dir(store_path.join(WAL_DIRECTORY)) fs::read_dir(store_path.join(WAL_DIRECTORY))
.unwrap() .unwrap()
.map(|entry| entry.unwrap().file_name().into_string().unwrap()) .map(|entry| entry.unwrap().file_name().into_string().unwrap())
.filter(|file_name| file_name.starts_with(CLOSED_WAL_SEGMENT_PREFIX)) .filter(|file_name| file_name.starts_with("closed-"))
.collect() .collect()
} }
/// Updates the newest of the given points and checks that a search finds its new text.
fn assert_update_of_the_newest_point_takes_effect(database: &mut QdrantEdgeDatabase, point_ids: &[String]) {
let newest_point_id = point_ids.last().unwrap();
let mut updated_point = test_point(newest_point_id, vec![0.0, 0.0, 1.0]);
updated_point.text = "Updated text.".to_string();
database.insert_embedding(SEARCH_STORE, vec![updated_point]).unwrap();
let found = database
.search_embedding(SEARCH_STORE, search_vector(), 1, Some(vec![newest_point_id.clone()]), &[])
.unwrap();
assert_eq!(found.len(), 1);
assert_eq!(found[0].text, "Updated text.");
}
/// Closest to the point on the x axis, then the one on the y axis, then the one on the z axis. /// Closest to the point on the x axis, then the one on the y axis, then the one on the z axis.
fn search_vector() -> Vec<f32> { fn search_vector() -> Vec<f32> {
vec![1.0, 0.5, 0.0] vec![1.0, 0.5, 0.0]