Fixed #3711, #6734, #12581 -- Bounded connection.queries.

Prevented unlimited memory consumption when running background tasks
with DEBUG=True.

Thanks Rob, Alex, Baptiste, and others.
I never came across `reset_queries()` before and have done `connection.queries = []` in tests. I think `reset_queries()` needs to be documented somewhere.