babenkoivan / elastic-scout-driver

Elasticsearch driver for Laravel Scout
MIT License
253 stars 33 forks source link

No alive nodes locks entire app #23

Closed chrisgrim closed 3 years ago

chrisgrim commented 3 years ago

I allow users to save events on my site. Everything works great unless the ES nodes go down. Then if a user tries to save something it sends back the error no alive nodes on your server and wont let them do anything. I figure this is how its supposed to work, but is there a way to allow the app to continue to save to the database even if the ES save doesn't work because the server is down?

babenkoivan commented 3 years ago

Hi @chrisgrim, I think the best approach would be to enable queues. In this case, even if an error happens, the indexing operation would be most likely retried and you wouldn't block your users and wouldn't lose any data.

If this not possible, then you can wrap model saving in a try/catch block and either retry in a few seconds or continue the execution. Scout indexes data on the saved event, which is happening after a record was inserted in the table.

chrisgrim commented 3 years ago

Exciting! Do you happen to know of any good tutorials for enable queues? I am always a little bit weary when I have to setup a new server like Redis. I will also look into the try/catch to see if I can beat the problem that way. Thanks so much for the response!

babenkoivan commented 3 years ago

Hey @chrisgrim, I think the best knowledge source is the official Laravel documentation 🙂

chrisgrim commented 3 years ago

Haha ok thanks :)