-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: Transaction page inconsistent grouping of statement stats #59205
Comments
This seems related to https://github.com/cockroachlabs/support/issues/793 |
Currently started with the approach where we create a temporary in-memory SQL Stats to record all statements within an ongoing transaction, then flush the transaction to the actual SQL Stats once transaction is either committed or aborted. (This is when transaction fingerprint ID becomes available). I realized an issue with the approach with using the temp SQL Stats approach while implementing it. SET application_name = "app1";
BEGIN;
SELECT 1; -- stmt1
SELECT 1,1; -- stmt2
SET application_name = "app2"; -- stmt3
SELECT 1,1,1; -- stmt4
COMMIT; Our current behaviour would result This introduce a problem for a new approach, when we swap out the application statistics object, we still don't have all the information to compute transaction fingerprint ID yet. This leaves us with few options:
My personal take: I would go with the first option. Since |
Previously, SQL Stats's public writer interface is very limited in its functionality. This was intentional back in the time where SQL Stat's writer is injected into stats collector and directly writes statistics into the in-memory store. However, as we move to support grouping of statement statistics within an explicit transaction, this limited interface becomes a hurdle for stats collector to implement that behavior. This commit restructure the SQL Stats Writer API to introduce the concept of sqlstats.ApplicationStats, which maps to ssmemstorage.Container struct. Now, sqlstats.Storage interface would return the new sqlstats.ApplicationStats intead of sqlstats.Writer to the connExecutor, which can be injected into the sqlstats.StatsCollector. This is the initial step to address cockroachdb#59205 Release justification: Low risk, high benefit changes to existing functionality Release note: None
Previously, SQL Stats's public writer interface is was very limited in its functionality. This was intentional back in the time where SQL Stat's writer was injected into the stats collector and directly wrote statistics into the in-memory store. However, as we move to support grouping statement statistics within an explicit transaction, we need to create short-lived emphemeral sqlstats.Writer to record statement statistics for explicit transactions, then merge the stored statistics inside the emphemeral sqlstats.Writer into the main SQLStats. However, this merge cannot be implemented with the current sqlstats.Writer API, since the API does not allow statistics to be fetched from the sqlstats.Writer. This commit restructures the SQL Stats Writer API to introduce the concept of sqlstats.ApplicationStats, which is backed by the ssmemstorage.Container struct. Now, sqlstats.Storage interface would return the new sqlstats.ApplicationStats intead of sqlstats.Writer to the connExecutor, which can be injected into the sqlstats.StatsCollector. This is the initial step to address cockroachdb#59205 Release justification: Low risk, high benefit changes to existing functionality Release note: None
fingerprintID Previously, statement that are executed as part of different transactions are grouped together resulting in one single stats entry. This results in weird UX and makes it difficult for developer to debug slow queries. This commit groups statement statsitics based on its transaction fingerprintIDs on top of the statement fingerprint ID. Partially addresses cockroachdb#65106, cockroachdb#59205 Release note (bug fix): statement statsitics are now grouped by the statement's corresponding transaction fingerprints.
fingerprintID Previously, statement that are executed as part of different transactions are grouped together resulting in one single stats entry. This results in weird UX and makes it difficult for developer to debug slow queries. This commit groups statement statsitics based on its transaction fingerprintIDs on top of the statement fingerprint ID. Partially addresses cockroachdb#65106, cockroachdb#59205 Release note (bug fix): statement statsitics are now grouped by the statement's corresponding transaction fingerprints.
70261: sql: group statement statistics based on its transaction fingerprintID r=matthewtodd a=Azhng Depends on #69710 # First Commit sql: plumb sqlstats.TestingKnobs down into ssmemstorage This commit plumbs sqlstats.TestingKnobs into ssmemstorage in order to allow later unit tests to manipulate times in the tests. Release note: None # Second Commit sql: remove GetStatementStats and GetTransactionStats API Previsously, we had GetStatementStats and GetTransactionStats exported as part of the interface for SQL Stats subsystem. These two methods are only used within tests and nowhere else in the code base. This commit removes those two exported methods and rewrite the tests to use the iterator API. Release note: None # Third Commit sql: group statement statistics based on its transaction fingerprintID Previously, statement that are executed as part of different transactions are grouped together resulting in one single stats entry. This results in weird UX and makes it difficult for developer to debug slow queries. This commit groups statement statsitics based on its transaction fingerprintIDs on top of the statement fingerprint ID. Partially addresses #65106, #59205 Release note (bug fix): statement statsitics are now grouped by the statement's corresponding transaction fingerprints. Co-authored-by: Azhng <archer.xn@gmail.com>
fingerprintID Previously, statement that are executed as part of different transactions are grouped together resulting in one single stats entry. This results in weird UX and makes it difficult for developer to debug slow queries. This commit groups statement statsitics based on its transaction fingerprintIDs on top of the statement fingerprint ID. Partially addresses cockroachdb#65106, cockroachdb#59205 Release note (bug fix): statement statsitics are now grouped by the statement's corresponding transaction fingerprints.
transaction fingerprint ID Previously, transactionDetail page shows statement statistics aggregated across **all** executions of that statement fingerprint. This led to confusing UX and the statement statistics were subsequently removed from transactionDetail page. This commit reintroduces statement statistics on transactionDetail page. The statistics now are only aggregated across the statement fingerprints that are part of the selected transaction fingerprint. Resolves cockroachdb#59205 cockroachdb#65106 Release note (ui change): transactionDetail page now shows statement statistics scoped by the transaction fingeprint.
71543: roachtest: disable prometheus for scrub r=otan a=otan I'm unable to reproduce the error running roachtest myself, and it's the only set of tests affected. Resolves #71979 Release note: None 71927: sql/catalog/nstree: optimize with lazy initialization, pooling btrees r=ajwerner a=ajwerner This change comes in response to #66112 (comment). The thrust of the change is to lazily initialize the data structures so that when they are not used, they do not incur cost. Additionally, pool the underlying tree so that when they are used, the allocations are effectively free. This was originally deemed unimportant because the connExecutor descs.Collection is long-lived. Unfortunately, others, as used for the type resolve in distsql, are not. ``` name old time/op new time/op delta FlowSetup/vectorize=true/distribute=true-16 145µs ± 2% 139µs ± 3% -3.94% (p=0.000 n=19+20) FlowSetup/vectorize=true/distribute=false-16 141µs ± 3% 134µs ± 2% -4.66% (p=0.000 n=18+19) FlowSetup/vectorize=false/distribute=true-16 138µs ± 4% 132µs ± 4% -4.23% (p=0.000 n=20+20) FlowSetup/vectorize=false/distribute=false-16 133µs ± 3% 127µs ± 3% -4.41% (p=0.000 n=20+19) name old alloc/op new alloc/op delta FlowSetup/vectorize=true/distribute=true-16 38.1kB ± 3% 36.7kB ± 2% -3.58% (p=0.000 n=18+18) FlowSetup/vectorize=true/distribute=false-16 36.2kB ± 0% 34.9kB ± 0% -3.66% (p=0.000 n=18+16) FlowSetup/vectorize=false/distribute=true-16 42.6kB ± 0% 41.3kB ± 0% -3.11% (p=0.000 n=17+17) FlowSetup/vectorize=false/distribute=false-16 41.0kB ± 0% 39.7kB ± 0% -3.22% (p=0.000 n=17+17) name old allocs/op new allocs/op delta FlowSetup/vectorize=true/distribute=true-16 368 ± 0% 314 ± 0% -14.67% (p=0.000 n=16+17) FlowSetup/vectorize=true/distribute=false-16 354 ± 0% 300 ± 0% -15.25% (p=0.000 n=17+17) FlowSetup/vectorize=false/distribute=true-16 338 ± 1% 283 ± 1% -16.13% (p=0.000 n=19+19) FlowSetup/vectorize=false/distribute=false-16 325 ± 0% 271 ± 0% -16.62% (p=0.000 n=18+18) ``` Omitting a release note because I'm doubtful this meaningfully shows up on its own. Release note: None 71960: ui: Added informative warning for insufficient privileges r=nathanstilwell a=nathanstilwell <img width="972" alt="Screen Shot 2021-10-25 at 17 17 49" src="https://user-images.githubusercontent.com/397448/138772352-117456e1-10a8-475b-9b1c-79b0e2327558.png"> Previously, `/#/reports/nodes` would seem to hang in a loading state indefinitely when a DB Console user wouldn't have admin privileges for that endpoint. This was due to nodes data being empty from a 403 response. An error is captured in the application state for this response, so mapping this error as a prop to the component, the UI can distinguish between the nodes data simply being empty and being empty due to a restriction error. <img width="827" alt="Screen Shot 2021-10-25 at 17 16 07" src="https://user-images.githubusercontent.com/397448/138772135-33321d34-9728-489b-8549-1c8bd55cf650.png"> Detecting this error, we render an `<InlineAlert />` to notify the user of their lack of privileges. Release note (ui change): All Nodes report notifies user is they need more privileges to view information. 71966: ui: default filter on Transaction and Statement pages now exclude internals r=maryliag a=maryliag Previously, the default value when no App filter was selected on Transactions and Statements page, we were showing all data, now we're excluding internal transaction/statements. Fixes #70544 Release note (ui change): The default value when no App is selected on Transactions and Statements filter is now excluding internal Transactions and Statements. 71967: server,ui: transactionDetail page now shows statement stats scoped by transaction fingerprint ID r=matthewtodd a=Azhng Previously, transactionDetail page shows statement statistics aggregated across **all** executions of that statement fingerprint. This led to confusing UX and the statement statistics were subsequently removed from transactionDetail page. This commit reintroduces statement statistics on transactionDetail page. The statistics now are only aggregated across the statement fingerprints that are part of the selected transaction fingerprint. Resolves #59205 #65106 Release note (ui change): transactionDetail page now shows statement statistics scoped by the transaction fingeprint. https://user-images.githubusercontent.com/9267198/138916095-c91895d5-6f34-49b7-87dd-81f375b3f582.mov 71987: sql: skip TestSavepoints r=nkodali a=jbowens Refs: #70220 Reason: flaky test Generated by bin/skip-test. Release justification: non-production code changes Release note: None Co-authored-by: Oliver Tan <otan@cockroachlabs.com> Co-authored-by: Andrew Werner <awerner32@gmail.com> Co-authored-by: Nathan Stilwell <nathanstilwell@cockroachlabs.com> Co-authored-by: Marylia Gutierrez <marylia@cockroachlabs.com> Co-authored-by: Azhng <archer.xn@gmail.com> Co-authored-by: Jackson Owens <jackson@cockroachlabs.com>
Previously, SQL Stats's public writer interface was very limited in its functionality. This was intentional back in the time where SQL Stat's writer was injected into the stats collector and directly wrote statistics into the in-memory store. However, as we move to support grouping statement statistics within an explicit transaction, we need to create short-lived emphemeral sqlstats.Writer to record statement statistics for explicit transactions, then merge the stored statistics inside the emphemeral sqlstats.Writer into the main SQLStats. However, this merge cannot be implemented with the current sqlstats.Writer API, since the API does not allow statistics to be fetched from the sqlstats.Writer. This commit restructures the SQL Stats Writer API to introduce the concept of sqlstats.ApplicationStats, which is backed by the ssmemstorage.Container struct. Now, sqlstats.Storage interface would return the new sqlstats.ApplicationStats intead of sqlstats.Writer to the connExecutor, which can be injected into the sqlstats.StatsCollector. This is the initial step to address cockroachdb#59205 Release justification: Low risk, high benefit changes to existing functionality Release note: None
fingerprintID Previously, statement that are executed as part of different transactions are grouped together resulting in one single stats entry. This results in weird UX and makes it difficult for developer to debug slow queries. This commit groups statement statsitics based on its transaction fingerprintIDs on top of the statement fingerprint ID. Partially addresses cockroachdb#65106, cockroachdb#59205 Release note (bug fix): statement statsitics are now grouped by the statement's corresponding transaction fingerprints.
Previously, SQL Stats's public writer interface was very limited in its functionality. This was intentional back in the time where SQL Stat's writer was injected into the stats collector and directly wrote statistics into the in-memory store. However, as we move to support grouping statement statistics within an explicit transaction, we need to create short-lived emphemeral sqlstats.Writer to record statement statistics for explicit transactions, then merge the stored statistics inside the emphemeral sqlstats.Writer into the main SQLStats. However, this merge cannot be implemented with the current sqlstats.Writer API, since the API does not allow statistics to be fetched from the sqlstats.Writer. This commit restructures the SQL Stats Writer API to introduce the concept of sqlstats.ApplicationStats, which is backed by the ssmemstorage.Container struct. Now, sqlstats.Storage interface would return the new sqlstats.ApplicationStats intead of sqlstats.Writer to the connExecutor, which can be injected into the sqlstats.StatsCollector. This is the initial step to address cockroachdb#59205 Release justification: Low risk, high benefit changes to existing functionality Release note: None
fingerprintID Previously, statement that are executed as part of different transactions are grouped together resulting in one single stats entry. This results in weird UX and makes it difficult for developer to debug slow queries. This commit groups statement statsitics based on its transaction fingerprintIDs on top of the statement fingerprint ID. Partially addresses cockroachdb#65106, cockroachdb#59205 Release note (bug fix): statement statsitics are now grouped by the statement's corresponding transaction fingerprints.
Previously, SQL Stats's public writer interface was very limited in its functionality. This was intentional back in the time where SQL Stat's writer was injected into the stats collector and directly wrote statistics into the in-memory store. However, as we move to support grouping statement statistics within an explicit transaction, we need to create short-lived emphemeral sqlstats.Writer to record statement statistics for explicit transactions, then merge the stored statistics inside the emphemeral sqlstats.Writer into the main SQLStats. However, this merge cannot be implemented with the current sqlstats.Writer API, since the API does not allow statistics to be fetched from the sqlstats.Writer. This commit restructures the SQL Stats Writer API to introduce the concept of sqlstats.ApplicationStats, which is backed by the ssmemstorage.Container struct. Now, sqlstats.Storage interface would return the new sqlstats.ApplicationStats intead of sqlstats.Writer to the connExecutor, which can be injected into the sqlstats.StatsCollector. This is the initial step to address cockroachdb#59205 Release justification: Low risk, high benefit changes to existing functionality Release note: None
fingerprintID Previously, statement that are executed as part of different transactions are grouped together resulting in one single stats entry. This results in weird UX and makes it difficult for developer to debug slow queries. This commit groups statement statsitics based on its transaction fingerprintIDs on top of the statement fingerprint ID. Partially addresses cockroachdb#65106, cockroachdb#59205 Release note (bug fix): statement statsitics are now grouped by the statement's corresponding transaction fingerprints.
…d by transaction fingerprint ID Previously, the transactionDetail page showed statement statistics aggregated across **all** executions of that statement fingerprint. This led to confusing UX and the statement statistics were subsequently removed from transactionDetail page. This commit reintroduces statement statistics on the transactionDetail page. The statistics now are only aggregated across the statement fingerprints that are part of the selected transaction fingerprint. Resolves cockroachdb#59205 cockroachdb#65106 Release note (ui change): transactionDetail page now shows statement statistics scoped by the transaction fingeprint.
I saw this while working with a customer, but have not been able to reproduce the behavior.
On the Transactions page in 20.2, we see a transaction with 2 similar statements. In the statement stats list (bottom of screen shot) the statement is listed twice, however the first listing has an execution count of 2 and the second has an execution count of 0. So it seems like some of the grouping and/or display logic in the statement stats list is mixing up the stats...or is displaying the statement twice when it should only be listed one with the aggregate stats.
Epic: CRDB-9867
The text was updated successfully, but these errors were encountered: