Skip to content

Commit 362021f

Browse files
sql/stats,sql/opt: detect canary window expiration in digest fast path (#166957)
sql/stats,sql/opt: detect canary window expiration in digest fast path
2 parents cedf088 + b08c515 commit 362021f

16 files changed

Lines changed: 912 additions & 34 deletions

pkg/sql/distsql_plan_changefeed.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/cockroachdb/cockroach/pkg/sql/sem/catid"
2424
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
2525
"github.com/cockroachdb/cockroach/pkg/util/errorutil/unimplemented"
26+
"github.com/cockroachdb/cockroach/pkg/util/hlc"
2627
"github.com/cockroachdb/cockroach/pkg/util/log"
2728
"github.com/cockroachdb/errors"
2829
)
@@ -480,7 +481,7 @@ func (c *cdcOptCatalog) newCDCDataSource(
480481
if err != nil {
481482
return nil, err
482483
}
483-
return newOptTable(ctx, d, c.codec(), nil /* stats */, emptyZoneConfig, false /* canaryAndStableStatsDiffer */)
484+
return newOptTable(ctx, d, c.codec(), nil /* stats */, emptyZoneConfig, false /* canaryAndStableStatsDiffer */, hlc.Timestamp{} /* canaryExpiration */)
484485
}
485486

486487
// familyTableDescriptor wraps underlying catalog.TableDescriptor,

pkg/sql/opt/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ go_library(
4848
"//pkg/sql/types",
4949
"//pkg/util",
5050
"//pkg/util/buildutil",
51+
"//pkg/util/hlc",
5152
"//pkg/util/intsets",
5253
"//pkg/util/log",
5354
"//pkg/util/syncutil",
55+
"//pkg/util/timeutil",
5456
"@com_github_cockroachdb_errors//:errors",
5557
"@com_github_cockroachdb_redact//:redact",
5658
"@com_github_lib_pq//oid",

pkg/sql/opt/cat/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ go_library(
3939
"//pkg/sql/types",
4040
"//pkg/sql/vecindex/vecpb",
4141
"//pkg/util/encoding",
42+
"//pkg/util/hlc",
4243
"//pkg/util/intsets",
4344
"//pkg/util/treeprinter",
4445
"@com_github_cockroachdb_errors//:errors",

pkg/sql/opt/cat/table.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb"
1212
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
1313
"github.com/cockroachdb/cockroach/pkg/sql/types"
14+
"github.com/cockroachdb/cockroach/pkg/util/hlc"
1415
)
1516

1617
// Table is an interface to a database table, exposing only the information
@@ -219,6 +220,11 @@ type Table interface {
219220
// this table. A non-zero value means the table participates in canary
220221
// statistics rollout.
221222
StatsCanaryWindow() time.Duration
223+
224+
// CanaryExpiration returns the timestamp at which this table's canary
225+
// window expires. Returns the empty timestamp if there is no active
226+
// canary window or canary and stable stats are already identical.
227+
CanaryExpiration() hlc.Timestamp
222228
}
223229

224230
// CheckConstraint represents a check constraint on a table. Check constraints

0 commit comments

Comments
 (0)