Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
92628: sql: add SHOW TENANT name WITH REPLICATION STATUS r=lidorcarmel a=lidorcarmel

Extending SHOW TENANT to also allow showing replication status which contains info such as the protected timestamp on the destination cluster and the source cluster name.

Command output right after the destination cluster is created:

```
[email protected]:26257/defaultdb> show tenant dest5 with replication status;
  id | name  | status | source_tenant_name | source_cluster_uri | replication_job_id | replicated_time | retained_time
-----+-------+--------+--------------------+--------------------+--------------------+-----------------+----------------
   7 | dest5 | ADD    | NULL               | NULL               | 819890711267737601 | NULL            | NULL
(1 row)
```

A bit later we have most stats (manually adjusting the source_cluster_uri):
```
[email protected]:26257/defaultdb> show tenant dest5 with replication status;
  id | name  | status | source_tenant_name | source_cluster_uri                                    | replication_job_id | replicated_time |       retained_time
-----+-------+--------+--------------------+-------------------------------------------------------+--------------------+-----------------+-----------------------------
   7 | dest5 | ADD    | src                | postgresql://[email protected]:26257/defaultdb?ssl...crt | 819890711267737601 | NULL            | 2022-12-05 23:00:04.516331
(1 row)
```

And a moment later the replication time is populated.

Fixes: #91261

Epic: CRDB-18749

Release note: None

92774: scrun: added a cluster setting to skip planner sanity checks in prod r=Xiang-Gu a=Xiang-Gu

