From 5d2563820d3338893db97d22f8e9764ae00ba352 Mon Sep 17 00:00:00 2001 From: Xin Hao Zhang Date: Mon, 19 Sep 2022 10:57:30 -0400 Subject: [PATCH] server: return all completed stmt diag requests Fixes #80104 Previously, we only return statement diagnostics requests that have not yet expired. Since we use the results of this request to populate completed statement diagnostics bundles in addition to outstanding requests, completed statement diag bundles would disappear from the UI after the request expired. This commit ensures that `StatementDiagnosticsRequests` returns all completed stmt diag requests so that we can display the complete history of completed bundles in the UI. Release note (bug fix): completed stmt diagnostics bundles now persist in the UI in stmt diag bundle pages --- pkg/server/statement_diagnostics_requests.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/server/statement_diagnostics_requests.go b/pkg/server/statement_diagnostics_requests.go index 3b2a042b1b16..d0ded957d24c 100644 --- a/pkg/server/statement_diagnostics_requests.go +++ b/pkg/server/statement_diagnostics_requests.go @@ -118,7 +118,7 @@ func (s *statusServer) CancelStatementDiagnosticsReport( // StatementDiagnosticsRequests retrieves all statement diagnostics // requests in the `system.statement_diagnostics_requests` table that -// have not yet expired. +// have either completed or have not yet expired. func (s *statusServer) StatementDiagnosticsRequests( ctx context.Context, _ *serverpb.StatementDiagnosticsReportsRequest, ) (*serverpb.StatementDiagnosticsReportsResponse, error) { @@ -182,7 +182,7 @@ func (s *statusServer) StatementDiagnosticsRequests( if expiresAt, ok := row[6].(*tree.DTimestampTZ); ok { req.ExpiresAt = expiresAt.Time // Don't return already expired requests. - if req.ExpiresAt.Before(timeutil.Now()) { + if !completed && req.ExpiresAt.Before(timeutil.Now()) { continue } }