Changing the date while dashboard visualization queries are still running results in race condition
Problem
Visualizations can execute longer-running queries when dealing with longer date ranges or a larger volume of data. Then, if you change the date, you execute a new set of queries.
However, they will update the visualization accordingly depending on when the queries finish. This results in a race condition as some visualizations may have simpler queries that execute faster than others, effectively showing you data from two different date ranges requested.
This is most noticeable when using the custom date range picker, as each selection launches a new set of queries, so if I set a custom date range of 30 days then change it to 14 days, I may see data from the 30 days queries as they took longer to execute and may have been returned after the 14 days queries had already finished.
This is easily verified in the .com Product Analytics dashboards.
Proposal
Cancel or discard currently running queries when a new date range is selected or when new queries are made, e.g., excluding anonymous users.
Implementation plan
See proposed patch