fix: close SQLite connection before removing collection directory on delete#1148
fix: close SQLite connection before removing collection directory on delete#1148veeceey wants to merge 2 commits intoqdrant:devfrom
Conversation
…delete In delete_collection, the LocalCollection was popped from the collections dict and its reference deleted, but the SQLite connection was never explicitly closed. On Windows, this leaves the database file locked, preventing shutil.rmtree from removing it. The fix calls close() before directory removal, matching the pattern used in QdrantLocal.close(). Fixes qdrant#1067
✅ Deploy Preview for poetic-froyo-8baba7 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
📝 WalkthroughWalkthroughThe PR updates local Qdrant client code to close collection resources when deleting a collection in both synchronous and asynchronous implementations (close if the collection existed before removal). It reformats an assertion in Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Addressed the CodeRabbit nitpick: added |
|
All checks passing, ready for maintainer review |
|
Hi maintainers, friendly ping on this PR. It's been open a couple of days now and all checks are passing. Would appreciate it whenever you get a chance to review. Thank you for your time! |
|
Friendly bump — all checks are passing and the CodeRabbit feedback has been addressed. Would appreciate a maintainer review when you get a chance. Thanks! |
|
checking in on this - happy to make any changes if needed |
Summary
delete_collectionin local mode not explicitly closing the SQLite connection before attempting to remove the collection directory withshutil.rmtreeshutil.rmtreeto silently fail (due toignore_errors=True), leaving thestorage.sqlitefile on diskcollection.close()before directory removal in both sync (QdrantLocal) and async (AsyncQdrantLocal) implementations, matching the pattern already used inQdrantLocal.close()delete_collectionRoot Cause
In
delete_collection, theLocalCollectionwas popped from the dict anddelwas called on the variable. However,delin Python only decrements the reference count and does not guarantee the SQLite connection is closed. On Windows, the open connection holds a file lock onstorage.sqlite, preventingshutil.rmtreefrom deleting it.Test Plan
test_delete_collection_removes_storage_filesto verify that storage files are properly removed after deletiontest_local_persistence.pytests passtest_in_memory.pytests passtest_async_qdrant_client_localpassesFixes #1067