-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: implement persistedsqlstats flush logic
This commit implements the initial flush logic of the persisted sql stats subsystem. Release note: None
- Loading branch information
Showing
25 changed files
with
1,243 additions
and
31 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,59 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") | ||
|
||
go_library( | ||
name = "persistedsqlstats", | ||
srcs = [ | ||
"cluster_settings.go", | ||
"flush.go", | ||
"provider.go", | ||
"test_utils.go", | ||
], | ||
importpath = "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/persistedsqlstats", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//pkg/base", | ||
"//pkg/kv", | ||
"//pkg/roachpb:with-mocks", | ||
"//pkg/security", | ||
"//pkg/settings", | ||
"//pkg/settings/cluster", | ||
"//pkg/sql/sem/tree", | ||
"//pkg/sql/sessiondata", | ||
"//pkg/sql/sqlstats", | ||
"//pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil", | ||
"//pkg/sql/sqlstats/sslocal", | ||
"//pkg/sql/sqlutil", | ||
"//pkg/util/log", | ||
"//pkg/util/metric", | ||
"//pkg/util/stop", | ||
"//pkg/util/timeutil", | ||
"@com_github_cockroachdb_errors//:errors", | ||
], | ||
) | ||
|
||
go_test( | ||
name = "persistedsqlstats_test", | ||
srcs = [ | ||
"flush_test.go", | ||
"main_test.go", | ||
], | ||
deps = [ | ||
":persistedsqlstats", | ||
"//pkg/base", | ||
"//pkg/roachpb:with-mocks", | ||
"//pkg/security", | ||
"//pkg/security/securitytest", | ||
"//pkg/server", | ||
"//pkg/sql", | ||
"//pkg/sql/sqlstats", | ||
"//pkg/testutils/serverutils", | ||
"//pkg/testutils/sqlutils", | ||
"//pkg/testutils/testcluster", | ||
"//pkg/util/leaktest", | ||
"//pkg/util/log", | ||
"//pkg/util/stop", | ||
"//pkg/util/syncutil", | ||
"//pkg/util/timeutil", | ||
"@com_github_stretchr_testify//require", | ||
], | ||
) |
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,26 @@ | ||
// Copyright 2021 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 persistedsqlstats | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/settings" | ||
) | ||
|
||
// SQLStatsFlushInterval is the cluster setting that controls how often the SQL | ||
// stats are flushed to system table. | ||
var SQLStatsFlushInterval = settings.RegisterDurationSetting( | ||
"sql.stats.flush.interval", | ||
"the interval at which SQL execution statistics are flushed to disk", | ||
time.Hour, | ||
settings.NonNegativeDurationWithMaximum(time.Hour*24), | ||
).WithPublic() |
Oops, something went wrong.