-
Notifications
You must be signed in to change notification settings - Fork 14
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
Future of wait_for_task #243
Comments
I still think that we should strongly advise against this method in production.
I so agree with this.
I am not sure that giving access to this function in the README so easily is a good idea. |
I'm not sure I like the idea that the API references in the readme are not exhaustive. We should own to our decision of keeping the method and following the moto:
Should we add in the warning that tasks are asynchronous and that they are not instantly settled? |
For me @bidoubiwa it could be any of these:
Also,
I don't think it's necessary because the docs already explain that in the docs.meilisearch.com, so I tend to think the users will not need it twice + more text to maintain. I've discussed it with @dichotommy and I'll create an issue about the subject on their side. So we will have better documentation of this method directly on the docs website. |
Just a note that this will be SDK specific. The Rust SDK for example was setup specifically to not block the thread and does an async sleep. |
For me, we should not give access to this method in the README however it will be nice to add a sentence after the getting started to underline the fact that the documents are not added instantaneously but that the API is asynchronous ❤️ ❤️ ❤️ |
I just pop to give you some legacy context. The sentence already exists but does not mention the We discussed this in the past: originally the "asynchronous" word was present (and the API link as well), and then we decided not to mention "asynchronous" (like Algolia, who always avoid using it). We indeed found out some users were "afraid" of the asynchronous word (bringing complexity for them, so some friction when starting with meilisearch). Also, However, this is something you can reconsider (the sentence can be improved without the async word for instance). I just bring more context to avoid you keeping stuck in an infinite loop of debate (especially for @bidoubiwa who is here since the beginning of the debate 😂) |
Thank you @bidoubiwa. Sharing a discussion where a user asks for a way to have a synchronous call. Also, adding that Algolia has dedicated doc pages for the subject and explains when it could be useful or not given the user's need, if it helps.
Listing crazy ideas you may want to consider, if people struggle to use waitForTask after some iterations and you decide to keep it:
|
Thanks a lot for your input @curquiza and @gmourier. It is very valuable. @curquiza
@gmourier |
I think this is a great idea to opt for better documentation since:
Knowing that, a simple iteration that better documents the usage of Do we have a way to track feedback on this? I can create a tracking table, so we can feed it over time and see how it goes. |
I allow myself to add this reflection from @sanders41 here. I know this is not exactly the topic of this conversation, but in my opinion, it somewhat joins this issue but I could open another topic of discussion elsewhere if that's easier.
Point to note:
|
The main reason we want wait for task, is because we need to make sure the API consumer receives the latest valid data. I suggest the following: All write operations that produce tasks should get an extra boolean query parameter (
|
I've pushed your idea to the product side so this way we can track it and do something about it in the future. If you think this will be important for the meilisearch-flutter @ahmednfwela let's make the |
First, thanks to everyone for your input here. I'm cleaning the repo and will give the final input on this topic to close this issue. The Dart SDK is the only SDK that does not expose a version of All the remaining SDKs will stay as they are, and I'm going to submit this discussion as part of the @meilisearch/product-team prioritization. If this is a real user need, we should find a proper solution to help them. Thanks, everyone! |
Currently in all of our sdk's we have a method named
wait_for_task
.What does this method do
wait_for_task
provides the possibility to block the current flow of your code until a task is either processed or failed. It has a default timeout time of5
seconds in most SDK's. The value of the timeout can be changed in the function parameters (same as the interval time).What is the issue
In a development environment where we mostly work on smaller datasets, tasks are fast, and this method seems to be just fine and do what we expect it to do. Nonetheless, in a production environment datasets are bigger, tasks are longer and the wait_for_task method could wait way longer for a task to be completed, longer than 5 seconds, throwing an timeout error.
This timeout behavior is not intuitive based on this method's name. Most users would expect the method to wait indefinitely for the task to be resolved. We decided to keep a timeout to protect the users from blocking their whole production flow of an infinite loop.
Nonetheless, it does not fix the issue that the user does not expect a timeout error to be thrown and that he might not realize it before he works in an environment with bigger tasks. Additionaly, the error thrown is
TimeOutError
orMeilisearchTimeOutError
, which implies an issue on the Meilisearch server side and not on the tasks duration. This makes debugging way harder.Solution
Again, to protect the user, we decided not to remove the default timeout. We also do not want to change the name to something more complex. What we want is to inform and warn the user as much as possible and make debugging and understanding the error easier.
Implementation of solution
Documentation
For a user to known this method exists, they need to find it somewhere. Wherever they find out about this method they should be met with a good explanation and a warning.
These are the places where these information should be added:
waitForTask
documentation#2171)For the information, what we suggest is something along the line of:
Error naming
The name of the error should also be updated to something more relevant:
timeOutError
orMeilisearchTimeOutError
should be renamed. Something along the lines ofWaitForTaskTimeOut
. if you have a better suggestion feel free to mention it.Additional questions
technical terms
Im not sure about the technical terms used to explain the blocking. @brunoocasali do you have any suggestion?
Additional information
Should we be way more clear on what a task is so that a user do not wonder why after adding documents, they are not immediately present in their index?
Should we also suggest using this method on other threads than the main one?
Competitors
In elasticsearch a
wait_for
parameter their refresh route that will wait for documents to be accessible in the search before responding. Based on this StackOverflow question they do not advise to use it in production. But I couldn't find this mention on elasticsearch documentation.Conclusion
What do you think ?
The text was updated successfully, but these errors were encountered: