Skip to content

Commit

Permalink
Merge #76307
Browse files Browse the repository at this point in the history
76307: server: add internal_app_name_prefix to ListSessionsResponse r=gtr a=gtr

Previously, the `InternalAppNamePrefix` constant from `catconstants` was
only included in the Statements Response. This change adds that same
field to the `ListSessionsResponse`.

Release note (API change): `InternalAppNamePrefix` added to `ListSessionsResponse`.

Co-authored-by: Gerardo Torres <[email protected]>
  • Loading branch information
craig[bot] and Gerardo Torres committed Feb 10, 2022
2 parents 3ac48db + 21dd242 commit c459d39
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
2 changes: 2 additions & 0 deletions docs/generated/http/full.md
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,7 @@ Response object for ListSessions and ListLocalSessions.
| ----- | ---- | ----- | ----------- | -------------- |
| sessions | [Session](#cockroach.server.serverpb.ListSessionsResponse-cockroach.server.serverpb.Session) | repeated | A list of sessions on this node or cluster. | [reserved](#support-status) |
| errors | [ListSessionsError](#cockroach.server.serverpb.ListSessionsResponse-cockroach.server.serverpb.ListSessionsError) | repeated | Any errors that occurred during fan-out calls to other nodes. | [reserved](#support-status) |
| internal_app_name_prefix | [string](#cockroach.server.serverpb.ListSessionsResponse-string) | | If set and non-empty, indicates the prefix to application_name used for statements/queries issued internally by CockroachDB. | [reserved](#support-status) |



Expand Down Expand Up @@ -1962,6 +1963,7 @@ Response object for ListSessions and ListLocalSessions.
| ----- | ---- | ----- | ----------- | -------------- |
| sessions | [Session](#cockroach.server.serverpb.ListSessionsResponse-cockroach.server.serverpb.Session) | repeated | A list of sessions on this node or cluster. | [reserved](#support-status) |
| errors | [ListSessionsError](#cockroach.server.serverpb.ListSessionsResponse-cockroach.server.serverpb.ListSessionsError) | repeated | Any errors that occurred during fan-out calls to other nodes. | [reserved](#support-status) |
| internal_app_name_prefix | [string](#cockroach.server.serverpb.ListSessionsResponse-string) | | If set and non-empty, indicates the prefix to application_name used for statements/queries issued internally by CockroachDB. | [reserved](#support-status) |



Expand Down
10 changes: 10 additions & 0 deletions docs/generated/swagger/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,11 @@
},
"x-go-name": "Errors"
},
"internal_app_name_prefix": {
"description": "If set and non-empty, indicates the prefix to application_name\nused for statements/queries issued internally by CockroachDB.",
"type": "string",
"x-go-name": "InternalAppNamePrefix"
},
"sessions": {
"description": "A list of sessions on this node or cluster.",
"type": "array",
Expand Down Expand Up @@ -1810,6 +1815,11 @@
},
"x-go-name": "Errors"
},
"internal_app_name_prefix": {
"description": "If set and non-empty, indicates the prefix to application_name\nused for statements/queries issued internally by CockroachDB.",
"type": "string",
"x-go-name": "InternalAppNamePrefix"
},
"next": {
"description": "The continuation token, for use in the next paginated call in the `start`\nparameter.",
"type": "string",
Expand Down
3 changes: 3 additions & 0 deletions pkg/server/serverpb/status.proto
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,9 @@ message ListSessionsResponse {
repeated Session sessions = 1 [ (gogoproto.nullable) = false ];
// Any errors that occurred during fan-out calls to other nodes.
repeated ListSessionsError errors = 2 [ (gogoproto.nullable) = false ];
// If set and non-empty, indicates the prefix to application_name
// used for statements/queries issued internally by CockroachDB.
string internal_app_name_prefix = 3;
}

// Request object for issuing a query cancel request.
Expand Down
6 changes: 4 additions & 2 deletions pkg/server/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/server/telemetry"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/sql"
"github.com/cockroachdb/cockroach/pkg/sql/catalog/catconstants"
"github.com/cockroachdb/cockroach/pkg/sql/contention"
"github.com/cockroachdb/cockroach/pkg/sql/flowinfra"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgwirecancel"
Expand Down Expand Up @@ -2399,8 +2400,9 @@ func (s *statusServer) listSessionsHelper(
ctx context.Context, req *serverpb.ListSessionsRequest, limit int, start paginationState,
) (*serverpb.ListSessionsResponse, paginationState, error) {
response := &serverpb.ListSessionsResponse{
Sessions: make([]serverpb.Session, 0),
Errors: make([]serverpb.ListSessionsError, 0),
Sessions: make([]serverpb.Session, 0),
Errors: make([]serverpb.ListSessionsError, 0),
InternalAppNamePrefix: catconstants.InternalAppNamePrefix,
}

dialFn := func(ctx context.Context, nodeID roachpb.NodeID) (interface{}, error) {
Expand Down
9 changes: 7 additions & 2 deletions pkg/server/tenant_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ func (t *tenantStatusServer) ListSessions(
return nil, status.Errorf(codes.Unavailable, "instanceID not set")
}

response := &serverpb.ListSessionsResponse{}
response := &serverpb.ListSessionsResponse{
InternalAppNamePrefix: catconstants.InternalAppNamePrefix,
}
nodeStatement := func(ctx context.Context, client interface{}, instanceID base.SQLInstanceID) (interface{}, error) {
statusClient := client.(serverpb.StatusClient)
localResponse, err := statusClient.ListLocalSessions(ctx, req)
Expand Down Expand Up @@ -177,7 +179,10 @@ func (t *tenantStatusServer) ListLocalSessions(
return nil, status.Errorf(codes.Unavailable, "instanceID not set")
}

return &serverpb.ListSessionsResponse{Sessions: sessions}, nil
return &serverpb.ListSessionsResponse{
Sessions: sessions,
InternalAppNamePrefix: catconstants.InternalAppNamePrefix,
}, nil
}

func (t *tenantStatusServer) CancelQuery(
Expand Down

0 comments on commit c459d39

Please sign in to comment.