DEV: Add more debugging information to AR query logs on GitHub actions (#25237)

Why this change?

We have been chasing a problem with our flaky system test where the user
is logged out when it should never be.

What does this change do?

1. Logs the request path when lookup a user auth token.
2. Logs the request path and also the current thread's object id in
   ActiveRecord query logs.
This commit is contained in:
Alan Guo Xiang Tan
2024-01-12 13:06:29 +08:00
committed by GitHub
parent 80b93e06f7
commit c76ca876a6
2 changed files with 17 additions and 1 deletions

View File

@@ -122,13 +122,19 @@ class UserAuthToken < ActiveRecord::Base
expire_before = SiteSetting.maximum_session_age.hours.ago
user_token =
find_by(
where(
"(auth_token = :token OR
prev_auth_token = :token) AND rotated_at > :expire_before",
token: token,
expire_before: expire_before,
)
if SiteSetting.verbose_auth_token_logging && path = opts.dig(:path)
user_token = user_token.annotate("path:#{path}")
end
user_token = user_token.first
if !user_token
log_verbose(
action: "miss token",