|
@@ -11,6 +11,7 @@
|
|
|
|
|
|
|
|
#if defined(__GLIBC__) && !defined(__APPLE__)
|
|
#if defined(__GLIBC__) && !defined(__APPLE__)
|
|
|
#include <malloc.h>
|
|
#include <malloc.h>
|
|
|
|
|
+#include <cstring>
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
#include <spdlog/spdlog.h>
|
|
#include <spdlog/spdlog.h>
|
|
@@ -2407,6 +2408,8 @@ std::vector<float> MemoryStore::extractVector(CollectionData& coll, Document& do
|
|
|
void MemoryStore::storeVector(CollectionData& coll, const std::string& docId,
|
|
void MemoryStore::storeVector(CollectionData& coll, const std::string& docId,
|
|
|
const std::vector<float>& vec) {
|
|
const std::vector<float>& vec) {
|
|
|
if (vec.empty()) return;
|
|
if (vec.empty()) return;
|
|
|
|
|
+ coll.releasedVectors.erase(docId); // v2.21.3 - memory holds it again
|
|
|
|
|
+ coll.vectorsKeptResident.erase(docId);
|
|
|
|
|
|
|
|
uint64_t oldSize = 0;
|
|
uint64_t oldSize = 0;
|
|
|
auto existing = coll.vectors.find(docId);
|
|
auto existing = coll.vectors.find(docId);
|
|
@@ -2428,6 +2431,8 @@ void MemoryStore::storeVector(CollectionData& coll, const std::string& docId,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void MemoryStore::removeVector(CollectionData& coll, const std::string& docId) {
|
|
void MemoryStore::removeVector(CollectionData& coll, const std::string& docId) {
|
|
|
|
|
+ coll.releasedVectors.erase(docId); // v2.21.3
|
|
|
|
|
+ coll.vectorsKeptResident.erase(docId);
|
|
|
auto it = coll.vectors.find(docId);
|
|
auto it = coll.vectors.find(docId);
|
|
|
if (it != coll.vectors.end()) {
|
|
if (it != coll.vectors.end()) {
|
|
|
uint64_t freed = estimateVectorSize(it->second);
|
|
uint64_t freed = estimateVectorSize(it->second);
|
|
@@ -2465,7 +2470,7 @@ std::vector<MemoryStore::SimilarityResult> MemoryStore::similaritySearch(
|
|
|
|
|
|
|
|
std::shared_lock<std::shared_mutex> collLock(coll.mutex);
|
|
std::shared_lock<std::shared_mutex> collLock(coll.mutex);
|
|
|
|
|
|
|
|
- if (coll.vectors.empty()) {
|
|
|
|
|
|
|
+ if (coll.vectors.empty() && coll.releasedVectors.empty()) {
|
|
|
return {};
|
|
return {};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2493,6 +2498,21 @@ std::vector<MemoryStore::SimilarityResult> MemoryStore::similaritySearch(
|
|
|
scored.push_back({docId, score});
|
|
scored.push_back({docId, score});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ // v2.21.3 - vectors released to LMDB are scored from there, so this
|
|
|
|
|
+ // degraded path (mirror unhealthy) does not lose them. LMDB's copy is
|
|
|
|
|
+ // current: it was byte-identical when released, and every write since
|
|
|
|
|
+ // would have read it back into memory first. A read error throws (the
|
|
|
|
|
+ // caller gets an error, not a silently shorter answer).
|
|
|
|
|
+ for (const auto& docId : coll.releasedVectors) {
|
|
|
|
|
+ auto vec = readStoredVector(collection, docId);
|
|
|
|
|
+ if (!vec || vec->size() != queryVector.size()) continue;
|
|
|
|
|
+ const float score = cosineSimilaritySIMD(
|
|
|
|
|
+ queryVector.data(), vec->data(), vec->size(), queryNorm,
|
|
|
|
|
+ computeNorm(vec->data(), vec->size()));
|
|
|
|
|
+ if (score >= minScore) {
|
|
|
|
|
+ scored.push_back({docId, score});
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// partial_sort for top-K
|
|
// partial_sort for top-K
|
|
|
uint32_t k = std::min(topK, static_cast<uint32_t>(scored.size()));
|
|
uint32_t k = std::min(topK, static_cast<uint32_t>(scored.size()));
|
|
@@ -2540,6 +2560,7 @@ void MemoryStore::loadVector(const std::string& collection, const std::string& d
|
|
|
if (vec.empty()) return;
|
|
if (vec.empty()) return;
|
|
|
|
|
|
|
|
std::unique_lock<std::shared_mutex> lock(coll->mutex);
|
|
std::unique_lock<std::shared_mutex> lock(coll->mutex);
|
|
|
|
|
+ coll->releasedVectors.erase(docId); // v2.21.3
|
|
|
|
|
|
|
|
// v2.21.2 - counted, through storeVector's accounting. Boot-loaded
|
|
// v2.21.2 - counted, through storeVector's accounting. Boot-loaded
|
|
|
// vectors (snapshot, WAL replay) used to bypass the estimate entirely, so
|
|
// vectors (snapshot, WAL replay) used to bypass the estimate entirely, so
|
|
@@ -3415,16 +3436,20 @@ std::optional<std::vector<float>> MemoryStore::residentVector(
|
|
|
const std::string& collection, const std::string& id) const {
|
|
const std::string& collection, const std::string& id) const {
|
|
|
const CollectionData* coll = getCollection(collection);
|
|
const CollectionData* coll = getCollection(collection);
|
|
|
if (coll == nullptr) return std::nullopt;
|
|
if (coll == nullptr) return std::nullopt;
|
|
|
- std::shared_lock<std::shared_mutex> lock(coll->mutex);
|
|
|
|
|
- auto it = coll->vectors.find(id);
|
|
|
|
|
- if (it == coll->vectors.end()) return std::nullopt;
|
|
|
|
|
- return it->second;
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ std::shared_lock<std::shared_mutex> lock(coll->mutex);
|
|
|
|
|
+ auto it = coll->vectors.find(id);
|
|
|
|
|
+ if (it != coll->vectors.end()) return it->second;
|
|
|
|
|
+ if (coll->releasedVectors.count(id) == 0) return std::nullopt;
|
|
|
|
|
+ }
|
|
|
|
|
+ return readStoredVector(collection, id); // v2.21.3 - released
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool MemoryStore::hasVector(const std::string& collection, const std::string& id) const {
|
|
bool MemoryStore::hasVector(const std::string& collection, const std::string& id) const {
|
|
|
if (const CollectionData* coll = getCollection(collection)) {
|
|
if (const CollectionData* coll = getCollection(collection)) {
|
|
|
std::shared_lock<std::shared_mutex> lock(coll->mutex);
|
|
std::shared_lock<std::shared_mutex> lock(coll->mutex);
|
|
|
if (coll->vectors.count(id) != 0) return true;
|
|
if (coll->vectors.count(id) != 0) return true;
|
|
|
|
|
+ if (coll->releasedVectors.count(id) != 0) return true; // v2.21.3
|
|
|
}
|
|
}
|
|
|
auto stub = getEvictedStub(collection, id);
|
|
auto stub = getEvictedStub(collection, id);
|
|
|
return stub && stub->vectorEvicted;
|
|
return stub && stub->vectorEvicted;
|
|
@@ -3434,8 +3459,9 @@ std::vector<std::string> MemoryStore::getVectorIds(const std::string& collection
|
|
|
std::vector<std::string> ids;
|
|
std::vector<std::string> ids;
|
|
|
if (const CollectionData* coll = getCollection(collection)) {
|
|
if (const CollectionData* coll = getCollection(collection)) {
|
|
|
std::shared_lock<std::shared_mutex> lock(coll->mutex);
|
|
std::shared_lock<std::shared_mutex> lock(coll->mutex);
|
|
|
- ids.reserve(coll->vectors.size());
|
|
|
|
|
|
|
+ ids.reserve(coll->vectors.size() + coll->releasedVectors.size());
|
|
|
for (const auto& [id, vec] : coll->vectors) ids.push_back(id);
|
|
for (const auto& [id, vec] : coll->vectors) ids.push_back(id);
|
|
|
|
|
+ for (const auto& id : coll->releasedVectors) ids.push_back(id); // v2.21.3
|
|
|
}
|
|
}
|
|
|
// Evicted after the resident ids were listed: listed twice, written
|
|
// Evicted after the resident ids were listed: listed twice, written
|
|
|
// twice, and the loader keeps one. Never missed.
|
|
// twice, and the loader keeps one. Never missed.
|
|
@@ -3456,11 +3482,13 @@ std::vector<std::optional<std::vector<float>>> MemoryStore::copyVectors(
|
|
|
if (from >= end) return out;
|
|
if (from >= end) return out;
|
|
|
out.resize(end - from);
|
|
out.resize(end - from);
|
|
|
std::vector<size_t> missing;
|
|
std::vector<size_t> missing;
|
|
|
|
|
+ std::vector<size_t> released; // v2.21.3 - in LMDB only
|
|
|
if (const CollectionData* coll = getCollection(collection)) {
|
|
if (const CollectionData* coll = getCollection(collection)) {
|
|
|
std::shared_lock<std::shared_mutex> lock(coll->mutex);
|
|
std::shared_lock<std::shared_mutex> lock(coll->mutex);
|
|
|
for (size_t i = from; i < end; ++i) {
|
|
for (size_t i = from; i < end; ++i) {
|
|
|
auto it = coll->vectors.find(ids[i]);
|
|
auto it = coll->vectors.find(ids[i]);
|
|
|
if (it != coll->vectors.end()) out[i - from] = it->second;
|
|
if (it != coll->vectors.end()) out[i - from] = it->second;
|
|
|
|
|
+ else if (coll->releasedVectors.count(ids[i]) != 0) released.push_back(i);
|
|
|
else missing.push_back(i);
|
|
else missing.push_back(i);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
@@ -3472,6 +3500,9 @@ std::vector<std::optional<std::vector<float>>> MemoryStore::copyVectors(
|
|
|
// absent: it was released only because LMDB held it, so absence means it
|
|
// absent: it was released only because LMDB held it, so absence means it
|
|
|
// was deleted meanwhile, and failing every snapshot over it would grow
|
|
// was deleted meanwhile, and failing every snapshot over it would grow
|
|
|
// the WAL without bound (the 2.20.1 outage).
|
|
// the WAL without bound (the 2.20.1 outage).
|
|
|
|
|
+ // A released vector of a resident document: same reasoning, LMDB holds
|
|
|
|
|
+ // the current copy (a write reads it back into memory first).
|
|
|
|
|
+ for (size_t i : released) out[i - from] = readStoredVector(collection, ids[i]);
|
|
|
for (size_t i : missing) {
|
|
for (size_t i : missing) {
|
|
|
auto stub = getEvictedStub(collection, ids[i]);
|
|
auto stub = getEvictedStub(collection, ids[i]);
|
|
|
if (stub && stub->vectorEvicted) {
|
|
if (stub && stub->vectorEvicted) {
|
|
@@ -3485,6 +3516,137 @@ std::vector<std::optional<std::vector<float>>> MemoryStore::copyVectors(
|
|
|
return out;
|
|
return out;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void MemoryStore::restoreReleasedVector(const std::string& collection, const std::string& id) {
|
|
|
|
|
+ if (const CollectionData* coll = getCollection(collection)) {
|
|
|
|
|
+ std::shared_lock<std::shared_mutex> lock(coll->mutex);
|
|
|
|
|
+ if (coll->releasedVectors.count(id) == 0) return;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ // Read outside the collection lock; a read error throws and fails the
|
|
|
|
|
+ // write, which must not proceed as if the row had no vector.
|
|
|
|
|
+ auto vec = readStoredVector(collection, id);
|
|
|
|
|
+
|
|
|
|
|
+ std::shared_lock<std::shared_mutex> globalLock(globalMutex_);
|
|
|
|
|
+ auto it = collections_.find(collection);
|
|
|
|
|
+ if (it == collections_.end()) return;
|
|
|
|
|
+ CollectionData& coll = *it->second;
|
|
|
|
|
+ std::unique_lock<std::shared_mutex> lock(coll.mutex);
|
|
|
|
|
+ // Gone from the set meanwhile: another write restored it (and may have
|
|
|
|
|
+ // changed it since), or it was deleted. Either way not ours to restore.
|
|
|
|
|
+ if (coll.releasedVectors.count(id) == 0) return;
|
|
|
|
|
+ if (vec) {
|
|
|
|
|
+ storeVector(coll, id, *vec); // also takes it out of releasedVectors
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // Released only because LMDB held it; nothing deletes it there
|
|
|
|
|
+ // without going through a write, which restores first. Never expected.
|
|
|
|
|
+ coll.releasedVectors.erase(id);
|
|
|
|
|
+ spdlog::warn("Vector of {}/{} was released to LMDB and is no longer there; "
|
|
|
|
|
+ "the document continues without one", collection, id);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+size_t MemoryStore::releaseMirroredVectors() {
|
|
|
|
|
+ if (!docStoreResolver_) return 0;
|
|
|
|
|
+ std::vector<std::string> names;
|
|
|
|
|
+ {
|
|
|
|
|
+ std::shared_lock<std::shared_mutex> globalLock(globalMutex_);
|
|
|
|
|
+ for (const auto& [name, coll] : collections_) {
|
|
|
|
|
+ if (coll->options.vectorDimension > 0) names.push_back(name);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ constexpr size_t kBatch = 256; // vectors per hold of the collection lock
|
|
|
|
|
+ size_t released = 0, keptResident = 0;
|
|
|
|
|
+ uint64_t freed = 0;
|
|
|
|
|
+ for (const auto& name : names) {
|
|
|
|
|
+ if (!canReleaseVector(name)) continue;
|
|
|
|
|
+ smartbotic::db::storage::DocumentStore* ds = nullptr;
|
|
|
|
|
+ std::string subName;
|
|
|
|
|
+ try {
|
|
|
|
|
+ const auto pc = smartbotic::database::parseProjectCollection(name);
|
|
|
|
|
+ ds = docStoreResolver_(pc.project);
|
|
|
|
|
+ subName = pc.collection;
|
|
|
|
|
+ } catch (const std::exception&) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ds == nullptr) continue;
|
|
|
|
|
+
|
|
|
|
|
+ for (;;) {
|
|
|
|
|
+ std::shared_lock<std::shared_mutex> globalLock(globalMutex_);
|
|
|
|
|
+ auto it = collections_.find(name);
|
|
|
|
|
+ if (it == collections_.end()) break;
|
|
|
|
|
+ CollectionData& coll = *it->second;
|
|
|
|
|
+ std::unique_lock<std::shared_mutex> lock(coll.mutex);
|
|
|
|
|
+ // Re-checked under the lock: a mirror failure since the check
|
|
|
|
|
+ // above means LMDB may be behind, and nothing may be released.
|
|
|
|
|
+ if (!canReleaseVector(name)) break;
|
|
|
|
|
+ size_t inBatch = 0, examined = 0;
|
|
|
|
|
+ for (auto vit = coll.vectors.begin();
|
|
|
|
|
+ vit != coll.vectors.end() && examined < kBatch;) {
|
|
|
|
|
+ const std::string& id = vit->first;
|
|
|
|
|
+ if (coll.vectorsKeptResident.count(id) != 0 || hasInFlightWrite(coll, id)) {
|
|
|
|
|
+ ++vit;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ ++examined;
|
|
|
|
|
+ // Byte-exact or not at all: a vector LMDB lacks or disagrees
|
|
|
|
|
+ // with would be lost by releasing it.
|
|
|
|
|
+ std::optional<std::vector<float>> stored;
|
|
|
|
|
+ try {
|
|
|
|
|
+ stored = ds->get_vector(subName, id);
|
|
|
|
|
+ } catch (const std::exception& e) {
|
|
|
|
|
+ spdlog::warn("Vector release: LMDB read of {}/{} failed ({}); kept in memory",
|
|
|
|
|
+ name, id, e.what());
|
|
|
|
|
+ coll.vectorsKeptResident.insert(id);
|
|
|
|
|
+ ++keptResident;
|
|
|
|
|
+ ++vit;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ const auto& vec = vit->second;
|
|
|
|
|
+ if (!stored || stored->size() != vec.size() ||
|
|
|
|
|
+ std::memcmp(stored->data(), vec.data(), vec.size() * sizeof(float)) != 0) {
|
|
|
|
|
+ coll.vectorsKeptResident.insert(id);
|
|
|
|
|
+ ++keptResident;
|
|
|
|
|
+ ++vit;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ const uint64_t size = estimateVectorSize(vec);
|
|
|
|
|
+ coll.vectorNorms.erase(id);
|
|
|
|
|
+ coll.releasedVectors.insert(id);
|
|
|
|
|
+ vit = coll.vectors.erase(vit);
|
|
|
|
|
+ subVectorBytes(size);
|
|
|
|
|
+ freed += size;
|
|
|
|
|
+ ++released;
|
|
|
|
|
+ ++inBatch;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (inBatch == 0) break; // nothing left this collection can release
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (keptResident > 0) {
|
|
|
|
|
+ spdlog::warn("Vector release: {} vector(s) kept in memory because LMDB's copy is "
|
|
|
|
|
+ "missing or differs; a write to the row retries", keptResident);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (released > 0) {
|
|
|
|
|
+ spdlog::info("Released {} vector(s) ({} MB) from memory; LMDB holds them",
|
|
|
|
|
+ released, freed / (1024 * 1024));
|
|
|
|
|
+#if defined(__GLIBC__) && !defined(__APPLE__)
|
|
|
|
|
+ // Thousands of 16 KB blocks freed at once sit in the heap otherwise.
|
|
|
|
|
+ if (freed >= 16ULL * 1024 * 1024) ::malloc_trim(0);
|
|
|
|
|
+#endif
|
|
|
|
|
+ }
|
|
|
|
|
+ return released;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+size_t MemoryStore::releasedVectorCount() const {
|
|
|
|
|
+ size_t n = 0;
|
|
|
|
|
+ std::shared_lock<std::shared_mutex> globalLock(globalMutex_);
|
|
|
|
|
+ for (const auto& [name, coll] : collections_) {
|
|
|
|
|
+ std::shared_lock<std::shared_mutex> lock(coll->mutex);
|
|
|
|
|
+ n += coll->releasedVectors.size();
|
|
|
|
|
+ }
|
|
|
|
|
+ return n;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
std::vector<std::pair<std::string, CollectionOptions>> MemoryStore::getAllCollectionsWithOptions() const {
|
|
std::vector<std::pair<std::string, CollectionOptions>> MemoryStore::getAllCollectionsWithOptions() const {
|
|
|
std::shared_lock<std::shared_mutex> lock(globalMutex_);
|
|
std::shared_lock<std::shared_mutex> lock(globalMutex_);
|
|
|
|
|
|
|
@@ -3779,6 +3941,7 @@ void MemoryStore::reloadIfEvicted(const std::string& collection, const std::stri
|
|
|
if (id.empty()) return;
|
|
if (id.empty()) return;
|
|
|
if (!getEvictedStub(collection, id)) {
|
|
if (!getEvictedStub(collection, id)) {
|
|
|
adoptFromDocStore(collection, id); // v2.20.2
|
|
adoptFromDocStore(collection, id); // v2.20.2
|
|
|
|
|
+ restoreReleasedVector(collection, id); // v2.21.3
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (loadEvictedDocument(collection, id)) return;
|
|
if (loadEvictedDocument(collection, id)) return;
|
|
@@ -4192,12 +4355,14 @@ void MemoryStore::logMemoryCheck() {
|
|
|
auto stats = getStats();
|
|
auto stats = getStats();
|
|
|
// v2.21.2 - the vector share is reported on its own: it is usually the
|
|
// v2.21.2 - the vector share is reported on its own: it is usually the
|
|
|
// largest single thing in a vector store and was invisible before.
|
|
// largest single thing in a vector store and was invisible before.
|
|
|
- spdlog::info("Memory check: {} MB estimated ({}%, pressure={}), of which vectors {} MB, "
|
|
|
|
|
- "{} docs, {} evicted",
|
|
|
|
|
|
|
+ // v2.21.3 - plus how many vectors live in LMDB only (released).
|
|
|
|
|
+ spdlog::info("Memory check: {} MB estimated ({}%, pressure={}), of which vectors {} MB "
|
|
|
|
|
+ "({} more in LMDB only), {} docs, {} evicted",
|
|
|
stats.estimatedMemoryBytes / (1024 * 1024),
|
|
stats.estimatedMemoryBytes / (1024 * 1024),
|
|
|
pressurePercent(),
|
|
pressurePercent(),
|
|
|
memoryPressureToString(pressure()),
|
|
memoryPressureToString(pressure()),
|
|
|
stats.vectorMemoryBytes / (1024 * 1024),
|
|
stats.vectorMemoryBytes / (1024 * 1024),
|
|
|
|
|
+ releasedVectorCount(),
|
|
|
stats.totalDocuments,
|
|
stats.totalDocuments,
|
|
|
stats.evictedCount);
|
|
stats.evictedCount);
|
|
|
|
|
|
|
@@ -4235,6 +4400,14 @@ void MemoryStore::evictionLoop() {
|
|
|
|
|
|
|
|
evictionCheckCount_++;
|
|
evictionCheckCount_++;
|
|
|
|
|
|
|
|
|
|
+ // v2.21.3 - every tick, whatever the pressure: a vector LMDB holds is
|
|
|
|
|
+ // a second copy in memory (search, get and export read LMDB).
|
|
|
|
|
+ try {
|
|
|
|
|
+ releaseMirroredVectors();
|
|
|
|
|
+ } catch (const std::exception& e) {
|
|
|
|
|
+ spdlog::error("Vector release failed: {}", e.what());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// Log memory status every 12 checks (~60s with default 5s interval)
|
|
// Log memory status every 12 checks (~60s with default 5s interval)
|
|
|
if (evictionCheckCount_ % 12 == 1) {
|
|
if (evictionCheckCount_ % 12 == 1) {
|
|
|
logMemoryCheck();
|
|
logMemoryCheck();
|
|
@@ -4681,12 +4854,16 @@ bool MemoryStore::evictDocument(const std::string& collection, const std::string
|
|
|
// thing in a vector store. Only while LMDB holds the current copy; a
|
|
// thing in a vector store. Only while LMDB holds the current copy; a
|
|
|
// reload, the snapshot and the degraded search read it from there.
|
|
// reload, the snapshot and the degraded search read it from there.
|
|
|
uint64_t vectorFreed = 0;
|
|
uint64_t vectorFreed = 0;
|
|
|
|
|
+ // v2.21.3 - not one the release sweep found LMDB disagreeing with.
|
|
|
if (auto vit = coll->vectors.find(id);
|
|
if (auto vit = coll->vectors.find(id);
|
|
|
- vit != coll->vectors.end() && canReleaseVector(collection)) {
|
|
|
|
|
|
|
+ vit != coll->vectors.end() && canReleaseVector(collection) &&
|
|
|
|
|
+ coll->vectorsKeptResident.count(id) == 0) {
|
|
|
vectorFreed = estimateVectorSize(vit->second);
|
|
vectorFreed = estimateVectorSize(vit->second);
|
|
|
coll->vectors.erase(vit);
|
|
coll->vectors.erase(vit);
|
|
|
coll->vectorNorms.erase(id);
|
|
coll->vectorNorms.erase(id);
|
|
|
stub.vectorEvicted = true;
|
|
stub.vectorEvicted = true;
|
|
|
|
|
+ } else if (coll->releasedVectors.erase(id) != 0) {
|
|
|
|
|
+ stub.vectorEvicted = true; // v2.21.3 - already in LMDB only
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Remove from expiration index
|
|
// Remove from expiration index
|