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

Client allows endless loops if there is a network issue #390

Open
kaspergrubbe opened this issue May 31, 2020 · 4 comments
Open

Client allows endless loops if there is a network issue #390

kaspergrubbe opened this issue May 31, 2020 · 4 comments

Comments

@kaspergrubbe
Copy link

  • Algolia Client Version: Only tested 1.26.0
  • Language Version: Not relevant.

Description

This is basically an endless loop:

#
# Wait the publication of a task on the server.
# All server task are asynchronous and you can check with this method that the task is published.
#
# @param index_name the index name owning the taskID
# @param taskID the id of the task returned by server
# @param time_before_retry the time in milliseconds before retry (default = 100ms)
# @param request_options contains extra parameters to send with your query
#
def wait_task(index_name, taskID, time_before_retry = WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options = {})
loop do
status = get_task_status(index_name, taskID, request_options)
if status == 'published'
return
end
sleep(time_before_retry.to_f / 1000)
end
end

There should be some retry logic, and if enough fails it should throw an error.

@DevinCodes
Copy link

Related: when perform a save_objects! with an empty batch, the taskID returned from the engine never resolves, resulting in this loop running forever.

client = ::Algolia::Search::Client.create_with_config(
::Algolia::Search::Config.new(
application_id: ENV['ALGOLIA_APP_ID'],
api_key: ENV['ALGOLIA_ADMIN_API_KEY'],
batch_size: ENV['ALGOLIA_BATCH_SIZE']
)
)

index = client.init_index('test-index-name')
index.save_objects!([]) # Hangs forever

We'll need to come up with a proper way to break here after x loops to prevent the infinite loop. I'll discuss this internally to see what we want to do about it.

@berniechiu
Copy link

berniechiu commented Sep 30, 2021

thanks for looking into the issue : )

@kaspergrubbe
Copy link
Author

This code still seem to be causing endless loops when there's issues on Algolias servers.

https://status.algolia.com/incidents/4367

@kaspergrubbe
Copy link
Author

@chuckmeyer reached out to me on Twitter, and pointed me to this PR: #487

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

3 participants