ExportXMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Python Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      pymongo_search_utils.drop_vector_search_index waits on the wrong condition. It never succeeds on a collection that holds more than one search index.

      Cause

      collection.drop_search_index(index_name)
      if wait_until_complete:
          wait_for_predicate(
              predicate=lambda: len(list(collection.list_search_indexes())) == 0,
              err=f"Index {index_name} did not drop in {wait_until_complete}!",
              timeout=wait_until_complete,
          )
      

      The predicate means "the collection has zero search indexes". It should mean "index_name is gone".

      Effect

      Any caller that drops one index from a collection that keeps another index waits the full timeout and then raises, even though the drop succeeded. The error message names the dropped index, so it reports a failure that did not happen.

      Found in langchain-mongodb. tests/integration_tests/test_retrievers.py::test_hybrid_retriever_auto_create_index drops text_index on a collection that keeps vector_index. The test waited 60s and failed. Because the drop did take effect, the next run found no text_index, skipped the drop, and passed. The test therefore alternated between passing and failing, and each failure forced a full-suite retry in CI.

      Suggested fix

      Wait for the named index only:

      predicate=lambda: not any(
          ix["name"] == index_name for ix in collection.list_search_indexes()
      )
      

      Consider whether the function name is still right. It drops any search index, not only a vector search index.

      Related

      INTPYTHON-1103 works around this in the langchain-mongodb test suite with a local helper, drop_search_index_and_wait. See https://github.com/langchain-ai/langchain-mongodb/pull/461. That helper should be deleted once this is fixed.

            Assignee:
            Casey Clements
            Reporter:
            Casey Clements
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: