Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 #94286
Fixes #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 #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: #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]>
  • Loading branch information
4 people committed Jul 28, 2023
4 parents 4642833 + d99cd3d + 11acdea + 357fe37 commit c986d84
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 14 deletions.
38 changes: 25 additions & 13 deletions pkg/ccl/multitenantccl/tenantcostclient/tenant_side_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -873,8 +873,9 @@ func TestConsumption(t *testing.T) {
hostServer, _, _ := serverutils.StartServer(t, base.TestServerArgs{DefaultTestTenant: base.TestControlsTenantsExplicitly})
defer hostServer.Stopper().Stop(context.Background())

const targetPeriod = time.Millisecond
st := cluster.MakeTestingClusterSettings()
tenantcostclient.TargetPeriodSetting.Override(context.Background(), &st.SV, time.Millisecond)
tenantcostclient.TargetPeriodSetting.Override(context.Background(), &st.SV, targetPeriod)
tenantcostclient.CPUUsageAllowance.Override(context.Background(), &st.SV, 0)

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

afterWrite := testProvider.waitForConsumption(t)
delta := afterWrite
delta.Sub(&beforeWrite)
if delta.WriteBatches < 1 || delta.WriteRequests < 2 || delta.WriteBytes < expectedBytes*2 {
t.Errorf("usage after write: %s", delta.String())
}
// Try a few times because background activity can trigger bucket
// requests before the test query does.
testutils.SucceedsSoon(t, func() error {
afterWrite := testProvider.waitForConsumption(t)
delta := afterWrite
delta.Sub(&beforeWrite)
if delta.WriteBatches < 1 || delta.WriteRequests < 2 || delta.WriteBytes < expectedBytes*2 {
return errors.Newf("usage after write: %s", delta.String())
}
return nil
})

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

afterRead := testProvider.waitForConsumption(t)
delta = afterRead
delta.Sub(&afterWrite)
if delta.ReadBatches < 1 || delta.ReadRequests < 1 || delta.ReadBytes < expectedBytes {
t.Errorf("usage after read: %s", delta.String())
}
// Try a few times because background activity can trigger bucket
// requests before the test query does.
testutils.SucceedsSoon(t, func() error {
afterRead := testProvider.waitForConsumption(t)
delta := afterRead
delta.Sub(&beforeRead)
if delta.ReadBatches < 1 || delta.ReadRequests < 1 || delta.ReadBytes < expectedBytes {
return errors.Newf("usage after read: %s", delta.String())
}
return nil
})
r.Exec(t, "DELETE FROM t WHERE true")
}
// Make sure some CPU usage is reported.
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/rowenc/valueside/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func DecodeUntaggedDatum(
case types.VoidFamily:
return a.NewDVoid(), buf, nil
default:
return nil, buf, errors.Errorf("couldn't decode type %s", t)
return nil, buf, errors.Errorf("couldn't decode type %s", t.SQLStringForError())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ const planDetailsColumnLabels = {
insights: "Insights",
indexes: "Used Indexes",
lastExecTime: "Last Execution Time",
latencyMax: "Max Latency",
latencyMin: "Min Latency",
latencyP50: "P50 Latency",
latencyP90: "P90 Latency",
latencyP99: "P99 Latency",
planGist: "Plan Gist",
vectorized: "Vectorized",
};
Expand Down Expand Up @@ -100,6 +105,71 @@ export const planDetailsTableTitles: PlanDetailsTableTitleType = {
</Tooltip>
);
},
latencyP50: () => {
return (
<Tooltip
style="tableTitle"
placement="bottom"
content={
"The 50th latency percentile for sampled statement executions with this Explain Plan."
}
>
{planDetailsColumnLabels.latencyP50}
</Tooltip>
);
},
latencyP90: () => {
return (
<Tooltip
style="tableTitle"
placement="bottom"
content={
"The 90th latency percentile for sampled statement executions with this Explain Plan."
}
>
{planDetailsColumnLabels.latencyP90}
</Tooltip>
);
},
latencyP99: () => {
return (
<Tooltip
style="tableTitle"
placement="bottom"
content={
"The 99th latency percentile for sampled statement executions with this Explain Plan."
}
>
{planDetailsColumnLabels.latencyP99}
</Tooltip>
);
},
latencyMin: () => {
return (
<Tooltip
style="tableTitle"
placement="bottom"
content={
"The lowest latency value for all statement executions with this Explain Plan."
}
>
{planDetailsColumnLabels.latencyMin}
</Tooltip>
);
},
latencyMax: () => {
return (
<Tooltip
style="tableTitle"
placement="bottom"
content={
"The highest latency value for all statement executions with this Explain Plan."
}
>
{planDetailsColumnLabels.latencyMax}
</Tooltip>
);
},
execCount: () => {
return (
<Tooltip
Expand Down Expand Up @@ -335,6 +405,41 @@ export function makeExplainPlanColumns(
sort: (item: PlanHashStats) =>
RenderCount(item.metadata.full_scan_count, item.metadata.total_count),
},
{
name: "latencyMin",
title: planDetailsTableTitles.latencyMin(),
cell: (item: PlanHashStats) =>
formatNumberForDisplay(item.stats.latency_info.min, duration),
sort: (item: PlanHashStats) => item.stats.latency_info.min,
},
{
name: "latencyMax",
title: planDetailsTableTitles.latencyMax(),
cell: (item: PlanHashStats) =>
formatNumberForDisplay(item.stats.latency_info.max, duration),
sort: (item: PlanHashStats) => item.stats.latency_info.max,
},
{
name: "latencyP50",
title: planDetailsTableTitles.latencyP50(),
cell: (item: PlanHashStats) =>
formatNumberForDisplay(item.stats.latency_info.p50, duration),
sort: (item: PlanHashStats) => item.stats.latency_info.p50,
},
{
name: "latencyP90",
title: planDetailsTableTitles.latencyP90(),
cell: (item: PlanHashStats) =>
formatNumberForDisplay(item.stats.latency_info.p90, duration),
sort: (item: PlanHashStats) => item.stats.latency_info.p90,
},
{
name: "latencyP99",
title: planDetailsTableTitles.latencyP99(),
cell: (item: PlanHashStats) =>
formatNumberForDisplay(item.stats.latency_info.p99, duration),
sort: (item: PlanHashStats) => item.stats.latency_info.p99,
},
{
name: "distSQL",
title: planDetailsTableTitles.distSQL(),
Expand Down

0 comments on commit c986d84

Please sign in to comment.