Query cache for load balancer prevents busting the SQL cache in a console

Sometimes when using a Rails console it's useful to force a re-query from the database (e.g. to pick up changes made outside said console). Normally the reload method on a model object or association would work, or even just executing another find. But with DB load balancing and with the query cache enabled on the host (https://gitlab.com/gitlab-org/gitlab/-/blob/5a72461ae48319e513aa1ed2d91efe9a206bab97/lib/gitlab/database/load_balancing/load_balancer.rb#L234; see !49708 (diffs) for where it was permanently enabled, although that code has moved now), this no longer works; all attempts to fetch a fresh object go to the cache.

It's only a problem with load balancing enabled, so many/most installations and GDK instances won't see this, but the gitlab.com staging and production instances definitely do.

@stanhu found that commenting out that host.enable_query_cache! line fixes this problem, although I make no suggestion of that as a solution (it's just a data point).

There is a (hacky) workaround (thanks to @tkuah) with something like:

ActiveRecord::Base.transaction { Project.find(<id>) }

but that's probably not a real solution (just a workaround while the problem exists).

This was discussed internally in Slack (90-day retention).