Skip to content
Back

Creating indexes immediately after creating string attributes often fails

  • 0
  • Databases
  • Cloud
Binyamin
7 Jun, 2023, 13:43

Try to wait one second for each attribute you're adding.

TL;DR
Issue: Creating indexes immediately after creating string attributes often fails There is currently a limitation with creating indexes immediately after creating string attributes in the project. This can render the creation unusable for the hackathon. There is no ETA for when this limitation will be resolved. As a workaround, you can try asynchronously handling creates with some sort of retry later approach. Additionally, there are some database operations that can lock up the database and take up to 30 minutes to complete at times. To handle errors, you can try using a try/catch block and retrying until the index creation completes.
saricden
7 Jun, 2023, 13:44

Hmm okay, I can try that

saricden
7 Jun, 2023, 13:44

Actually wait

saricden
7 Jun, 2023, 13:44

I might try to add some more elegant error handling

saricden
7 Jun, 2023, 13:45

I can try / catch the errors when creating indexes and retry automatically until it completes

Binyamin
7 Jun, 2023, 13:45

Yes, that can work

Binyamin
7 Jun, 2023, 13:46

You can even try and use this https://appwrite.io/docs/server/databases?sdk=nodejs-default#databasesGetAttribute To see if you're getting the attribute

saricden
7 Jun, 2023, 13:46

Oh nice idea

saricden
7 Jun, 2023, 13:46

Yeah

Binyamin
7 Jun, 2023, 13:47

Then maybe something like this.

TypeScript
while(true){
  try {
    await databases.getAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '');
    break;
  } catch (e) {
    await sleep(1000);
  }
}
saricden
7 Jun, 2023, 13:48

Right yeah! Thanks 😄

Drake
7 Jun, 2023, 17:20

FYI, at the moment, there are some times throughout the day where these operations can take up to 30 minutes to complete

saricden
7 Jun, 2023, 17:37

Oh wow. Is this only the case if there's a lot of data in the collections already?

In my case the collections will always be empty when I'm running this.

Drake
7 Jun, 2023, 17:38

no. there are some database operations that lock up the database 😕 we're working on improving this

saricden
7 Jun, 2023, 17:41

Okay, shoot. This limitation would kind of render my creation for the hackathon unusable I'm afraid.

What kind of ETA do you think can be expected on this?

Any chance it's before the hackathon ends? 😂

Drake
7 Jun, 2023, 17:43

This limitation would kind of render my creation for the hackathon unusable I'm afraid.

Do you only have 1 project?

What kind of ETA do you think can be expected on this?

Sorry, I don't have an ETA

saricden
7 Jun, 2023, 18:09

Yeah just the one project, it's basically done except for this part I was doing last night.

I do have it working and it was feeling fine with my tests last night, but I'll likely need to think of a different way to handle this knowing of this limitation.

saricden
7 Jun, 2023, 18:10

@Steven would I be able to DM you to provide more details that are currently kind of private?

Perhaps you'll see a way of working around the issue

Drake
7 Jun, 2023, 18:10

so the 30 minute delay will only happen once a day...and it's at the same time every day 😬

Drake
7 Jun, 2023, 18:11

asynchronously handling creates with some sort of retry later would be the best approach

saricden
7 Jun, 2023, 18:13

@Steven yeah I'm wondering if maybe I can schedule it as a function or something and have some features disabled until the indexes are created

saricden
7 Jun, 2023, 18:13

Like on a recurring cron or something

saricden
7 Jun, 2023, 18:13

Still not ideal but it'd work in the meantime

saricden
7 Jun, 2023, 18:16

Would it be appropriate to provide you with a better context over DM @Steven?

Drake
7 Jun, 2023, 18:40

sure

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more