1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Implemented Cache posts for later insertion if Elasticsearch service is offline.

Discussion in 'Enhanced Search Suggestions' started by Slavik, Jan 20, 2012.

  1. Slavik

    Slavik XenForo Moderator Staff Member

    As per title realy.

    Would be good that if the Elasticsearch stopped responding, that on an error the post that was missed out gets added to a backup mysql table, so once the admin has fixed the issue, he has an option to re-hand those posts over to Elasticsearch to be indexed without requiring a full re-index.

    Don't think it would be too hard either? Just have a script to parse the stack trace the logs throw up on error and extract the required information.
    DBA, Dinh Thanh, CyclingTribe and 4 others like this.
  2. Deebs

    Deebs Well-Known Member

    Very good suggestion. Thinking out loud:
    1. Insert post into main post table
    2. Insert postid into a xf_tobe_indexed table
    3. Cron job runs every x minutes scanning the xf_tobe_indexed table, if entries, index and add to ES
    4. blah blah
    Obviously with all the error trapping gubbings wrapped around etc.
    D.O.A. and GeeksChat like this.
  3. lazy llama

    lazy llama Well-Known Member

    Sounds like a good idea, and is pretty much how the SphinxSearch add-on works out which posts to add to the delta.
    Could even borrow the code ;)
    Deebs likes this.
  4. Walter

    Walter Well-Known Member

    Definitely useful.
    longanh likes this.
  5. James

    James Well-Known Member


    just kiddin', it's a great idea and I'd be surprised if it wasn't already on the developers cards.
  6. digitalpoint

    digitalpoint Well-Known Member

    I just saw this after making a semi-related suggestion...


    It would be much easier to implement a secondary hostname for reads/writes if the primary ElasticSearch node is down. ElasticSearch is made to shard and replicate across multiple servers... and site big enough to use it are probably going to be running it on multiple servers (at least they should be).
    TheComputerGuy likes this.
  7. Slavik

    Slavik XenForo Moderator Staff Member

    Consider the smaller large boards not using a multi server setup, how would they handle such failover?
  8. digitalpoint

    digitalpoint Well-Known Member

    I guess they wouldn't... but I would *think* a site big enough to need it would have multiple servers (even if it's just 1 web server and 1 db server)... no?
    TheComputerGuy likes this.
  9. Slavik

    Slavik XenForo Moderator Staff Member

    Each site is different obviously, but I know of more sites running ES who only have one server than those who have 2 or more.
    pjfry, Rob Fritz and lazy llama like this.
  10. TheComputerGuy

    TheComputerGuy Active Member

    I only run one server...but I don't understand why would ES be offline?
  11. Slavik

    Slavik XenForo Moderator Staff Member

    An error with the ES service, maybe some firewall issues, upgrading ES... anything which may cause ES to stop responding to XenForo
  12. TheComputerGuy

    TheComputerGuy Active Member

    How common is this happening? Sure redundancy is great, but I prefer something that has a much higher uptime rate...
  13. Slavik

    Slavik XenForo Moderator Staff Member

    Not very... but it can happen.
  14. Rudy

    Rudy Well-Known Member

    What about this? Rather than cache the posts, create a way for XF to alert the admins that ES has stopped working. That would give the admins the opportunity to restart ES (if they have permission) and rebuild the indexes.

    Additional option? Have a cron job setup in XF to automatically reindex the forum after ES is restarted, with some sort of "flag" where XF could indicate whether its search index is out of date or not. I realize that some busy servers cannot handle a reindex during peak hours, but I have found that the reindexing of ES (or even Sphinx for that matter) never put a terribly crushing load on our servers...and we are beyond 8 million posts now.

    Not quite the caching idea, but at least some sort of safeguard to let admins know ES has stopped and the indexes are stale.
  15. Mike

    Mike XenForo Developer Staff Member

    XFES 1.1 has a system to do this. (Specifically, with a 1/2/4/8/16 hour delay between attempts for each failure, before finally giving up.)
    Rudy, Walter, digitalpoint and 2 others like this.
  16. Rudy

    Rudy Well-Known Member

    XFES 1.1 is a future release, then? Only asking since we had a couple of server hiccups and I want to know if I should go and regenerate the search index for the time being.
  17. Brogan

    Brogan XenForo Moderator Staff Member

  18. Rudy

    Rudy Well-Known Member

    Interesting--I may give it a try on our private "testing" forum. I like the relevance improvement--slick! If the ETA is a month or two out, I'll refrain from using it on our production forum (although I've never had problems with XF beta software in the past).

    CyclingTribe likes this.
  19. CyclingTribe

    CyclingTribe Well-Known Member

    Yup, caching and relevance (especially with the date-based weighting) will be very welcome. Thanks guys. (y)
  20. Rudy

    Rudy Well-Known Member

    It definitely will help with the bias on newer vs. older threads. We have threads from twelve years ago that sometimes get dragged out of obscurity. (I personally would rather close all threads more than a year old, as we used to, but I have some hesitation from other staffers in doing so.) The problem on our forum is that over the course of three or four years, products change, new products come out, our opinions might change, etc. And many members find themselves replying to a thread a second time, several years later, often with the same thought they had several years ago while not realizing the thread is stale. Pushing those down in the search results certainly will help pull up more current threads.
    CyclingTribe likes this.

Share This Page