Skip to content

Commit c986d84

Browse files
craig[bot]DrewKimballmaryliagyuzefovich
committed
105552: multitenant: deflake TestConsumption r=yuzefovich a=DrewKimball This patch adds retries to the `TestConsumption` test for retrieving the total tenant RU consumption in order to ensure that the delta includes the bucket flush that was triggered by the test query, instead of background activity. Fixes cockroachdb#94286 Fixes cockroachdb#106572 Release note: None 107719: ui: add latency info to explain plan tab r=maryliag a=maryliag This commit adds columns for latency information (p50, p90, p99, pMax, pMin) on Explain Plan tab under Statement Details page. Fixes cockroachdb#105371 <img width="1707" alt="Screenshot 2023-07-27 at 10 59 41 AM" src="https://github.com/cockroachdb/cockroach/assets/1017486/81a2ce3d-655e-47c1-931b-00e34433b3a1"> Release note (ui change): Add columns for p50, p90, p99 percentiles and latency min and max on Explain Plan tab on Statement Details page. 107732: valueside: use redact type name when can't decode r=yuzefovich a=yuzefovich Informs: cockroachdb#106158 Epic: None Release note: None Co-authored-by: Drew Kimball <[email protected]> Co-authored-by: maryliag <[email protected]> Co-authored-by: Yahor Yuzefovich <[email protected]>
4 parents 4642833 + d99cd3d + 11acdea + 357fe37 commit c986d84

File tree

3 files changed

+131
-14
lines changed

3 files changed

+131
-14
lines changed

pkg/ccl/multitenantccl/tenantcostclient/tenant_side_test.go

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -873,8 +873,9 @@ func TestConsumption(t *testing.T) {
873873
hostServer, _, _ := serverutils.StartServer(t, base.TestServerArgs{DefaultTestTenant: base.TestControlsTenantsExplicitly})
874874
defer hostServer.Stopper().Stop(context.Background())
875875

876+
const targetPeriod = time.Millisecond
876877
st := cluster.MakeTestingClusterSettings()
877-
tenantcostclient.TargetPeriodSetting.Override(context.Background(), &st.SV, time.Millisecond)
878+
tenantcostclient.TargetPeriodSetting.Override(context.Background(), &st.SV, targetPeriod)
878879
tenantcostclient.CPUUsageAllowance.Override(context.Background(), &st.SV, 0)
879880

880881
testProvider := newTestProvider()
@@ -902,21 +903,32 @@ func TestConsumption(t *testing.T) {
902903
r.Exec(t, "INSERT INTO t (v) SELECT repeat('1234567890', 1024) FROM generate_series(1, 10) AS g(i)")
903904
const expectedBytes = 10 * 10 * 1024
904905

905-
afterWrite := testProvider.waitForConsumption(t)
906-
delta := afterWrite
907-
delta.Sub(&beforeWrite)
908-
if delta.WriteBatches < 1 || delta.WriteRequests < 2 || delta.WriteBytes < expectedBytes*2 {
909-
t.Errorf("usage after write: %s", delta.String())
910-
}
906+
// Try a few times because background activity can trigger bucket
907+
// requests before the test query does.
908+
testutils.SucceedsSoon(t, func() error {
909+
afterWrite := testProvider.waitForConsumption(t)
910+
delta := afterWrite
911+
delta.Sub(&beforeWrite)
912+
if delta.WriteBatches < 1 || delta.WriteRequests < 2 || delta.WriteBytes < expectedBytes*2 {
913+
return errors.Newf("usage after write: %s", delta.String())
914+
}
915+
return nil
916+
})
911917

918+
beforeRead := testProvider.waitForConsumption(t)
912919
r.QueryStr(t, "SELECT min(v) FROM t")
913920

914-
afterRead := testProvider.waitForConsumption(t)
915-
delta = afterRead
916-
delta.Sub(&afterWrite)
917-
if delta.ReadBatches < 1 || delta.ReadRequests < 1 || delta.ReadBytes < expectedBytes {
918-
t.Errorf("usage after read: %s", delta.String())
919-
}
921+
// Try a few times because background activity can trigger bucket
922+
// requests before the test query does.
923+
testutils.SucceedsSoon(t, func() error {
924+
afterRead := testProvider.waitForConsumption(t)
925+
delta := afterRead
926+
delta.Sub(&beforeRead)
927+
if delta.ReadBatches < 1 || delta.ReadRequests < 1 || delta.ReadBytes < expectedBytes {
928+
return errors.Newf("usage after read: %s", delta.String())
929+
}
930+
return nil
931+
})
920932
r.Exec(t, "DELETE FROM t WHERE true")
921933
}
922934
// Make sure some CPU usage is reported.

pkg/sql/rowenc/valueside/decode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func DecodeUntaggedDatum(
246246
case types.VoidFamily:
247247
return a.NewDVoid(), buf, nil
248248
default:
249-
return nil, buf, errors.Errorf("couldn't decode type %s", t)
249+
return nil, buf, errors.Errorf("couldn't decode type %s", t.SQLStringForError())
250250
}
251251
}
252252

pkg/ui/workspaces/cluster-ui/src/statementDetails/planDetails/plansTable.tsx

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ const planDetailsColumnLabels = {
4848
insights: "Insights",
4949
indexes: "Used Indexes",
5050
lastExecTime: "Last Execution Time",
51+
latencyMax: "Max Latency",
52+
latencyMin: "Min Latency",
53+
latencyP50: "P50 Latency",
54+
latencyP90: "P90 Latency",
55+
latencyP99: "P99 Latency",
5156
planGist: "Plan Gist",
5257
vectorized: "Vectorized",
5358
};
@@ -100,6 +105,71 @@ export const planDetailsTableTitles: PlanDetailsTableTitleType = {
100105
</Tooltip>
101106
);
102107
},
108+
latencyP50: () => {
109+
return (
110+
<Tooltip
111+
style="tableTitle"
112+
placement="bottom"
113+
content={
114+
"The 50th latency percentile for sampled statement executions with this Explain Plan."
115+
}
116+
>
117+
{planDetailsColumnLabels.latencyP50}
118+
</Tooltip>
119+
);
120+
},
121+
latencyP90: () => {
122+
return (
123+
<Tooltip
124+
style="tableTitle"
125+
placement="bottom"
126+
content={
127+
"The 90th latency percentile for sampled statement executions with this Explain Plan."
128+
}
129+
>
130+
{planDetailsColumnLabels.latencyP90}
131+
</Tooltip>
132+
);
133+
},
134+
latencyP99: () => {
135+
return (
136+
<Tooltip
137+
style="tableTitle"
138+
placement="bottom"
139+
content={
140+
"The 99th latency percentile for sampled statement executions with this Explain Plan."
141+
}
142+
>
143+
{planDetailsColumnLabels.latencyP99}
144+
</Tooltip>
145+
);
146+
},
147+
latencyMin: () => {
148+
return (
149+
<Tooltip
150+
style="tableTitle"
151+
placement="bottom"
152+
content={
153+
"The lowest latency value for all statement executions with this Explain Plan."
154+
}
155+
>
156+
{planDetailsColumnLabels.latencyMin}
157+
</Tooltip>
158+
);
159+
},
160+
latencyMax: () => {
161+
return (
162+
<Tooltip
163+
style="tableTitle"
164+
placement="bottom"
165+
content={
166+
"The highest latency value for all statement executions with this Explain Plan."
167+
}
168+
>
169+
{planDetailsColumnLabels.latencyMax}
170+
</Tooltip>
171+
);
172+
},
103173
execCount: () => {
104174
return (
105175
<Tooltip
@@ -335,6 +405,41 @@ export function makeExplainPlanColumns(
335405
sort: (item: PlanHashStats) =>
336406
RenderCount(item.metadata.full_scan_count, item.metadata.total_count),
337407
},
408+
{
409+
name: "latencyMin",
410+
title: planDetailsTableTitles.latencyMin(),
411+
cell: (item: PlanHashStats) =>
412+
formatNumberForDisplay(item.stats.latency_info.min, duration),
413+
sort: (item: PlanHashStats) => item.stats.latency_info.min,
414+
},
415+
{
416+
name: "latencyMax",
417+
title: planDetailsTableTitles.latencyMax(),
418+
cell: (item: PlanHashStats) =>
419+
formatNumberForDisplay(item.stats.latency_info.max, duration),
420+
sort: (item: PlanHashStats) => item.stats.latency_info.max,
421+
},
422+
{
423+
name: "latencyP50",
424+
title: planDetailsTableTitles.latencyP50(),
425+
cell: (item: PlanHashStats) =>
426+
formatNumberForDisplay(item.stats.latency_info.p50, duration),
427+
sort: (item: PlanHashStats) => item.stats.latency_info.p50,
428+
},
429+
{
430+
name: "latencyP90",
431+
title: planDetailsTableTitles.latencyP90(),
432+
cell: (item: PlanHashStats) =>
433+
formatNumberForDisplay(item.stats.latency_info.p90, duration),
434+
sort: (item: PlanHashStats) => item.stats.latency_info.p90,
435+
},
436+
{
437+
name: "latencyP99",
438+
title: planDetailsTableTitles.latencyP99(),
439+
cell: (item: PlanHashStats) =>
440+
formatNumberForDisplay(item.stats.latency_info.p99, duration),
441+
sort: (item: PlanHashStats) => item.stats.latency_info.p99,
442+
},
338443
{
339444
name: "distSQL",
340445
title: planDetailsTableTitles.distSQL(),

0 commit comments

Comments
 (0)