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: capture index usage statistics bug with database names containing hyphen character #85577

Closed
THardy98 opened this issue Aug 3, 2022 · 0 comments · Fixed by #87525
Closed
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Comments

@THardy98
Copy link

THardy98 commented Aug 3, 2022

Describe the problem

The placeholder string query used when capturing index usage statistics for telemetry is unable to parse database names that contain a hyphen character.

Stack Trace

W220803 20:53:37.952938 251 sql/scheduledlogging/captured_index_usage_stats.go:153  [nsql1] 35  error capturing index usage stats: capture-index-usage-stats: at or near "-": syntax error
W220803 20:53:37.952938 251 sql/scheduledlogging/captured_index_usage_stats.go:153  [nsql1] 35 +(1) attached stack trace
W220803 20:53:37.952938 251 sql/scheduledlogging/captured_index_usage_stats.go:153  [nsql1] 35 +  -- stack trace:
W220803 20:53:37.952938 251 sql/scheduledlogging/captured_index_usage_stats.go:153  [nsql1] 35 +  | github.com/cockroachdb/cockroach/pkg/sql.(*InternalExecutor).execInternal.func1
W220803 20:53:37.952938 251 sql/scheduledlogging/captured_index_usage_stats.go:153  [nsql1] 35 +  | 	github.com/cockroachdb/cockroach/pkg/sql/internal.go:671
W220803 20:53:37.952938 251 sql/scheduledlogging/captured_index_usage_stats.go:153  [nsql1] 35 +  | github.com/cockroachdb/cockroach/pkg/sql.(*InternalExecutor).execInternal
W220803 20:53:37.952938 251 sql/scheduledlogging/captured_index_usage_stats.go:153  [nsql1] 35 +  | 	github.com/cockroachdb/cockroach/pkg/sql/internal.go:691
W220803 20:53:37.952938 251 sql/scheduledlogging/captured_index_usage_stats.go:153  [nsql1] 35 +  | github.com/cockroachdb/cockroach/pkg/sql.(*InternalExecutor).QueryIteratorEx
W220803 20:53:37.952938 251 sql/scheduledlogging/captured_index_usage_stats.go:153  [nsql1] 35 +  | 	github.com/cockroachdb/cockroach/pkg/sql/internal.go:567
W220803 20:53:37.952938 251 sql/scheduledlogging/captured_index_usage_stats.go:153  [nsql1] 35 +  | github.com/cockroachdb/cockroach/pkg/sql/scheduledlogging.captureIndexUsageStats
W220803 20:53:37.952938 251 sql/scheduledlogging/captured_index_usage_stats.go:153  [nsql1] 35 +  | 	github.com/cockroachdb/cockroach/pkg/sql/scheduledlogging/captured_index_usage_stats.go:199
W220803 20:53:37.952938 251 sql/scheduledlogging/captured_index_usage_stats.go:153  [nsql1] 35 +  | github.com/cockroachdb/cockroach/pkg/sql/scheduledlogging.(*CaptureIndexUsageStatsLoggingScheduler).start.func1
W220803 20:53:37.952938 251 sql/scheduledlogging/captured_index_usage_stats.go:153  [nsql1] 35 +  | 	github.com/cockroachdb/cockroach/pkg/sql/scheduledlogging/captured_index_usage_stats.go:151
W220803 20:53:37.952938 251 sql/scheduledlogging/captured_index_usage_stats.go:153  [nsql1] 35 +  | github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTaskEx.func2
W220803 20:53:37.952938 251 sql/scheduledlogging/captured_index_usage_stats.go:153  [nsql1] 35 +  | 	github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:494
W220803 20:53:37.952938 251 sql/scheduledlogging/captured_index_usage_stats.go:153  [nsql1] 35 +Wraps: (2) capture-index-usage-stats
W220803 20:53:37.952938 251 sql/scheduledlogging/captured_index_usage_stats.go:153  [nsql1] 35 +Wraps: (3) source SQL:

Erroneous Query in Question
image (3)

Location of Code Change

FROM %s.crdb_internal.index_usage_statistics AS us

The placeholder string value needs double-quotes surrounding the database name placeholder.

