Pinecone not visible in seach_api only after cache clear.

Created on 14 January 2025, 3 months ago

Problem/Motivation

Pinecone provider not usable in search api.
Was only usable after manually clearing the cache.

Steps to reproduce

Install pinecone provider
Enable pineconde provider
Try to choose the provider
Need to manually clear the cache.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇧🇪Belgium wouters_f Leuven

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @wouters_f
  • 🇧🇪Belgium wouters_f Leuven

    Could it be something like this that is needed?

    /**
     * Implements hook_modules_installed().
     */
    function ai_modules_installed(array $modules) {
      // Clear the provider cache when a module is installed.
      \Drupal::cache('discovery')->delete('ai_provider_plugins');
    }
    
  • 🇬🇧United Kingdom scott_euser

    Drupal should clear the cache when module installed, perhaps when pinecone is configured? Setting back to active as there isn't an MR

  • 🇮🇳India Vivek Panicker Kolkata

    @wotuers_f I see that the code is already there in the AI Core module.
    I think what is happening is that when we try to access the providers page, VdbProvidersAccessChecker::access() gets called.
    It then calls AiVdbProviderPluginManager::getProviders which calls AzureAiSearchProvider::isSetup, which returns FALSE as we have not configured the API key yet.
    And this response gets cached.
    So I feel that after we have configured the API key, we should to rebuild the routing cache or refresh the access policy for the page or something.

  • 🇬🇧United Kingdom scott_euser

    Updated issue summary given this is an issue in any VDB provider (see https://drupal.slack.com/archives/CDL2YPBNX/p1737390223024339 where it was raised for Azure VDB Provider).

    Moving to AI module.

    Suggested a solution in issue summary.

  • Merge request !420Add starter code for this → (Open) created by scott_euser
  • 🇬🇧United Kingdom scott_euser

    Untested but I believe something like this should do it. Could one of you confirm please?

  • 🇮🇳India Vivek Panicker Kolkata

    @scott, the patch did not work for me.
    I applied the patch, enabled the Azure VDB provider module and still the page was not showing the provider.
    What worked for me is commenting out this code, then installing the module:

          if ($setup && !$instance->isSetup()) {
            continue;
          }
    

    So I think we need to change something in this front.

  • 🇬🇧United Kingdom scott_euser

    It shouldn't appear until it's set up though

  • 🇬🇧United Kingdom scott_euser

    Maybe there is a vbd provider manager service or something that needs a cache tag invalidated perhaps... Haven't looked

  • 🇬🇧United Kingdom MrDaleSmith

    We've got ai/src/Cache/Context/AIProvidersCacheContext.php that gets invalidated every time a new provider is added (VDB or otherwise) so it should just be a case of ensuring that context is added to the search api form?

  • 🇬🇧United Kingdom seogow

    @mrdalesmith & @scott_euser will you follow or should I investigate further on Wednesday, 22 January 2025?

  • 🇬🇧United Kingdom scott_euser

    Re #13 I don't think you can invalidate a context; we need some mechanism to invalidate the cache each time a VDB Provider settings form is updated.

    Personally tried to reproduce this now in default Drupal install with caching enabled but I cannot:

    1. Enabled Pinecone without configuring
    2. Went to add Search API Server and choose AI Search as backend. Pinecone not in list as expected
    3. Configured Pinecone
    4. Refreshed add Search API Server and choose AI Search as backend. Pinecone is now in list as expected

    But given multiple reports of it, it seems like I must be doing something wrong to reproduce

  • 🇬🇧United Kingdom scott_euser

    @seogow re #14 great if you manage to get further, I'm hitting a dead end. Thanks!

  • 🇬🇧United Kingdom MrDaleSmith

    You wouldn't need to invalidate the context - it invalidates itself whenever any new provider is added - but if we need to have a cache clear if the plugin settings are changed as well, then we'd need to add the cache tags of the VDB providers to the form (and create cache tags for them if plugins don't get those by default). I think that would be the most Drupal way to resolve the issue?

  • 🇮🇳India prashant.c Dharamshala

    I am trying to replicate, but it seems to be working fine:

    • Tried on Vanilla Drupal 11 instance
    • Database server with search index already configured
    • Configured the Milvus DB provider, which was connected successfully
    • Added a new server with "AI server" and in that "Milvus DB" was available
    • I have caching enabled, and while doing the above steps, I did not clear cache

    Steps to reproduce: "Go back to search API index and expect to see VDB provider, but have to clear cache to see it." Are we expecting some new option in the Search index, in addition to the Search API server?

    Am I missing something to reproduce this?

    Thanks

  • 🇮🇳India Vivek Panicker Kolkata

    I think you have followed the proper steps.
    Maybe we can have 1 more person give it a try, and if if it's not reproducible, we can close the issue.

  • 🇮🇳India annmarysruthy

    Tried replicating issue in local ddev drupal 11 setup.

    1. cache is already enabled in site.
    2. Installed Milvus VDB Provider module
    3. Tried creating a new server and No VDB provider found
    4. Configured Milvus VDB Provider module and connected successfully
    5. On creating a new server, Milvus DB is now available without clearing cache
  • 🇮🇳India Vivek Panicker Kolkata

    We can close the issue then!

Production build 0.71.5 2024