Previously, there is a niche case where we might run into a backward incompatible issue (see #91528). We decided to fix it by relaxing the sanity check that caused the issue and backport the change to relase-22.2, so this backward incompatibility issue is contained only between release-22.2.0 and master, which we think should be a rare occurrance in the wild.

Fixes: #91528
Release note: None

93103: roachprod: remove COCKROACH_UI_RELEASE_NOTES_SIGNUP_DISMISSED r=nkodali,herkolategan a=srosenberg

Remove COCKROACH_UI_RELEASE_NOTES_SIGNUP_DISMISSED which had previously been used by roachprod circa 2020, until it got reverted in [1]. It has no effect after the PR which reverted the related change.

Release note: None
Epic: None

[1] #57003

93150: ui: remove feedback survey link r=Santamaura a=Santamaura

This change removes the survey feedback link from the admin ui due to the AppCues survey being retired.

Fixes: #92867

Release note (ui change): remove feedback survey link

93215: opt: omit unnecessary assignment casts for UDF return values r=mgartner a=mgartner

Previously, UDF return values were being assignment-casted to the return type of the UDF function when the types were identical. These casts are no longer created.

Epic: CRDB-20370

Fixes #93210

Release note: None

93255: cli: flag doc updates r=andreimatei a=knz

See the individual commits for details.

Epic: None

Co-authored-by: Lidor Carmel <[email protected]>
Co-authored-by: Xiang Gu <[email protected]>
Co-authored-by: Stan Rosenberg <[email protected]>
Co-authored-by: Santamaura <[email protected]>
Co-authored-by: Marcus Gartner <[email protected]>
Co-authored-by: Raphael 'kena' Poss <[email protected]>
  • Loading branch information
7 people committed Dec 8, 2022
7 parents eb02796 + dcd183c + 255ceba + 3b8e08a + ea5e586 + 50aa2a5 + ade6297 commit fe683e3
Show file tree
Hide file tree
Showing 35 changed files with 436 additions and 253 deletions.
3 changes: 2 additions & 1 deletion docs/generated/sql/bnf/show_tenant_stmt.bnf
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
show_tenant_stmt ::=
'SHOW' 'TENANT' name
'SHOW' 'TENANT' d_expr
| 'SHOW' 'TENANT' d_expr 'WITH' 'REPLICATION' 'STATUS'
3 changes: 2 additions & 1 deletion docs/generated/sql/bnf/stmt_block.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,8 @@ show_tables_stmt ::=
| 'SHOW' 'TABLES' with_comment

show_tenant_stmt ::=
'SHOW' 'TENANT' name
'SHOW' 'TENANT' d_expr
| 'SHOW' 'TENANT' d_expr 'WITH' 'REPLICATION' 'STATUS'

show_trace_stmt ::=
'SHOW' opt_compact 'TRACE' 'FOR' 'SESSION'
Expand Down
3 changes: 3 additions & 0 deletions pkg/ccl/streamingccl/streamclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ func NewStreamClient(
// GetFirstActiveClient iterates through each provided stream address
// and returns the first client it's able to successfully Dial.
func GetFirstActiveClient(ctx context.Context, streamAddresses []string) (Client, error) {
if len(streamAddresses) == 0 {
return nil, errors.Newf("failed to connect, no partition addresses")
}
var combinedError error = nil
for _, address := range streamAddresses {
streamAddress := streamingccl.StreamAddress(address)
Expand Down
9 changes: 9 additions & 0 deletions pkg/ccl/streamingccl/streamclient/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ func (t testStreamSubscription) Err() error {
return nil
}

func TestGetFirstActiveClientEmpty(t *testing.T) {
defer leaktest.AfterTest(t)()

var streamAddresses []string
activeClient, err := GetFirstActiveClient(context.Background(), streamAddresses)
require.ErrorContains(t, err, "failed to connect, no partition addresses")
require.Nil(t, activeClient)
}

func TestGetFirstActiveClient(t *testing.T) {
defer leaktest.AfterTest(t)()

Expand Down
44 changes: 44 additions & 0 deletions pkg/ccl/streamingccl/streamingest/stream_replication_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"github.com/cockroachdb/errors"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -1244,3 +1245,46 @@ func TestTenantReplicationProtectedTimestampManagement(t *testing.T) {
})
})
}

// TODO(lidor): consider rewriting this test as a data driven test when #92609 is merged.
func TestTenantStreamingShowTenant(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)

ctx := context.Background()
args := defaultTenantStreamingClustersArgs

c, cleanup := createTenantStreamingClusters(ctx, t, args)
defer cleanup()
testStartTime := timeutil.Now()
producerJobID, ingestionJobID := c.startStreamReplication()

jobutils.WaitForJobToRun(c.t, c.srcSysSQL, jobspb.JobID(producerJobID))
jobutils.WaitForJobToRun(c.t, c.destSysSQL, jobspb.JobID(ingestionJobID))
highWatermark := c.srcCluster.Server(0).Clock().Now()
c.waitUntilHighWatermark(highWatermark, jobspb.JobID(ingestionJobID))

var (
id int
dest string
status string
source string
sourceUri string
jobId int
maxReplTime time.Time
protectedTime time.Time
)
row := c.destSysSQL.QueryRow(t, fmt.Sprintf("SHOW TENANT %s WITH REPLICATION STATUS", args.destTenantName))
row.Scan(&id, &dest, &status, &source, &sourceUri, &jobId, &maxReplTime, &protectedTime)
require.Equal(t, 2, id)
require.Equal(t, "destination", dest)
require.Equal(t, "ADD", status)
require.Equal(t, "source", source)
require.Equal(t, c.srcURL.String(), sourceUri)
require.Equal(t, ingestionJobID, jobId)
require.Less(t, maxReplTime, timeutil.Now())
require.Less(t, protectedTime, timeutil.Now())
require.GreaterOrEqual(t, maxReplTime, highWatermark.GoTime())
// TODO(lidor): replace this start time with the actual replication start time when we have it.
require.GreaterOrEqual(t, protectedTime, testStartTime)
}
40 changes: 20 additions & 20 deletions pkg/cli/cliflags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1642,46 +1642,46 @@ the --log flag.`,
present in the body of the logging configuration.`,
}

DeprecatedStderrThreshold = FlagInfo{
Name: "logtostderr",
Description: `Write log messages beyond the specified severity to stderr.`,
StderrThresholdOverride = FlagInfo{
Name: "logtostderr",
Description: `--logtostderr=XXX is an alias for --log='sinks: {stderr: {filter: XXX}}'.
If no value is specified, the default value for the command is inferred: INFO for server
commands, WARNING for client commands.`,
}

DeprecatedFileThreshold = FlagInfo{
FileThresholdOverride = FlagInfo{
Name: "log-file-verbosity",
Description: `Write log messages beyond the specified severity to files.`,
Description: `--log-file-verbosity=XXX is an alias for --log='file-defaults: {filter: XXX}}'.`,
}

DeprecatedStderrNoColor = FlagInfo{
StderrNoColorOverride = FlagInfo{
Name: "no-color",
Description: `Avoid color in the stderr output.`,
Description: `--no-color=XXX is an alias for --log='sinks: {stderr: {no-color: XXX}}'.`,
}

DeprecatedRedactableLogs = FlagInfo{
RedactableLogsOverride = FlagInfo{
Name: "redactable-logs",
Description: `Request redaction markers.`,
Description: `--redactable-logs=XXX is an alias for --log='file-defaults: {redactable: XXX}}'.`,
}

DeprecatedLogFileMaxSize = FlagInfo{
LogFileMaxSizeOverride = FlagInfo{
Name: "log-file-max-size",
Description: "Maximum size of a log file before switching to a new file.",
Description: "--log-file-max-size=XXX is an alias for --log='file-defaults: {max-file-size: XXX}'.",
}

DeprecatedLogGroupMaxSize = FlagInfo{
LogGroupMaxSizeOverride = FlagInfo{
Name: "log-group-max-size",
Description: `Maximum size of a group of log files before old files are removed.`,
Description: `--log-group-max-size=XXX is an alias for --log='file-defaults: {max-group-size: XXX}'.`,
}

DeprecatedLogDir = FlagInfo{
LogDirOverride = FlagInfo{
Name: "log-dir",
Description: `Override the logging directory.`,
Description: `--log-dir=XXX is an alias for --log='file-defaults: {dir: XXX}'.`,
}

DeprecatedSQLAuditLogDir = FlagInfo{
Name: "sql-audit-dir",
Description: `
If non-empty, create a SQL audit log in this directory.
`,
SQLAuditLogDirOverride = FlagInfo{
Name: "sql-audit-dir",
Description: `--sql-audit-dir=XXX is an alias for --log='sinks: {file-groups: {sql-audit: {channels: SENSITIVE_ACCESS, dir: ...}}}'.`,
}

BuildTag = FlagInfo{
Expand Down
17 changes: 7 additions & 10 deletions pkg/cli/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,9 @@ type cliContext struct {
// before exiting the process. This may block until all buffered log sinks
// are shutdown, if any are enabled, or until a timeout is triggered.
logShutdownFn func()
// deprecatedLogOverrides is the legacy pre-v21.1 discrete flag
// overrides for the logging configuration.
// TODO(knz): Deprecated in v21.1. Remove this.
deprecatedLogOverrides *logConfigFlags
// logOverrides encodes discrete flag overrides for the logging
// configuration. They are provided for convenience.
logOverrides *logConfigFlags
// ambiguousLogDir is populated during setupLogging() to indicate
// that no log directory was specified and there were multiple
// on-disk stores.
Expand All @@ -187,9 +186,8 @@ type cliContext struct {
// cliCtx captures the command-line parameters common to most CLI utilities.
// See below for defaults.
var cliCtx = cliContext{
Config: baseCfg,
// TODO(knz): Deprecated in v21.1. Remove this.
deprecatedLogOverrides: newLogConfigOverrides(),
Config: baseCfg,
logOverrides: newLogConfigOverrides(),
}

// setCliContextDefaults set the default values in cliCtx. This
Expand All @@ -214,8 +212,7 @@ func setCliContextDefaults() {
cliCtx.logConfig = logconfig.Config{}
cliCtx.logShutdownFn = func() {}
cliCtx.ambiguousLogDir = false
// TODO(knz): Deprecated in v21.1. Remove this.
cliCtx.deprecatedLogOverrides.reset()
cliCtx.logOverrides.reset()
cliCtx.showVersionUsingOnlyBuildTag = false
}

Expand Down Expand Up @@ -610,7 +607,7 @@ func setDemoContextDefaults() {
demoCtx.NumNodes = 1
demoCtx.SQLPoolMemorySize = 128 << 20 // 128MB, chosen to fit 9 nodes on 2GB machine.
demoCtx.CacheSize = 64 << 20 // 64MB, chosen to fit 9 nodes on 2GB machine.
demoCtx.NoExampleDatabase = false
demoCtx.UseEmptyDatabase = false
demoCtx.SimulateLatency = false
demoCtx.RunWorkload = false
demoCtx.Localities = nil
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ func checkDemoConfiguration(
cmd *cobra.Command, gen workload.Generator,
) (workload.Generator, error) {
f := cliflagcfg.FlagSetForCmd(cmd)
if gen == nil && !demoCtx.NoExampleDatabase {
if gen == nil && !demoCtx.UseEmptyDatabase {
// Use a default dataset unless prevented by --no-example-database.
gen = defaultGenerator
}

// Make sure that the user didn't request a workload and an empty database.
if demoCtx.RunWorkload && demoCtx.NoExampleDatabase {
if demoCtx.RunWorkload && demoCtx.UseEmptyDatabase {
return nil, errors.New("cannot run a workload when generation of the example database is disabled")
}

Expand Down Expand Up @@ -151,7 +151,7 @@ func checkDemoConfiguration(
}

// Make sure that the user didn't request to have a topology and disable the example database.
if demoCtx.NoExampleDatabase {
if demoCtx.UseEmptyDatabase {
return nil, errors.New("cannot setup geo-partitioned replicas topology without generating an example database")
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/democluster/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ type Context struct {
// CacheSize is the size of the storage cache for each KV server.
CacheSize int64

// NoExampleDatabase prevents the auto-creation of a demo database
// UseEmptyDatabase prevents the auto-creation of a demo database
// from a workload.
NoExampleDatabase bool
UseEmptyDatabase bool

// RunWorkload indicates whether to run a workload in the background
// after the demo cluster has been initialized.
Expand Down
57 changes: 21 additions & 36 deletions pkg/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"strings"

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/build"
"github.com/cockroachdb/cockroach/pkg/cli/clientflags"
"github.com/cockroachdb/cockroach/pkg/cli/clienturl"
"github.com/cockroachdb/cockroach/pkg/cli/cliflagcfg"
Expand Down Expand Up @@ -327,41 +326,28 @@ func init() {
cliflagcfg.VarFlag(pf, &fileContentsValue{settableString: &cliCtx.logConfigInput, fileName: "<unset>"}, cliflags.LogConfigFile)
cliflagcfg.StringSliceFlag(pf, &cliCtx.logConfigVars, cliflags.LogConfigVars)

// Pre-v21.1 overrides. Deprecated.
// TODO(knz): Remove this.
cliflagcfg.VarFlag(pf, &cliCtx.deprecatedLogOverrides.stderrThreshold, cliflags.DeprecatedStderrThreshold)
_ = pf.MarkDeprecated(cliflags.DeprecatedStderrThreshold.Name,
"use --"+cliflags.Log.Name+" instead to specify 'sinks: {stderr: {filter: ...}}'.")
// Discrete convenience overrides.
cliflagcfg.VarFlag(pf, &cliCtx.logOverrides.stderrThreshold, cliflags.StderrThresholdOverride)
// This flag can also be specified without an explicit argument.
pf.Lookup(cliflags.DeprecatedStderrThreshold.Name).NoOptDefVal = "DEFAULT"
pf.Lookup(cliflags.StderrThresholdOverride.Name).NoOptDefVal = "DEFAULT"

cliflagcfg.VarFlag(pf, &cliCtx.deprecatedLogOverrides.stderrNoColor, cliflags.DeprecatedStderrNoColor)
_ = pf.MarkDeprecated(cliflags.DeprecatedStderrNoColor.Name,
"use --"+cliflags.Log.Name+" instead to specify 'sinks: {stderr: {no-color: true}}'")
cliflagcfg.VarFlag(pf, &cliCtx.logOverrides.stderrNoColor, cliflags.StderrNoColorOverride)
_ = pf.MarkHidden(cliflags.StderrNoColorOverride.Name)
cliflagcfg.VarFlag(pf, &stringValue{&cliCtx.logOverrides.logDir}, cliflags.LogDirOverride)

cliflagcfg.VarFlag(pf, &stringValue{&cliCtx.deprecatedLogOverrides.logDir}, cliflags.DeprecatedLogDir)
_ = pf.MarkDeprecated(cliflags.DeprecatedLogDir.Name,
"use --"+cliflags.Log.Name+" instead to specify 'file-defaults: {dir: ...}'")
cliflagcfg.VarFlag(pf, cliCtx.logOverrides.fileMaxSizeVal, cliflags.LogFileMaxSizeOverride)
_ = pf.MarkHidden(cliflags.LogFileMaxSizeOverride.Name)

cliflagcfg.VarFlag(pf, cliCtx.deprecatedLogOverrides.fileMaxSizeVal, cliflags.DeprecatedLogFileMaxSize)
_ = pf.MarkDeprecated(cliflags.DeprecatedLogFileMaxSize.Name,
"use --"+cliflags.Log.Name+" instead to specify 'file-defaults: {max-file-size: ...}'")
cliflagcfg.VarFlag(pf, cliCtx.logOverrides.maxGroupSizeVal, cliflags.LogGroupMaxSizeOverride)
_ = pf.MarkHidden(cliflags.LogGroupMaxSizeOverride.Name)

cliflagcfg.VarFlag(pf, cliCtx.deprecatedLogOverrides.maxGroupSizeVal, cliflags.DeprecatedLogGroupMaxSize)
_ = pf.MarkDeprecated(cliflags.DeprecatedLogGroupMaxSize.Name,
"use --"+cliflags.Log.Name+" instead to specify 'file-defaults: {max-group-size: ...}'")
cliflagcfg.VarFlag(pf, &cliCtx.logOverrides.fileThreshold, cliflags.FileThresholdOverride)
_ = pf.MarkHidden(cliflags.FileThresholdOverride.Name)

cliflagcfg.VarFlag(pf, &cliCtx.deprecatedLogOverrides.fileThreshold, cliflags.DeprecatedFileThreshold)
_ = pf.MarkDeprecated(cliflags.DeprecatedFileThreshold.Name,
"use --"+cliflags.Log.Name+" instead to specify 'file-defaults: {filter: ...}'")
cliflagcfg.VarFlag(pf, &cliCtx.logOverrides.redactableLogs, cliflags.RedactableLogsOverride)

cliflagcfg.VarFlag(pf, &cliCtx.deprecatedLogOverrides.redactableLogs, cliflags.DeprecatedRedactableLogs)
_ = pf.MarkDeprecated(cliflags.DeprecatedRedactableLogs.Name,
"use --"+cliflags.Log.Name+" instead to specify 'file-defaults: {redactable: ...}")

cliflagcfg.VarFlag(pf, &stringValue{&cliCtx.deprecatedLogOverrides.sqlAuditLogDir}, cliflags.DeprecatedSQLAuditLogDir)
_ = pf.MarkDeprecated(cliflags.DeprecatedSQLAuditLogDir.Name,
"use --"+cliflags.Log.Name+" instead to specify 'sinks: {file-groups: {sql-audit: {channels: SENSITIVE_ACCESS, dir: ...}}}")
cliflagcfg.VarFlag(pf, &stringValue{&cliCtx.logOverrides.sqlAuditLogDir}, cliflags.SQLAuditLogDirOverride)
_ = pf.MarkHidden(cliflags.SQLAuditLogDirOverride.Name)
}

// Remember we are starting in the background as the `start` command will
Expand Down Expand Up @@ -800,11 +786,8 @@ func init() {
cliflagcfg.BoolFlag(f, &demoCtx.GeoPartitionedReplicas, cliflags.DemoGeoPartitionedReplicas)
cliflagcfg.VarFlag(f, &demoCtx.demoNodeSQLMemSizeValue, cliflags.DemoNodeSQLMemSize)
cliflagcfg.VarFlag(f, &demoCtx.demoNodeCacheSizeValue, cliflags.DemoNodeCacheSize)
cliflagcfg.BoolFlag(f, &demoCtx.Insecure, cliflags.ClientInsecure)
// NB: Insecure for `cockroach demo` is deprecated. See #53404.
_ = f.MarkDeprecated(cliflags.ServerInsecure.Name,
"to start a test server without any security, run start-single-node --insecure\n"+
"For details, see: "+build.MakeIssueURL(53404))
cliflagcfg.BoolFlag(f, &demoCtx.Insecure, cliflags.ClientInsecure)

cliflagcfg.BoolFlag(f, &demoCtx.disableEnterpriseFeatures, cliflags.DemoNoLicense)
cliflagcfg.BoolFlag(f, &demoCtx.DefaultEnableRangefeeds, cliflags.DemoEnableRangefeeds)
Expand All @@ -830,9 +813,11 @@ func init() {
// The --empty flag is only valid for the top level demo command,
// so we use the regular flag set.
f := demoCmd.Flags()
cliflagcfg.BoolFlag(f, &demoCtx.NoExampleDatabase, cliflags.UseEmptyDatabase)
_ = f.MarkDeprecated(cliflags.UseEmptyDatabase.Name, "use --no-example-database")
cliflagcfg.BoolFlag(f, &demoCtx.NoExampleDatabase, cliflags.NoExampleDatabase)
cliflagcfg.BoolFlag(f, &demoCtx.UseEmptyDatabase, cliflags.UseEmptyDatabase)

// --no-example-database is an old name for --empty.
cliflagcfg.BoolFlag(f, &demoCtx.UseEmptyDatabase, cliflags.NoExampleDatabase)
_ = f.MarkHidden(cliflags.NoExampleDatabase.Name)
}

// statement-diag command.
Expand Down
Loading

0 comments on commit fe683e3

Please sign in to comment.