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

ui: statements page should disambiguate statements based on database #33316

Closed
jordanlewis opened this issue Dec 21, 2018 · 23 comments · Fixed by cockroachdb/ui#294
Closed

ui: statements page should disambiguate statements based on database #33316

jordanlewis opened this issue Dec 21, 2018 · 23 comments · Fixed by cockroachdb/ui#294
Assignees
Labels
A-sql-ui Why is my query slow? A-webui Triage label for DB Console (fka admin UI) issues. Add this if nothing else is clear. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)

Comments

@jordanlewis
Copy link
Member

jordanlewis commented Dec 21, 2018

Currently, statements on the statement page do not seem to be bucketed by database. This makes it impossible to distinguish whether a statement on a table is from one database or another.

Repro:

root@127.0.0.1:56758/defaultdb> create table a (a int primary key);
CREATE TABLE

Time: 6.559ms

root@127.0.0.1:56758/defaultdb> insert into a values(1);
INSERT 1

Time: 5.411ms

root@127.0.0.1:56758/defaultdb> create database foo;
CREATE DATABASE

Time: 4.107ms

root@127.0.0.1:56758/defaultdb> use foo;
SET

Time: 402µs

root@127.0.0.1:56758/foo> create table a (a int primary key);
CREATE TABLE

Time: 5.812ms

root@127.0.0.1:56758/foo> insert into a values(1);
INSERT 1

Time: 6.249ms

Actual result:

image

Expected: the two INSERT statements should not be in the same bucket, since they're on different tables, despite the tables having the same name.

@knz
Copy link
Contributor

knz commented Dec 26, 2018

@jordanlewis @piyush-singh we do not currently bucket statement statistics based on the value of the "current database". It's not just a matter of UI, the back-end collection must be changed as well.

@knz knz added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) A-webui Triage label for DB Console (fka admin UI) issues. Add this if nothing else is clear. labels Dec 26, 2018
@piyush-singh
Copy link

cc @couchand another wrinkle for persistence. I can't believe this didn't occur to me earlier, thanks for flagging @jordanlewis !

Andrew, this makes sense to me as a natural extension to how we handle statement stats/how users would want to filter. We can discuss whether we want to prioritize this for 2.2 at our next sprint planning. Adding as a user story to the persistence AT record.

@couchand
Copy link
Contributor

couchand commented Jan 7, 2019

As @knz alluded to but may not have made completely clear, it's not just about the storage of the stats but about the way that we collect them. I would expect getting this right to be more complicated than we can reasonably expect to do in 2.2, since it requires a lot more understanding of the semantics of what's going on that we currently kind of pretend don't exist.

Just to extend the example a bit, if you added a statement like:

insert into foo.a values(1);

The results would be even more confusing/misleading/wrong -- we'd never combine the same statement if one instance of it used fully-qualified names.

I'm happy to brainstorm ideas to address these issues, but they are necessarily much more complicated than just the UI.

@jordanlewis
Copy link
Member Author

