Skip to content

Commit b59054b

Browse files
craig[bot]spilchenwilliamchoe3yuzefovichwenyihu6
committed
155772: sql/inspect: skip REFCURSOR stored columns in consistency check r=spilchen a=spilchen REFCURSOR values cannot be compared for equality, which breaks the `INSPECT` command when an index stores a column of this type. During a consistency check, INSPECT attempts to compare stored column payloads between the primary and secondary indexes. This fails for REFCURSOR values because the column type cannot be used in an equality comparison. This change skips REFCURSOR stored columns during the primary/secondary comparison. Informs: #155676 Epic: CRDB-55075 Release note (bug fix): INSPECT can now be run on tables with indexes that store REFCURSOR-typed columns. 155789: publish-artifacts: change GCS latest key prefix for Workload binary r=rail a=williamchoe3 Informs #154274 In gcs `gs://cockroach-edge-artifacts-prod`, change `latest` Workload binary key prefix from `cockroach` to `workload` i.e. ``` gs://cockroach-edge-artifacts-prod/cockroach/workload.release-24.1 to gs://cockroach-edge-artifacts-prod/workload/workload.release-24.1 ``` This will allow `latest` workload binary to not be deleted after 30 days so tests can download and use workload binaries from unsupported versions (that no longer have nightlies running against them) Notes: * Will need to backfill currently unsupported versions * ".../workload/workload...." while descriptive also sounds redundant, open to suggestions if folks don't like that prefix * The non latest copy of the obj i.e. `gs://cockroach-edge-artifacts-prod/cockroach/workload.ee80eab77ca6434f4be7c33c0f6d29dd0b9d07b1` is still prefixed with `cockroach` so these objects will get deleted after 30 days with the current lifecycle policy Edited `PutNonRelease`'s docstring to remove "redirect" terminology, looks to be from a previous s3 implementation which is not a feature of GCS. * Note: I don't feel that strongly about the docstring, it just confused me a bit when reading the code and just wanted it to match what the function is actually doing Also noticed there's no unit test coverage for non master branches, added 1 release branch test with simple coverage Also noticed there's a slight difference between mockGCSProvider.PutObject & release.PutObject ``` # obj latest key names on gs://cockroach-edge-artifacts-prod gs://cockroach-edge-artifacts-prod/cockroach/workload.release-23.2 # obj latest key names in unit tests gs://edge-binaries-bucket/workload/workload.release-25.4/no-cache ``` Actual `release.PutObject` does not modify the key name based on the `PutObjectInput.CacheControl` field, but in `mockGCSProvider.PutObject` the `"/no-cache"` gets appended I changed the behavior in the mock to match the actual function, and modified the unit tests FWIW `PutObjectInput.CacheControl` is only set to `False` currently * It looks like this might be a hold over from the S3 implementation? I didn't read that diff but let me know if I should revert this change This PR is a dependency for these roachtest changes: #155397 Also discussed other options like using a new bucket or using the release bucket here: https://cockroachlabs.slack.com/archives/C03SG8QKYRJ/p1760977289072049?thread_ts=1760976858.868889&cid=C03SG8QKYRJ Decided on this approach for simplicity For verification, I'm relying on the unit tests. Just assumed this wouldn't work on my local, but if there's a simple way to verify this E2E let me know and i'll do it Will squash and write a proper commit msg after review, leaving commit separate incase i need to revert anything 155797: *: replace some usages of global rand r=yuzefovich a=yuzefovich **sem/builtins: use RNG from eval context for 'st_generatepoints'** ***: replace some usages of global rand** When we use `rand.*` methods like `math/rand.Intn`, under the hood we hit the global rand source, which is protected by a mutex, so we could be subject to contention on that lock. This commit updates some of such usages in favor of object-specific rand source to avoid that. Note that allocating a separate rand source is not free (the allocation itself is about 5KiB in size), so we modify spots where the lifecycle matches that of the server or when the affected code is heavy already / not on the hot path (also when it's clear that the access is from within a single goroutine). Epic: None Release note: None 155865: roachtest: remove metamorphicBufferedSender r=wenyihu6 a=wenyihu6 This setting is now enabled by default, so there is no need to enable this metamorphically. Epic: none Release note: none Co-authored-by: Matt Spilchen <[email protected]> Co-authored-by: William Choe <[email protected]> Co-authored-by: Yahor Yuzefovich <[email protected]> Co-authored-by: wenyihu6 <[email protected]>
5 parents 5e07f09 + f9aa66a + 6469695 + 8a8e228 + 830964e commit b59054b

File tree

17 files changed

+184
-82
lines changed

17 files changed

+184
-82
lines changed

pkg/cmd/publish-artifacts/main_test.go

Lines changed: 88 additions & 49 deletions
Large diffs are not rendered by default.

