-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: create system.mvcc_statistics table and update job
The system.mvcc_statistics table stores historical mvcc data for a tenant's SQL objects. It's purpose it to serve mvcc data for a SQL object quickly - The span stats API is too slow to use in a hot path. Storing data over time unlocks new use cases like showing a table or index's accumulated garbage over time. Indexes have been added for common access use-cases. - by database_id, table_id, index_id and time. - by database_id and time. - by table_id and time. - by index_id and time. The MVCCStatisticsUpdate Job is responsible for managing the contents of the table, decoupled from the read-hotpath. Both the table and job are baked when a cluster bootstraps itself, or upgrades itself from a previous version. Epic: CRDB-25491 Release note: None
- Loading branch information
Zach Lite
committed
Sep 29, 2023
1 parent
af05d81
commit ef6736b
Showing
18 changed files
with
278 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright 2023 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
// Package upgrades contains the implementation of upgrades. It is imported | ||
// by the server library. | ||
// | ||
// This package registers the upgrades with the upgrade package. | ||
|
||
package sql | ||
|
||
import ( | ||
"context" | ||
"github.com/cockroachdb/cockroach/pkg/jobs" | ||
"github.com/cockroachdb/cockroach/pkg/jobs/jobspb" | ||
"github.com/cockroachdb/cockroach/pkg/settings/cluster" | ||
"github.com/cockroachdb/cockroach/pkg/util/log" | ||
"github.com/cockroachdb/errors" | ||
) | ||
|
||
type mvccStatisticsUpdateJob struct { | ||
job *jobs.Job | ||
} | ||
|
||
var _ jobs.Resumer = (*mvccStatisticsUpdateJob)(nil) | ||
|
||
func (j *mvccStatisticsUpdateJob) Resume( | ||
ctx context.Context, execCtxI interface{}, | ||
) (jobErr error) { | ||
|
||
// TODO(zachlite): | ||
// Delete samples older than configurable setting... | ||
// Collect span stats for tenant descriptors... | ||
// Write new samples... | ||
|
||
return nil | ||
} | ||
|
||
func (j *mvccStatisticsUpdateJob) OnFailOrCancel( | ||
ctx context.Context, _ interface{}, jobErr error, | ||
) error { | ||
if jobs.HasErrJobCanceled(jobErr) { | ||
err := errors.NewAssertionErrorWithWrappedErrf( | ||
jobErr, "mvcc statistics update job is not cancelable", | ||
) | ||
log.Errorf(ctx, "%v", err) | ||
} | ||
return nil | ||
} | ||
|
||
func (j *mvccStatisticsUpdateJob) CollectProfile(_ context.Context, _ interface{}) error { | ||
return nil | ||
} | ||
|
||
func init() { | ||
jobs.RegisterConstructor(jobspb.TypeMVCCStatisticsUpdate, | ||
func(job *jobs.Job, settings *cluster.Settings) jobs.Resumer { | ||
return &mvccStatisticsUpdateJob{job: job} | ||
}, | ||
jobs.DisablesTenantCostControl, | ||
) | ||
} |
Oops, something went wrong.