nickna / Neighborly

An open-source vector database
MIT License
9 stars 2 forks source link

Lock `VectorDatabase` for `Save()` #29

Closed hangy closed 4 weeks ago

hangy commented 4 weeks ago

https://github.com/nickna/Neighborly/blob/30f68bb1d294824f031d1e89758b5026124bf21f/Neighborly/VectorDatabase.cs#L392-L418

I think this might need _rwLock.EnterWriteLock();, as the _isDirty is only set after an item has been added. The method uses direct index access to _vectors, which means that concurrent calls that modify the database during a call to Save could cause corruption.

hangy commented 4 weeks ago

Fixed in 4f68e9a4ba30bcbead025c52437f13a319b15993