Hey @couchand, totally agreed that this kind of example makes things more complex! But IMO a quick fix would be to just bucket by "current database" and ignore trying to coalesce things more correctly like your example. The use case (that I didn't link to hear because it was in a private repo) was just that there's a product that has several workloads running at once against different databases and they want to see which workload is doing what.

@jordanlewis
Copy link
Member Author

Here*. ugh

@couchand
Copy link
Contributor

couchand commented Jan 7, 2019

My point may not have been clear with my example. My point was that, if you want to use database as a criteria to filter/compare on (like you can today with app_name), it's not going to do what you want if it's based solely on the current database setting.

@jordanlewis
Copy link
Member Author

Ah, right! I forgot that it's also bucketed by app name. I wonder if the problem would have gone away if I had suggested that to this user.

@knz
Copy link
Contributor

knz commented Jan 8, 2019

My first comment above was a matter-of-fact comment on the technicalities of solving the problem. I did not back then express my opinion about this feature ask. Let me do that now.

I do not like it.

(It makes no sense and we already have a solution anyway. read on.)

The use case (that I didn't link to hear because it was in a private repo) was just that there's a product that has several workloads running at once against different databases and they want to see which workload is doing what.
Ah, right! I forgot that it's also bucketed by app name. I wonder if the problem would have gone away if I had suggested that to this user.

That's the thing. The one true and tried way to organize workloads in a pg-like db is application_name, not the current databaase. We also use the app_name in many other places as a identification string (table audits, execution log, SHOW SESSIONS/QUERIES, probably others by now).
The user should have been advised from the start to use that, and if they had we would not be having this discussion now.

Now on why I don't like doing anything with the db name.

  1. it doesn't make sense (like Andrew noted).

I'll start with the same argument as Andrew. One "application" can use multiple databases, going so far as having the same client session switch between values of the current db setting, or using cross-db transactions. There is no "identity" of an app in its current db session var.

  1. it's going to create poor UX.

Really, it's inconsistent with the other places where we identify applications (table audits, exec log etc). If we start to identify apps by the current db in the UI, we need to start doing so in every other places too.

All the while the pg folk have already determined that app_name is the way to go and that the cur db session var is worthless / not interesting.

So, IMHO, no. Let's not make this change and instead properly document how to use app_name.

@piyush-singh
Copy link

FWIW I read up on the customer conversation Jordan was involved in back in December. Robert correctly suggested to the customer that they try using app_name. From the conversation, it seems like they saw that as an acceptable solution and were going to try it out. I can follow up and confirm that they managed to set app_name correctly via hibernate and that this solves their need. I'll close this ticket if that is indeed the case.

@ajwerner
Copy link
Contributor

ideally we'd rewrite queries to use numerical identifiers for all of their references and use that for fingerprints. That would also give us a fingerprint that we could render back to the user in a nice way if we wanted. Ah, that'd be great. This is yet another reason to need the ability to get fine-grained information out of the optbuilder to rewrite ASTs.

@maryliag
Copy link
Contributor

maryliag commented Apr 7, 2021

Summary:

  • include database into the fingerprint and sql view (crdb_internal.node_statement_statistics)
  • show the database name on the Statements tables and details (transaction pages too?)
  • create a new filter based on database for both Statements and Transactions Page

@Annebirzin can you update figma with the new field? Not sure if we want a new column or show some other way
(we might consider adding the possibility of the user choosing the columns to show, if we keep following this path of adding more and more columns to those tables)

@maryliag maryliag self-assigned this Apr 7, 2021
@Annebirzin
Copy link

Annebirzin commented Apr 9, 2021

@maryliag I've explored some initial designs for adding databases to statements here :

option 1: add database column with ability to hide/show columns AND add filter by database
cons:

  • more columns
  • saving column preference could be complicated

option 2: 'group by' database AND filter by database (no database column)
cons:

  • not sure this scales for lots of dbs (how would collapse/expand groups work with pagination)
  • if there is no collapse/expand, could scale be an issue? (maybe solved with filtering)

Let me know any thoughts/ideas

@maryliag
Copy link
Contributor

maryliag commented Apr 9, 2021

option 1:
as a user I think I would like this one more, and we could have some hidden column (like database) hidden by default and the user can select if they want.
adding just a new column is definitely the easiest solution, but the extra save for column selection would take more work, but I have a feeling if we want to keep on this path of adding more information, it would be better do this sooner then later

option2: the collapse part seems to be tricky, maybe we could have a row for the database name, but not necessary have it collapse? I need to investigate a little of how this can be done (and check how it works with pagination as you mentioned)

THardy98 added a commit to THardy98/cockroach that referenced this issue Jun 5, 2023
role checks for role-based audit logs

This change introduces the `sql.log.user_audit.reduced_config.enabled`
cluster setting. When enabled, this cluster setting computes a "reduced"
audit configuration based on the user's current role memberships and the
current value for the `sql.log.user_audit` cluster setting. The
"reduced" audit configuration is computed at the _first SQL event emit
by the user after the setting is enabled_. Enabling the cluster setting
allows us to compute the audit configuration once at session start,
instead of computing at each SQL event (providing ~5% increase in
throughput). The tradeoff is that changes to the audit configuration
(user role memberships or cluster setting configuration) are not
reflected within session. Users will need to start a new session to see
these changes in their auditing behaviour.

Release note (sql change): Introduce new cluster setting
`sql.log.user_audit.reduced_config.enabled`. When enabled, this cluster
setting computes a "reduced" audit configuration based on the user's
current role memberships and the current value for the
`sql.log.user_audit` cluster setting. The "reduced" audit configuration
is computed at the _first SQL event emit by the user after the setting
is enabled_. Enabling the cluster setting allows us to compute the audit
configuration once at session start, instead of computing at each SQL
event (providing ~5% increase in throughput). The tradeoff is that
changes to the audit configuration (user role memberships or cluster
setting configuration) are not reflected within session. Users will need
to start a new session to see these changes in their auditing behaviour.

https://cockroachlabs.atlassian.net/browse/DOC-1355 #Informs:
cockroachdb#33316 #Epic: CRDB-8035
THardy98 added a commit to THardy98/cockroach that referenced this issue Jun 5, 2023
role checks for role-based audit logs

This change introduces the `sql.log.user_audit.reduced_config.enabled`
cluster setting. When enabled, this cluster setting computes a "reduced"
audit configuration based on the user's current role memberships and the
current value for the `sql.log.user_audit` cluster setting. The
"reduced" audit configuration is computed at the _first SQL event emit
by the user after the setting is enabled_. Enabling the cluster setting
allows us to compute the audit configuration once at session start,
instead of computing at each SQL event (providing ~5% increase in
throughput). The tradeoff is that changes to the audit configuration
(user role memberships or cluster setting configuration) are not
reflected within session. Users will need to start a new session to see
these changes in their auditing behaviour.

Release note (sql change): Introduce new cluster setting
`sql.log.user_audit.reduced_config.enabled`. When enabled, this cluster
setting computes a "reduced" audit configuration based on the user's
current role memberships and the current value for the
`sql.log.user_audit` cluster setting. The "reduced" audit configuration
is computed at the _first SQL event emit by the user after the setting
is enabled_. Enabling the cluster setting allows us to compute the audit
configuration once at session start, instead of computing at each SQL
event (providing ~5% increase in throughput). The tradeoff is that
changes to the audit configuration (user role memberships or cluster
setting configuration) are not reflected within session. Users will need
to start a new session to see these changes in their auditing behaviour.

https://cockroachlabs.atlassian.net/browse/DOC-1355 #Informs:
cockroachdb#33316 #Epic: CRDB-8035
THardy98 added a commit to THardy98/cockroach that referenced this issue Jun 5, 2023
role checks for role-based audit logs

This change introduces the `sql.log.user_audit.reduced_config.enabled`
cluster setting. When enabled, this cluster setting computes a "reduced"
audit configuration based on the user's current role memberships and the
current value for the `sql.log.user_audit` cluster setting. The
"reduced" audit configuration is computed at the _first SQL event emit
by the user after the setting is enabled_. Enabling the cluster setting
allows us to compute the audit configuration once at session start,
instead of computing at each SQL event (providing ~5% increase in
throughput). The tradeoff is that changes to the audit configuration
(user role memberships or cluster setting configuration) are not
reflected within session. Users will need to start a new session to see
these changes in their auditing behaviour.

Release note (sql change): Introduce new cluster setting
`sql.log.user_audit.reduced_config.enabled`. When enabled, this cluster
setting computes a "reduced" audit configuration based on the user's
current role memberships and the current value for the
`sql.log.user_audit` cluster setting. The "reduced" audit configuration
is computed at the _first SQL event emit by the user after the setting
is enabled_. Enabling the cluster setting allows us to compute the audit
configuration once at session start, instead of computing at each SQL
event (providing ~5% increase in throughput). The tradeoff is that
changes to the audit configuration (user role memberships or cluster
setting configuration) are not reflected within session. Users will need
to start a new session to see these changes in their auditing behaviour.

https://cockroachlabs.atlassian.net/browse/DOC-1355 #Informs:
cockroachdb#33316 #Epic: CRDB-8035
THardy98 added a commit to THardy98/cockroach that referenced this issue Jun 5, 2023
role checks for role-based audit logs

This change introduces the `sql.log.user_audit.reduced_config.enabled`
cluster setting. When enabled, this cluster setting computes a "reduced"
audit configuration based on the user's current role memberships and the
current value for the `sql.log.user_audit` cluster setting. The
"reduced" audit configuration is computed at the _first SQL event emit
by the user after the setting is enabled_. Enabling the cluster setting
allows us to compute the audit configuration once at session start,
instead of computing at each SQL event (providing ~5% increase in
throughput). The tradeoff is that changes to the audit configuration
(user role memberships or cluster setting configuration) are not
reflected within session. Users will need to start a new session to see
these changes in their auditing behaviour.

Release note (sql change): Introduce new cluster setting
`sql.log.user_audit.reduced_config.enabled`. When enabled, this cluster
setting computes a "reduced" audit configuration based on the user's
current role memberships and the current value for the
`sql.log.user_audit` cluster setting. The "reduced" audit configuration
is computed at the _first SQL event emit by the user after the setting
is enabled_. Enabling the cluster setting allows us to compute the audit
configuration once at session start, instead of computing at each SQL
event (providing ~5% increase in throughput). The tradeoff is that
changes to the audit configuration (user role memberships or cluster
setting configuration) are not reflected within session. Users will need
to start a new session to see these changes in their auditing behaviour.

https://cockroachlabs.atlassian.net/browse/DOC-1355 #Informs:
cockroachdb#33316 #Epic: CRDB-8035
THardy98 added a commit to THardy98/cockroach that referenced this issue Jun 5, 2023
role checks for role-based audit logs

This change introduces the `sql.log.user_audit.reduced_config.enabled`
cluster setting. When enabled, this cluster setting computes a "reduced"
audit configuration based on the user's current role memberships and the
current value for the `sql.log.user_audit` cluster setting. The
"reduced" audit configuration is computed at the _first SQL event emit
by the user after the setting is enabled_. Enabling the cluster setting
allows us to compute the audit configuration once at session start,
instead of computing at each SQL event (providing ~5% increase in
throughput). The tradeoff is that changes to the audit configuration
(user role memberships or cluster setting configuration) are not
reflected within session. Users will need to start a new session to see
these changes in their auditing behaviour.

Release note (sql change): Introduce new cluster setting
`sql.log.user_audit.reduced_config.enabled`. When enabled, this cluster
setting computes a "reduced" audit configuration based on the user's
current role memberships and the current value for the
`sql.log.user_audit` cluster setting. The "reduced" audit configuration
is computed at the _first SQL event emit by the user after the setting
is enabled_. Enabling the cluster setting allows us to compute the audit
configuration once at session start, instead of computing at each SQL
event (providing ~5% increase in throughput). The tradeoff is that
changes to the audit configuration (user role memberships or cluster
setting configuration) are not reflected within session. Users will need
to start a new session to see these changes in their auditing behaviour.

https://cockroachlabs.atlassian.net/browse/DOC-1355 #Informs:
cockroachdb#33316 #Epic: CRDB-8035
THardy98 added a commit to THardy98/cockroach that referenced this issue Jun 5, 2023
role checks for role-based audit logs

This change introduces the `sql.log.user_audit.reduced_config.enabled`
cluster setting. When enabled, this cluster setting computes a "reduced"
audit configuration based on the user's current role memberships and the
current value for the `sql.log.user_audit` cluster setting. The
"reduced" audit configuration is computed at the _first SQL event emit
by the user after the setting is enabled_. Enabling the cluster setting
allows us to compute the audit configuration once at session start,
instead of computing at each SQL event (providing ~5% increase in
throughput). The tradeoff is that changes to the audit configuration
(user role memberships or cluster setting configuration) are not
reflected within session. Users will need to start a new session to see
these changes in their auditing behaviour.

Release note (sql change): Introduce new cluster setting
`sql.log.user_audit.reduced_config.enabled`. When enabled, this cluster
setting computes a "reduced" audit configuration based on the user's
current role memberships and the current value for the
`sql.log.user_audit` cluster setting. The "reduced" audit configuration
is computed at the _first SQL event emit by the user after the setting
is enabled_. Enabling the cluster setting allows us to compute the audit
configuration once at session start, instead of computing at each SQL
event (providing ~5% increase in throughput). The tradeoff is that
changes to the audit configuration (user role memberships or cluster
setting configuration) are not reflected within session. Users will need
to start a new session to see these changes in their auditing behaviour.

https://cockroachlabs.atlassian.net/browse/DOC-1355 #Informs:
cockroachdb#33316 #Epic: CRDB-8035
THardy98 added a commit to THardy98/cockroach that referenced this issue Jun 6, 2023
This change moves the existing role-based audit logging logic to be
consumed as a CCL (enterprise) feature.

https://cockroachlabs.atlassian.net/browse/DOC-1355 #Informs:
cockroachdb#33316 #Epic: CRDB-8035

(sql change): #Release note (ui change): #Release note (security
update): #Release note (general change):
(performance improvement): #Release note (bug fix):
THardy98 added a commit to THardy98/cockroach that referenced this issue Jun 6, 2023
This change moves the existing role-based audit logging logic to be
consumed as a CCL (enterprise) feature.

Release note (sql change): role-based audit logging not a CCL
(enterprise) feature

https://cockroachlabs.atlassian.net/browse/DOC-1355 #Informs:
cockroachdb#33316 #Epic: CRDB-8035
THardy98 added a commit to THardy98/cockroach that referenced this issue Jun 6, 2023
This change moves the existing role-based audit logging logic to be
consumed as a CCL (enterprise) feature.

Release note (sql change): role-based audit logging not a CCL
(enterprise) feature

https://cockroachlabs.atlassian.net/browse/DOC-1355 #Informs:
cockroachdb#33316 #Epic: CRDB-8035
THardy98 added a commit to THardy98/cockroach that referenced this issue Jun 20, 2023
Now that we are on the 23.1 -> 23.2 path, we no longer need this mixed
version test case for 22.2 -> 23.1 on `master`.

Release note: None

https://cockroachlabs.atlassian.net/browse/DOC-1355 #Informs:
cockroachdb#33316 #Epic: CRDB-8035
THardy98 added a commit to THardy98/cockroach that referenced this issue Jun 20, 2023
Release note (bug fix): This change fixes a race/deadlock condition that
can occur when multiple SQLServers are created simulatenously, causing
simultaneous write to an unprotected global variable used to configure a
CCL audit logging feature.
https://cockroachlabs.atlassian.net/browse/DOC-1355 #Informs:
cockroachdb#33316 #Epic: CRDB-8035

(sql change): #Release note (ui change): #Release note (security
update): #Release note (general change):
(performance improvement): #Release note (bug fix):
THardy98 added a commit to THardy98/cockroach that referenced this issue Jun 21, 2023
Release note (bug fix): This change fixes a race/deadlock condition that
can occur when multiple SQLServers are created simulatenously, causing
simultaneous write to an unprotected global variable used to configure a
CCL audit logging feature.
https://cockroachlabs.atlassian.net/browse/DOC-1355 #Informs:
cockroachdb#33316 #Epic: CRDB-8035

(sql change): #Release note (ui change): #Release note (security
update): #Release note (general change):
(performance improvement): #Release note (bug fix):
angles-n-daemons added a commit to angles-n-daemons/cockroach that referenced this issue Aug 19, 2024
Previously, for resolving the cluster's license expiry we relied on a metric
whose value was regularly ticked down by an async task. This change seeks to
only the resolve value at read time by reading directly from the cluster
settings when its requested.

Release note: None

Fixes: cockroachdb#77376
Part of: https://cockroachlabs.atlassian.net/browse/DOC-1355
Informs: cockroachdb#33316
Epic: CRDB-8035
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-ui Why is my query slow? A-webui Triage label for DB Console (fka admin UI) issues. Add this if nothing else is clear. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants