3 ms·
For those curious: the root cause for the incident is, ultimately, degraded statistics on a table. There are a set of high frequency (very frequently run queri
by ahachete 6y ago
For those curious: the root cause for the incident is, ultimately, degraded statistics on a table.
There are a set of high frequency (very frequently run queries) that are quite sensible to plan flipping (they normally run with a given execution plan; if the plan changes to a worse one, effects can be dramatic, given their frequency).
That leads to a lot of query timeouts (GitLab's database limit query execution time to prevent further damage), which are visualized as database errors. This in turn leads to partial or complete downtime (effectively, if the database is running few effective --non timed out-- traffic).
Some of these queries depend on a particular Postgres planner way of working that is less than ideal (in PG11, it is improved in PG12), and may lead to plan flipping. Which in turn, happens when table statistics degrade. In GitLab's case, they are normally close to the threshold, and slight statistics degradation caused a plan change, which in turn lead to many queries time out and excessive load on the fleet.
At the end of the day, the fix is quite simple, however: update the table statistics (running ANALYZE). For more information: https://gitlab.com/gitlab-com/gl-infra/production/-/issues/3962#note_529314106 https://gitlab.com/gitlab-com/gl-infra/production/-/issues/3...
- hobs 6y agos/sensible/sensitive/ Would this be a place where a plan hint would help? It seems like having to re-analyze would mean that this is just a matter of time before it becomes problematic again.
- ahachete 6y ago> s/sensible/sensitive/ Thanks :) > Would this be a place where a plan hint would help? It is one option to consider (I wrote about it last week: https://gitlab.com/gitlab-com/gl-infra/production/-/issues/3875#note_528191706 https://gitlab.com/gitlab-com/gl-infra/production/-/issues/3...), but it is not an ideal solution, for several reasons. Re-analyze is not the solution either, but as a short-term measure, cron-ed ANALYZEs will be run. Longer term, apart from refactoring some queries which are quite prone to trigger this plan behavior, statistics gathering process is going to be fully reviewed.
- hobs 6y agoGotcha, that makes sense to me - refactoring queries which wanna flip would be my choice as well, just thinking that if the analyze fixes plans its (in my experience) "well we could have just used this plan anyway" - both of them are short term fixes for sure.