pkg/cmd/roachtest/test_runner.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,6 @@ func (r *testRunner) runWorker(
11041104
setting string
11051105
label string
11061106
}{
1107-
{setting: "kv.rangefeed.buffered_sender.enabled", label: "metamorphicBufferedSender"},
11081107
{setting: "kv.transaction.write_buffering.enabled", label: "metamorphicWriteBuffering"},
11091108
} {
11101109
enable := prng.Intn(2) == 0

pkg/gossip/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ go_library(
3434
"//pkg/util/log",
3535
"//pkg/util/metric",
3636
"//pkg/util/protoutil",
37+
"//pkg/util/randutil",
3738
"//pkg/util/stop",
3839
"//pkg/util/syncutil",
3940
"//pkg/util/timeutil",

pkg/gossip/gossip.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import (
6262
"github.com/cockroachdb/cockroach/pkg/util/log"
6363
"github.com/cockroachdb/cockroach/pkg/util/metric"
6464
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
65+
"github.com/cockroachdb/cockroach/pkg/util/randutil"
6566
"github.com/cockroachdb/cockroach/pkg/util/stop"
6667
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
6768
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
@@ -1360,9 +1361,10 @@ func (g *Gossip) manage(rpcContext *rpc.Context) {
13601361
var cullTimer, stallTimer timeutil.Timer
13611362
defer cullTimer.Stop()
13621363
defer stallTimer.Stop()
1364+
rng, _ := randutil.NewPseudoRand()
13631365

1364-
cullTimer.Reset(jitteredInterval(g.cullInterval))
1365-
stallTimer.Reset(jitteredInterval(g.stallInterval))
1366+
cullTimer.Reset(jitteredInterval(g.cullInterval, rng))
1367+
stallTimer.Reset(jitteredInterval(g.stallInterval, rng))
13661368
for {
13671369
select {
13681370
case <-g.server.stopper.ShouldQuiesce():
@@ -1372,7 +1374,7 @@ func (g *Gossip) manage(rpcContext *rpc.Context) {
13721374
case <-g.tighten:
13731375
g.tightenNetwork(ctx, rpcContext)
13741376
case <-cullTimer.C:
1375-
cullTimer.Reset(jitteredInterval(g.cullInterval))
1377+
cullTimer.Reset(jitteredInterval(g.cullInterval, rng))
13761378
func() {
13771379
g.mu.Lock()
13781380
if !g.outgoing.hasSpace() {
@@ -1402,7 +1404,7 @@ func (g *Gossip) manage(rpcContext *rpc.Context) {
14021404
g.mu.Unlock()
14031405
}()
14041406
case <-stallTimer.C:
1405-
stallTimer.Reset(jitteredInterval(g.stallInterval))
1407+
stallTimer.Reset(jitteredInterval(g.stallInterval, rng))
14061408
func() {
14071409
g.mu.Lock()
14081410
defer g.mu.Unlock()
@@ -1415,8 +1417,8 @@ func (g *Gossip) manage(rpcContext *rpc.Context) {
14151417

14161418
// jitteredInterval returns a randomly jittered (+/-25%) duration
14171419
// from checkInterval.
1418-
func jitteredInterval(interval time.Duration) time.Duration {
1419-
return time.Duration(float64(interval) * (0.75 + 0.5*rand.Float64()))
1420+
func jitteredInterval(interval time.Duration, rng *rand.Rand) time.Duration {
1421+
return time.Duration(float64(interval) * (0.75 + 0.5*rng.Float64()))
14201422
}
14211423

14221424
// tightenNetwork "tightens" the network by starting a new gossip client to the

pkg/release/upload.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,18 @@ func readFile(path string, dst io.Writer) error {
183183
return errors.CombineErrors(err, file.Close())
184184
}
185185

186-
// PutNonRelease uploads non-release related files.
187-
// Files are uploaded to /cockroach/<FilePath> for each non release file.
188-
// A `latest` key is then put at cockroach/<RedirectPrefix>.<BranchName> that redirects
189-
// to the above file.
186+
// PutNonRelease uploads non-release related files
187+
//
188+
// Each file is uploaded to /<prefix>/<FilePath> with prefix cockroach
189+
// i.e. /cockroach/<FilePath>
190+
//
191+
// Then that file is uploaded again under a `latest` key
192+
// <prefix>/<RedirectPrefix>.<BranchName>
193+
// Workload "latest" objects are stored under workload/<RedirectPrefix>.<BranchName>
194+
// All other "latest" objects are stored under cockroach/<RedirectPrefix>.<BranchName>
190195
func PutNonRelease(svc ObjectPutGetter, o PutNonReleaseOptions) {
191196
const nonReleasePrefix = "cockroach"
197+
const workloadPrefix = "workload"
192198
for _, f := range o.Files {
193199
disposition := mime.FormatMediaType("attachment", map[string]string{
194200
"filename": f.FileName,
@@ -214,7 +220,13 @@ func PutNonRelease(svc ObjectPutGetter, o PutNonReleaseOptions) {
214220
if latestSuffix == "master" {
215221
latestSuffix = "LATEST"
216222
}
217-
latestKey := fmt.Sprintf("%s/%s.%s", nonReleasePrefix, f.RedirectPathPrefix, latestSuffix)
223+
var latestPrefix string
224+
if strings.HasPrefix(f.RedirectPathPrefix, "workload") {
225+
latestPrefix = workloadPrefix
226+
} else {
227+
latestPrefix = nonReleasePrefix
228+
}
229+
latestKey := fmt.Sprintf("%s/%s.%s", latestPrefix, f.RedirectPathPrefix, latestSuffix)
218230
// NB: The leading slash is required to make redirects work
219231
// correctly since we reuse this key as the redirect location.
220232
target := "/" + versionKey

pkg/server/diagnostics/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ go_library(
3636
"//pkg/util/log",
3737
"//pkg/util/log/logcrash",
3838
"//pkg/util/protoutil",
39+
"//pkg/util/randutil",
3940
"//pkg/util/stop",
4041
"//pkg/util/syncutil",
4142
"//pkg/util/system",

pkg/server/diagnostics/diagnostics.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ func addInfoToURL(
149149
}
150150

151151
// randomly shift `d` to be up to `jitterSeconds` shorter or longer.
152-
func addJitter(d time.Duration) time.Duration {
152+
func addJitter(d time.Duration, rng *rand.Rand) time.Duration {
153153
const jitterSeconds = 120
154-
j := time.Duration(rand.Intn(jitterSeconds*2)-jitterSeconds) * time.Second
154+
j := time.Duration(rng.Intn(jitterSeconds*2)-jitterSeconds) * time.Second
155155
return d + j
156156
}
157157

pkg/server/diagnostics/reporter.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
"github.com/cockroachdb/cockroach/pkg/util/log"
4141
"github.com/cockroachdb/cockroach/pkg/util/log/logcrash"
4242
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
43+
"github.com/cockroachdb/cockroach/pkg/util/randutil"
4344
"github.com/cockroachdb/cockroach/pkg/util/stop"
4445
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
4546
"github.com/cockroachdb/cockroach/pkg/util/uuid"
@@ -185,6 +186,7 @@ func (r *Reporter) PeriodicallyReportDiagnostics(ctx context.Context, stopper *s
185186
ctx, cancel = stopper.WithCancelOnQuiesce(ctx)
186187
defer cancel()
187188
defer logcrash.RecoverAndReportNonfatalPanic(ctx, &r.Settings.SV)
189+
rng, _ := randutil.NewPseudoRand()
188190
nextReport := r.StartTime
189191

190192
var timer timeutil.Timer
@@ -199,7 +201,7 @@ func (r *Reporter) PeriodicallyReportDiagnostics(ctx context.Context, stopper *s
199201

200202
nextReport = nextReport.Add(reportFrequency.Get(&r.Settings.SV))
201203

202-
timer.Reset(addJitter(nextReport.Sub(timeutil.Now())))
204+
timer.Reset(addJitter(nextReport.Sub(timeutil.Now()), rng))
203205
select {
204206
case <-stopper.ShouldQuiesce():
205207
return

pkg/server/diagnostics/update_checker.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/cockroachdb/cockroach/pkg/util/httputil"
2323
"github.com/cockroachdb/cockroach/pkg/util/log"
2424
"github.com/cockroachdb/cockroach/pkg/util/log/logcrash"
25+
"github.com/cockroachdb/cockroach/pkg/util/randutil"
2526
"github.com/cockroachdb/cockroach/pkg/util/stop"
2627
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
2728
"github.com/cockroachdb/cockroach/pkg/util/uuid"
@@ -74,6 +75,7 @@ func (u *UpdateChecker) PeriodicallyCheckForUpdates(ctx context.Context, stopper
7475
SpanOpt: stop.SterileRootSpan,
7576
}, func(ctx context.Context) {
7677
defer logcrash.RecoverAndReportNonfatalPanic(ctx, &u.Settings.SV)
78+
rng, _ := randutil.NewPseudoRand()
7779
nextUpdateCheck := u.StartTime
7880

7981
var timer timeutil.Timer
@@ -84,7 +86,7 @@ func (u *UpdateChecker) PeriodicallyCheckForUpdates(ctx context.Context, stopper
8486

8587
nextUpdateCheck = u.maybeCheckForUpdates(ctx, now, nextUpdateCheck, runningTime)
8688

87-
timer.Reset(addJitter(nextUpdateCheck.Sub(timeutil.Now())))
89+
timer.Reset(addJitter(nextUpdateCheck.Sub(timeutil.Now()), rng))
8890
select {
8991
case <-stopper.ShouldQuiesce():
9092
return

pkg/sql/catalog/lease/storage.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ var LeaseRenewalCrossValidate = settings.RegisterBoolSetting(
111111
func (s storage) jitteredLeaseDuration() time.Duration {
112112
leaseDuration := LeaseDuration.Get(&s.settings.SV)
113113
jitterFraction := LeaseJitterFraction.Get(&s.settings.SV)
114+
// TODO(yuzefovich): it would probably be worth replacing this usage of
115+
// global rand with rng tied to the 'storage' object. It's not clear whether
116+
// we need concurrency safety or not.
114117
return time.Duration(float64(leaseDuration) * (1 - jitterFraction +
115118
2*jitterFraction*rand.Float64()))
116119
}

0 commit comments

Comments
 (0)