Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to delete virtual replica #1377

Open
lamontadams opened this issue Jan 3, 2022 · 4 comments
Open

Unable to delete virtual replica #1377

lamontadams opened this issue Jan 3, 2022 · 4 comments

Comments

@lamontadams
Copy link

lamontadams commented Jan 3, 2022

How does one go about deleting a virtual replica index?

Looking at the published documentation at

It seems as though this should work, assuming a "main" index named "main" and a virtual replica named "virtual":

const client = algoliaSearch(ID, KEY);
const main = client.initIndex('main');
await main.setSettings({
    replicas: []
  });
const virtualIndex = client.initIndex('virtual');
await virtualIndex.delete();

However, the call to initIndex for 'virtual' yields this error response:

{
  name: 'ApiError',
  message: 'cannot apply a add object request on a replica index',
  status: 403,
}

Is there some way other than initIndex that I'm supposed to be getting a reference to a virtual replica index?

@Haroenv
Copy link
Contributor

Haroenv commented Jan 4, 2022

I'm not sure how you could have an "add object" error in code that doesn't mention addObject, but what I assume is happening is that your are waiting for the network requests, but not for the actual operations to be finished. You can opt in to that behaviour by writing await main.setSettings({}).wait() etc.

@lamontadams
Copy link
Author

Yeah, thanks. That's what I'm apparently missing, my code seems to be racing the settings update of the main index.

The fact that this is needed isn't clear at all from any of the documentation I've looked at, and that error message is definitely less than helpful.

@Haroenv
Copy link
Contributor

Haroenv commented Jan 4, 2022

You received that error message from the API from the code you sent, without adding any new objects? That definitely seems like an issue I'll forward to the api team then!

Waiting for the tasks is in general not needed very often, but seems like it would be in this specific case where you want to recreate the same index as non-replica, and thus need to wait for the deletion to be done.

@Haroenv Haroenv reopened this Jan 4, 2022
@lamontadams
Copy link
Author

Yeah this is an unusual case for sure. I'm working around an issue with the terraform provider I'm using, which causes my script to fail when I apply it against an existing virtual replica index. Deleting existing virtual replicas beforehand is brute force but it does work around the issue...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants