Skip to content

Commit

Permalink
Merge #139065
Browse files Browse the repository at this point in the history
139065: catalog/lease: WaitForInitialVersion should be version gated r=fqazi a=fqazi

Previously, we could have mixed version configurations hang waiting for initial version of descriptors, when new objects are created. This was because prior releases of CRDB do not have logic to lease new descriptors automatically. This patch adds a version gate to enable the WaitForInitialVersion and the memo staleness optimizations once 25.1 is finalized.

Fixes: #139015

Release note: None

Co-authored-by: Faizan Qazi <[email protected]>
  • Loading branch information
craig[bot] and fqazi committed Jan 14, 2025
2 parents 7c622cd + 023dbc1 commit d006f32
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/sql/catalog/lease/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//pkg/base",
"//pkg/clusterversion",
"//pkg/keys",
"//pkg/kv",
"//pkg/kv/kvclient/rangefeed",
Expand Down
4 changes: 3 additions & 1 deletion pkg/sql/catalog/lease/lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"time"

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/clusterversion"
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/kv"
"github.com/cockroachdb/cockroach/pkg/kv/kvclient/rangefeed"
Expand Down Expand Up @@ -313,7 +314,8 @@ func (m *Manager) WaitForInitialVersion(
retryOpts retry.Options,
regions regionliveness.CachedDatabaseRegions,
) error {
if !WaitForInitialVersion.Get(&m.settings.SV) {
if !WaitForInitialVersion.Get(&m.settings.SV) ||
!m.storage.settings.Version.IsActive(ctx, clusterversion.V25_1) {
return nil
}
wsTracker := startWaitStatsTracker(ctx)
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/opt/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ go_library(
importpath = "github.com/cockroachdb/cockroach/pkg/sql/opt",
visibility = ["//visibility:public"],
deps = [
"//pkg/clusterversion",
"//pkg/server/telemetry",
"//pkg/sql/catalog",
"//pkg/sql/catalog/catpb",
Expand Down
2 changes: 2 additions & 0 deletions pkg/sql/opt/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"math/bits"
"strings"

"github.com/cockroachdb/cockroach/pkg/clusterversion"
"github.com/cockroachdb/cockroach/pkg/sql/catalog"
"github.com/cockroachdb/cockroach/pkg/sql/catalog/multiregion"
"github.com/cockroachdb/cockroach/pkg/sql/opt/cat"
Expand Down Expand Up @@ -397,6 +398,7 @@ func (md *Metadata) CheckDependencies(
// is sufficient.
currentDigest := optCatalog.GetDependencyDigest()
if evalCtx.SessionData().CatalogDigestStalenessCheckEnabled &&
evalCtx.Settings.Version.IsActive(ctx, clusterversion.V25_1) &&
evalCtx.AsOfSystemTime == nil &&
!evalCtx.Txn.ReadTimestampFixed() &&
md.dependencyDigestEquals(&currentDigest) {
Expand Down

0 comments on commit d006f32

Please sign in to comment.