Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql/pgwire: add telemetry for interleaved portal requests #43797

Merged
merged 1 commit into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/sql/pgwire/command_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import (
"context"
"fmt"

"github.com/cockroachdb/cockroach/pkg/server/telemetry"
"github.com/cockroachdb/cockroach/pkg/sql"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgwirebase"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sessiondata"
"github.com/cockroachdb/cockroach/pkg/sql/sqlbase"
"github.com/cockroachdb/cockroach/pkg/sql/sqltelemetry"
"github.com/cockroachdb/errors"
"github.com/lib/pq/oid"
)
Expand Down Expand Up @@ -407,6 +409,7 @@ func (r *limitedCommandResult) moreResultsNeeded(ctx context.Context) error {
// the cleanup. We are in effect peeking to see if the
// next message is a delete portal.
if c.Type != pgwirebase.PreparePortal || c.Name != r.portalName {
telemetry.Inc(sqltelemetry.InterleavedPortalRequestCounter)
return errors.WithDetail(sql.ErrLimitedResultNotSupported,
"cannot close a portal while a different one is open")
}
Expand All @@ -418,6 +421,7 @@ func (r *limitedCommandResult) moreResultsNeeded(ctx context.Context) error {
case sql.ExecPortal:
// The happy case: the client wants more rows from the portal.
if c.Name != r.portalName {
telemetry.Inc(sqltelemetry.InterleavedPortalRequestCounter)
return errors.WithDetail(sql.ErrLimitedResultNotSupported,
"cannot execute a portal while a different one is open")
}
Expand All @@ -438,6 +442,7 @@ func (r *limitedCommandResult) moreResultsNeeded(ctx context.Context) error {
}
default:
// We got some other message, but we only support executing to completion.
telemetry.Inc(sqltelemetry.InterleavedPortalRequestCounter)
return errors.WithSafeDetails(sql.ErrLimitedResultNotSupported,
"cannot perform operation %T while a different portal is open",
errors.Safe(c))
Expand Down
4 changes: 4 additions & 0 deletions pkg/sql/sqltelemetry/pgwire.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ var BinaryDecimalInfinityCounter = telemetry.GetCounterOnce("pgwire.#32489.binar
// UncategorizedErrorCounter is to be incremented every time an error
// flows to the client without having been decorated with a pg error.
var UncategorizedErrorCounter = telemetry.GetCounterOnce("othererror." + pgcode.Uncategorized)

// InterleavedPortalRequestCounter is to be incremented every time an open
// portal attempts to interleave work with another portal.
var InterleavedPortalRequestCounter = telemetry.GetCounterOnce("pgwire.#40195.interleaved_portal")