Stack Exchange Network Status

Here we'll post updates on outages and maintenance windows for the Stack Exchange Network. You can also get status updates by following @StackStatus
Here we'll post updates on outages and maintenance windows for the Stack Exchange Network. You can also get status updates by following @StackStatus
  • rss
  • archive
  • Outage Postmortem - July 20, 2016

    Overview

    On July 20, 2016 we experienced a 34 minute outage starting at 14:44 UTC. It took 10 minutes to identify the cause, 14 minutes to write the code to fix it, and 10 minutes to roll out the fix to a point where Stack Overflow became available again.

    The direct cause was a malformed post that caused one of our regular expressions to consume high CPU on our web servers. The post was in the homepage list, and that caused the expensive regular expression to be called on each home page view. This caused the home page to stop responding fast enough. Since the home page is what our load balancer uses for the health check, the entire site became unavailable since the load balancer took the servers out of rotation.

    Follow-up Actions

    • Audit our regular expressions and post validation workflow for any similar issues
    • Add controls to our load balancer to disable the healthcheck – as we believe everything but the home page would have been accessible if it wasn’t for the the health check
    • Create a “what to do during an outage” checklist since our StackStatus Twitter notification was later than we would have liked (and a few other outage workflow items we would like to be more consistent on).

    Technical Details

    The regular expression was: ^[\s\u200c]+|[\s\u200c]+$ Which is intended to trim unicode space from start and end of a line. A simplified version of the Regex that exposes the same issue would be \s+$ which to a human looks easy (“all the spaces at the end of the string”), but which means quite some work for a simple backtracking Regex engine. The malformed post contained roughly 20,000 consecutive characters of whitespace on a comment line that started with -- play happy sound for player to enjoy. For us, the sound was not happy.

    If the string to be matched against contains 20,000 space characters in a row, but not at the end, then the Regex engine will start at the first space, check that it belongs to the \s character class, move to the second space, make the same check, etc. After the 20,000th space, there is a different character, but the Regex engine expected a space or the end of the string. Realizing it cannot match like this it backtracks, and tries matching \s+$ starting from the second space, checking 19,999 characters. The match fails again, and it backtracks to start at the third space, etc.

    So the Regex engine has to perform a “character belongs to a certain character class” check (plus some additional things) 20,000+19,999+19,998+…+3+2+1 = 199,990,000 times, and that takes a while. This is not classic catastrophic backtracking (talk on backtracking) (performance is O(n²), not exponential, in length), but it was enough. This regular expression has been replaced with a substring function.

    • July 20, 2016 (8:47 pm)
    1. spartancat7 liked this
    2. permutatrix liked this
    3. dedhomum liked this
    4. wtshibal liked this
    5. sunbathersunbather liked this
    6. sanya-nya reblogged this from stackstatus
    7. ritec reblogged this from stackstatus
    8. fuzzyhorns liked this
    9. thebramp liked this
    10. joeshorriblepuns reblogged this from stackstatus
    11. bakphooon liked this
    12. randomphilosophyideas liked this
    13. 143tinyhorses reblogged this from allthatglitchesisgold
    14. insanejapanesesquirrel reblogged this from ghaabor
    15. ghaabor reblogged this from stackstatus
    16. ghaabor liked this
    17. cjmlgrto liked this
    18. x0r liked this
    19. luisherlock liked this
    20. ununnilium liked this
    21. asmeikal liked this
    22. iamabiguy liked this
    23. longestpathsearch reblogged this from stackstatus
    24. longestpathsearch liked this
    25. xogrouptech reblogged this from stackstatus and added:
      Love the detail in the postmortem. Simple reminder: always use the simplest possible health check for your load...
    26. mymomsdog liked this
    27. jazzinsilhouette reblogged this from wabbeldabbel and added:
      This is a personal pet peeve of mine. They used n·(n-1)/2 instead of n·(n+1)/2, thus calculating only the sum of the...
    28. funkeyfreak reblogged this from stackstatus
    29. funkeyfreak liked this
    30. kernalphage reblogged this from stackstatus
    31. kernalphage liked this
    32. ebertek liked this
    33. jurvis liked this
    34. imabug liked this
    35. needsmoresalt liked this
    36. kkapadia liked this
    37. honoluabay liked this
    38. viva64 reblogged this from stackstatus
    39. goatsgomoo reblogged this from stackstatus
    40. from-away reblogged this from stackstatus
    41. from-away liked this
    42. neelkadia liked this
    43. avimehenwal reblogged this from stackstatus
    44. avimehenwal liked this
    45. gerrymanderring liked this
    46. joeshorriblepuns liked this
    47. stackstatus posted this
    48. Show more notesLoading...
© 2012–2018 Stack Exchange Network Status