To Reproduce

Run the query with any database name that contains a hyphen.

Expected behavior
Should be able to handle database names that contain a hyphen.

Jira issue: CRDB-18321

@THardy98 THardy98 added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-observability labels Aug 3, 2022
@THardy98 THardy98 changed the title sql: capture index usage statistics bug with database names containing - sql: capture index usage statistics bug with database names containing a hyphen - Aug 3, 2022
@THardy98 THardy98 changed the title sql: capture index usage statistics bug with database names containing a hyphen - sql: capture index usage statistics bug with database names containing - (hyphen character) Aug 3, 2022
@THardy98 THardy98 changed the title sql: capture index usage statistics bug with database names containing - (hyphen character) sql: capture index usage statistics bug with database names containing - Aug 3, 2022
@THardy98 THardy98 changed the title sql: capture index usage statistics bug with database names containing - sql: capture index usage statistics bug with database names containing hyphen character Aug 3, 2022
@xinhaoz xinhaoz self-assigned this Aug 24, 2022
xinhaoz added a commit to xinhaoz/cockroach that referenced this issue Sep 7, 2022
Fixes cockroachdb#85577

This commit fixes a bug where the query constructed during
index usage stats recording failed for db names containing
a hyphen. The db name placeholder is now wrapped in double
quotes so the db name can be recognized in the query.

Release justification: bug fix

Release note (bug fix): index usage stats are properly captured
for database names with hyphens
xinhaoz added a commit to xinhaoz/cockroach that referenced this issue Sep 8, 2022
Fixes cockroachdb#85577

This commit fixes a bug where the query constructed during
index usage stats recording failed for db names containing
a hyphen. The db name placeholder is now wrapped in double
quotes so the db name can be recognized in the query.

Release justification: bug fix

Release note (bug fix): index usage stats are properly captured
for database names with hyphens
xinhaoz added a commit to xinhaoz/cockroach that referenced this issue Sep 8, 2022
Fixes cockroachdb#85577

This commit fixes a bug where the query constructed during
index usage stats recording failed for db names containing
a hyphen. The db name placeholder is now wrapped in double
quotes so the db name can be recognized in the query.

Release justification: bug fix

Release note (bug fix): index usage stats are properly captured
for database names with hyphens
craig bot pushed a commit that referenced this issue Sep 9, 2022
87525: sql: fix recording db names with hyphen for idx usage stats r=xinhaoz a=xinhaoz

Fixes #85577

This commit fixes a bug where the query constructed during
index usage stats recording failed for db names containing
a hyphen. The db name placeholder is now converted to string
from the `tree.Name`, which should properly escape hyphen
characters for the query.

Release justification: bug fix

Release note (bug fix): index usage stats are properly captured for database names with hyphens

87706: descs: fix txn commit waiting on wrong lease version r=postamar a=postamar

Recent work on the descs.Collection (PR #87067) introduced a regression
in which it would return bad lease.IDVersion versions for the uncommitted
descriptors.

Fixes #87672.

Release justification: important bug fix
Release note: None

Co-authored-by: Xin Hao Zhang <[email protected]>
Co-authored-by: Marius Posta <[email protected]>
@craig craig bot closed this as completed in 4f632e1 Sep 9, 2022
THardy98 pushed a commit to THardy98/cockroach that referenced this issue Sep 29, 2022
Fixes cockroachdb#85577

This commit fixes a bug where the query constructed during
index usage stats recording failed for db names containing
a hyphen. The db name placeholder is now converted to string
from the `tree.Name`, which should properly escape hyphen
characters for the query.

Release justification: bug fix

Release note (bug fix): index usage stats are properly captured
for database names with hyphens
THardy98 pushed a commit to THardy98/cockroach that referenced this issue Sep 29, 2022
Fixes cockroachdb#85577

This commit fixes a bug where the query constructed during
index usage stats recording failed for db names containing
a hyphen. The db name placeholder is now converted to string
from the `tree.Name`, which should properly escape hyphen
characters for the query.

Release justification: bug fix

Release note (bug fix): index usage stats are properly captured
for database names with hyphens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants