Skip to content

Commit 61a9d7d

Browse files
craig[bot]stevendannajeffswensonRaduBerindemgartner
committed
152658: jobs: avoid unnecessary writes r=dt a=stevendanna See individual commits. 154149: azure: configure a default TryTimeout of 60 seconds r=jeffswenson a=jeffswenson We have seen some evidence of stuck or slow requests to azure blob storage. Setting a try timeout allows us to retry these slow operations and may allow us to make forward progress if the underlying error is transient. Operations that run into the TryTimeout will be internally retried by the cloud package. The TryTimeout can be controlled via the cloudstorage.azure.try.timeout setting. Setting it to zero disables the per-attempt timeout. 60 seconds is a relatively long timeout. The main reason it is set that long is the timeout is applied to read operations and CRDB sometimes performs long lived stream reads when it is merging many SSTs during a restore. Release note: Add a default TryTimeout of 60 seconds for Azure Blob Storage to mitigate occasional stuck operations. Fixes: #154085 154579: storageconfig: encryption YAML support and validation r=RaduBerinde a=RaduBerinde #### storageconfig: move StoreEncryptionSpec to cli The separate encryption specs are a byproduct of having to use a separate command-line flag. This change moves the related code to the cli package. Epic: none Release note: None #### storageconfig: move WAL failover flag code to cli Move the pflag-specific part to cli. Epic: none Release note: None #### storageconfig: use time.Duration for rotation period Epic: none Release note: None #### storageconfig: encryption YAML support and validation Support yaml for the encryption options and add validation. Epic: none Release note: None 154682: opt: move some assignment cast execbuilder logic to init-time r=mgartner a=mgartner #### opt: move some assignment cast execbuilder logic to init-time Lookups for the `crdb_internal.assignment_cast` function properties and overload are now performed once at init-time instead of for every assignment cast built at execbuild-time. Release note: None #### sql/sem/tree: remove always-nil error return from GetBuiltinFuncDefinition Release note: None 154743: server: check for isMeta1Leaseholder later in loop r=arulajmani a=stevendanna This checks for isMeta1Leaseholder after first checking the version, allowing the version checking goroutine to exit early for the common case of being on the most recent version. Epic: none Release note: None 154745: ui: update txn diagnostics history UI text and docs link r=jasonlmfong a=dhartunian Point users to new docs link and builtin. Epic: CRDB-53541 Resolves: CRDB-55077 Release note: None Co-authored-by: Steven Danna <[email protected]> Co-authored-by: Jeff Swenson <[email protected]> Co-authored-by: Radu Berinde <[email protected]> Co-authored-by: Marcus Gartner <[email protected]> Co-authored-by: David Hartunian <[email protected]>
7 parents e9a0b1c + 1d8250f + b299a3b + ffac2ad + a3a9de3 + ef35aef + 290dc2a commit 61a9d7d

File tree

36 files changed

+691
-619
lines changed

36 files changed

+691
-619
lines changed

pkg/base/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ go_test(
7474
"//pkg/util/leaktest",
7575
"//pkg/util/log",
7676
"//pkg/util/uuid",
77-
"@com_github_cockroachdb_datadriven//:datadriven",
7877
"@com_github_cockroachdb_errors//:errors",
7978
"@com_github_davecgh_go_spew//spew",
8079
"@com_github_stretchr_testify//require",

pkg/base/config_test.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,15 @@
66
package base_test
77

88
import (
9-
"bytes"
109
"fmt"
1110
"math"
12-
"strings"
1311
"testing"
1412
"time"
1513

1614
"github.com/cockroachdb/cockroach/pkg/base"
17-
"github.com/cockroachdb/cockroach/pkg/storage/storageconfig"
1815
"github.com/cockroachdb/cockroach/pkg/testutils/datapathutils"
1916
"github.com/cockroachdb/cockroach/pkg/testutils/echotest"
2017
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
21-
"github.com/cockroachdb/datadriven"
2218
"github.com/davecgh/go-spew/spew"
2319
"github.com/stretchr/testify/require"
2420
)
@@ -211,20 +207,3 @@ func TestRaftMaxInflightBytes(t *testing.T) {
211207
})
212208
}
213209
}
214-
215-
func TestWALFailoverConfigRoundtrip(t *testing.T) {
216-
defer leaktest.AfterTest(t)()
217-
218-
datadriven.RunTest(t, datapathutils.TestDataPath(t, "wal-failover-config"), func(t *testing.T, d *datadriven.TestData) string {
219-
var buf bytes.Buffer
220-
for _, l := range strings.Split(d.Input, "\n") {
221-
var cfg storageconfig.WALFailover
222-
if err := cfg.Set(l); err != nil {
223-
fmt.Fprintf(&buf, "err: %s\n", err)
224-
continue
225-
}
226-
fmt.Fprintln(&buf, cfg.String())
227-
}
228-
return buf.String()
229-
})
230-
}

pkg/base/store_spec.go

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -333,64 +333,3 @@ func (ssl *StoreSpecList) Set(value string) error {
333333
}
334334
return nil
335335
}
336-
337-
// PopulateWithEncryptionOpts iterates through the EncryptionSpecList and looks
338-
// for matching paths in the StoreSpecList and WAL failover config. Any
339-
// unmatched EncryptionSpec causes an error.
340-
func PopulateWithEncryptionOpts(
341-
storeSpecs StoreSpecList,
342-
walFailoverConfig *storageconfig.WALFailover,
343-
encryptionSpecs storageconfig.EncryptionSpecList,
344-
) error {
345-
for _, es := range encryptionSpecs.Specs {
346-
var storeMatched bool
347-
for i := range storeSpecs.Specs {
348-
if !es.PathMatches(storeSpecs.Specs[i].Path) {
349-
continue
350-
}
351-
352-
// Found a matching path.
353-
if storeSpecs.Specs[i].EncryptionOptions != nil {
354-
return fmt.Errorf("store with path %s already has an encryption setting",
355-
storeSpecs.Specs[i].Path)
356-
}
357-
358-
storeSpecs.Specs[i].EncryptionOptions = &es.Options
359-
storeMatched = true
360-
break
361-
}
362-
pathMatched, err := maybeSetExternalPathEncryption(&walFailoverConfig.Path, es)
363-
if err != nil {
364-
return err
365-
}
366-
prevPathMatched, err := maybeSetExternalPathEncryption(&walFailoverConfig.PrevPath, es)
367-
if err != nil {
368-
return err
369-
}
370-
if !storeMatched && !pathMatched && !prevPathMatched {
371-
return fmt.Errorf("no usage of path %s found for encryption setting: %v", es.Path, es)
372-
}
373-
}
374-
return nil
375-
}
376-
377-
// maybeSetExternalPathEncryption updates an ExternalPath to contain the provided
378-
// encryption options if the path matches. The ExternalPath must not already have
379-
// an encryption setting.
380-
func maybeSetExternalPathEncryption(
381-
externalPath *storageconfig.ExternalPath, es storageconfig.StoreEncryptionSpec,
382-
) (found bool, err error) {
383-
if !externalPath.IsSet() || !es.PathMatches(externalPath.Path) {
384-
return false, nil
385-
}
386-
// NB: The external paths WALFailoverConfig.Path and
387-
// WALFailoverConfig.PrevPath are only ever set in single-store
388-
// configurations. In multi-store with among-stores failover mode, these
389-
// will be empty (so we won't encounter the same path twice).
390-
if externalPath.Encryption != nil {
391-
return false, fmt.Errorf("WAL failover path %s already has an encryption setting",
392-
externalPath.Path)
393-
}
394-
externalPath.Encryption = &es.Options
395-
return true, nil
396-
}

pkg/bench/rttanalysis/testdata/benchmark_expectations

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,16 @@ exp,benchmark
6161
8,Grant/grant_all_on_3_tables
6262
12,GrantRole/grant_1_role
6363
16,GrantRole/grant_2_roles
64-
12-15,Jobs/cancel_job
64+
9-12,Jobs/cancel_job
6565
3,Jobs/crdb_internal.system_jobs
6666
3-5,Jobs/jobs_page_default
6767
3,Jobs/jobs_page_latest_50
6868
3,Jobs/jobs_page_type_filtered
6969
1-3,Jobs/jobs_page_type_filtered_no_matches
7070
2,Jobs/non_admin_crdb_internal.system_jobs
7171
2,Jobs/non_admin_show_jobs
72-
12-15,Jobs/pause_job
73-
12-15,Jobs/resume_job
72+
9-12,Jobs/pause_job
73+
9-12,Jobs/resume_job
7474
3,Jobs/show_job
7575
3-5,Jobs/show_jobs
7676
3,ORMQueries/activerecord_type_introspection_query

pkg/ccl/storageccl/engineccl/encrypted_fs.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package engineccl
88
import (
99
"context"
1010
"fmt"
11+
"time"
1112

1213
"github.com/cockroachdb/cockroach/pkg/storage/enginepb"
1314
"github.com/cockroachdb/cockroach/pkg/storage/fs"
@@ -319,7 +320,7 @@ func newEncryptedEnv(
319320
dataKeyManager := &DataKeyManager{
320321
fs: storeFS,
321322
dbDir: dbDir,
322-
rotationPeriod: options.DataKeyRotationPeriod,
323+
rotationPeriod: int64((options.RotationPeriod + time.Second - 1) / time.Second),
323324
readOnly: readOnly,
324325
}
325326
if err := dataKeyManager.Load(context.TODO()); err != nil {

pkg/ccl/storageccl/engineccl/encrypted_fs_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"strconv"
1717
"strings"
1818
"testing"
19+
"time"
1920

2021
"github.com/cockroachdb/cockroach/pkg/base"
2122
"github.com/cockroachdb/cockroach/pkg/roachpb"
@@ -242,7 +243,7 @@ func TestPebbleEncryption(t *testing.T) {
242243
CurrentKey: "16.key",
243244
OldKey: "plain",
244245
},
245-
DataKeyRotationPeriod: 1000, // arbitrary seconds
246+
RotationPeriod: time.Hour,
246247
}
247248

248249
func() {
@@ -385,7 +386,7 @@ func TestPebbleEncryption2(t *testing.T) {
385386
CurrentKey: encKeyFile,
386387
OldKey: oldEncFileKey,
387388
},
388-
DataKeyRotationPeriod: 1000,
389+
RotationPeriod: time.Hour,
389390
}
390391

391392
// Initialize the filesystem env.
@@ -580,7 +581,7 @@ func makeEncryptedTestFS(t *testing.T, errorProb float64, errorRand *rand.Rand)
580581
//
581582
// TODO(sumeer): Do deterministic data key rotation. Inject kmTimeNow and
582583
// operations that advance time.
583-
encOptions.DataKeyRotationPeriod = 100000
584+
encOptions.RotationPeriod = 100000 * time.Second
584585
etfs := &encryptedTestFS{
585586
mem: mem,
586587
encOptions: &encOptions,

pkg/cli/context.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -720,23 +720,3 @@ var userfileCtx struct {
720720
func setUserfileContextDefaults() {
721721
userfileCtx.recursive = false
722722
}
723-
724-
// GetServerCfgStores provides direct public access to the StoreSpecList inside
725-
// serverCfg. This is used by CCL code to populate some fields.
726-
//
727-
// WARNING: consider very carefully whether you should be using this.
728-
// If you are not writing CCL code that performs command-line flag
729-
// parsing, you probably should not be using this.
730-
func GetServerCfgStores() base.StoreSpecList {
731-
return serverCfg.Stores
732-
}
733-
734-
// GetWALFailoverConfig provides direct public access to the WALFailoverConfig
735-
// inside serverCfg. This is used by CCL code to populate some fields.
736-
//
737-
// WARNING: consider very carefully whether you should be using this.
738-
// If you are not writing CCL code that performs command-line flag
739-
// parsing, you probably should not be using this.
740-
func GetWALFailoverConfig() *storageconfig.WALFailover {
741-
return &serverCfg.StorageConfig.WALFailover
742-
}

pkg/cli/debug_ear.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"github.com/cockroachdb/cockroach/pkg/storage"
2121
"github.com/cockroachdb/cockroach/pkg/storage/enginepb"
2222
"github.com/cockroachdb/cockroach/pkg/storage/fs"
23-
"github.com/cockroachdb/cockroach/pkg/storage/storageconfig"
2423
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
2524
"github.com/cockroachdb/cockroach/pkg/util/stop"
2625
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
@@ -169,7 +168,7 @@ with their env type and encryption settings (if applicable).
169168
// fillEncryptionOptionsForStore fills the EnvConfig fields
170169
// based on the --enterprise-encryption flag value.
171170
func fillEncryptionOptionsForStore(dir string, cfg *fs.EnvConfig) error {
172-
opts, err := storageconfig.EncryptionOptionsForStore(dir, encryptionSpecs)
171+
opts, err := encryptionOptionsForStore(dir, encryptionSpecs)
173172
if err != nil {
174173
return err
175174
}

pkg/cli/ear_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
1919
"github.com/cockroachdb/cockroach/pkg/storage"
2020
"github.com/cockroachdb/cockroach/pkg/storage/fs"
21-
"github.com/cockroachdb/cockroach/pkg/storage/storageconfig"
2221
"github.com/cockroachdb/cockroach/pkg/testutils/datapathutils"
2322
"github.com/cockroachdb/cockroach/pkg/util/envutil"
2423
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
@@ -44,7 +43,7 @@ func TestDecrypt(t *testing.T) {
4443

4544
// Spin up a new encrypted store.
4645
encSpecStr := fmt.Sprintf("path=%s,key=%s,old-key=plain", dir, keyPath)
47-
encSpec, err := storageconfig.NewStoreEncryptionSpec(encSpecStr)
46+
encSpec, err := parseStoreEncryptionSpec(encSpecStr)
4847
require.NoError(t, err)
4948
encOpts := &encSpec.Options
5049

@@ -126,7 +125,7 @@ func TestList(t *testing.T) {
126125

127126
// Spin up a new encrypted store.
128127
encSpecStr := fmt.Sprintf("path=%s,key=%s,old-key=plain", dir, keyPath)
129-
encSpec, err := storageconfig.NewStoreEncryptionSpec(encSpecStr)
128+
encSpec, err := parseStoreEncryptionSpec(encSpecStr)
130129
require.NoError(t, err)
131130
encOpts := &encSpec.Options
132131
env, err := fs.InitEnv(ctx, vfs.Default, dir, fs.EnvConfig{EncryptionOptions: encOpts}, nil /* statsCollector */)

pkg/cli/flags.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ var storeSpecs base.StoreSpecList
6262
var goMemLimit int64
6363
var tenantIDFile string
6464
var localityFile string
65-
var encryptionSpecs storageconfig.EncryptionSpecList
65+
var encryptionSpecs encryptionSpecList
6666

6767
// initPreFlagsDefaults initializes the values of the global variables
6868
// defined above.
@@ -431,7 +431,11 @@ func init() {
431431

432432
// Add a new pre-run command to match encryption specs to store specs.
433433
AddPersistentPreRunE(cmd, func(cmd *cobra.Command, _ []string) error {
434-
return populateStoreSpecsEncryption()
434+
return populateWithEncryptionOpts(
435+
serverCfg.Stores,
436+
&serverCfg.StorageConfig.WALFailover,
437+
encryptionSpecs,
438+
)
435439
})
436440
}
437441

@@ -525,7 +529,7 @@ func init() {
525529
cliflagcfg.StringFlag(f, &deprecatedStorageEngine, cliflags.StorageEngine)
526530
_ = pf.MarkHidden(cliflags.StorageEngine.Name)
527531

528-
cliflagcfg.VarFlag(f, &serverCfg.StorageConfig.WALFailover, cliflags.WALFailover)
532+
cliflagcfg.VarFlag(f, &walFailoverWrapper{cfg: &serverCfg.StorageConfig.WALFailover}, cliflags.WALFailover)
529533
// TODO(storage): Consider combining the uri and cache manual settings.
530534
// Alternatively remove the ability to configure shared storage without
531535
// passing a bootstrap configuration file.
@@ -1485,17 +1489,6 @@ func mtStartSQLFlagsInit(cmd *cobra.Command) error {
14851489
return nil
14861490
}
14871491

1488-
// populateStoreSpecsEncryption is a PreRun hook that matches store encryption
1489-
// specs with the parsed stores and populates some fields in the StoreSpec and
1490-
// WAL failover config.
1491-
func populateStoreSpecsEncryption() error {
1492-
return base.PopulateWithEncryptionOpts(
1493-
GetServerCfgStores(),
1494-
GetWALFailoverConfig(),
1495-
encryptionSpecs,
1496-
)
1497-
}
1498-
14991492
// sizeFlagVal is a pflag.Value wrapper for storageconfig.Size. It can be
15001493
// set to an absolute bytes amount or a percentage.
15011494
type sizeFlagVal struct {

0 commit comments

Comments
 (0)