Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

settings: rename and better document the setting classes #111378

Merged
merged 1 commit into from
Sep 29, 2023

Conversation

knz
Copy link
Contributor

@knz knz commented Sep 27, 2023

All commits except the last are from #110758.
Epic: CRDB-6671
Informs #58445.

TLDR: "TenantReadOnly" -> "SystemVisible"; "TenantWritable" -> "ApplicationLevel".

Review guidance: the only manual change is in pkg/settings/setting.go. Everything else was automated
search-replace.

See the new/extended explanatory comments in pkg/settings/setting.go for details.

// Class describes the scope of a setting under cluster
// virtualization.
//
// Guidelines for choosing a class:
//
//   - Make sure to read the descriptions below carefully to
//     understand the differences in semantics.
//
//   - Rules of thumb:
//
//     1. if an end-user should be able to modify the setting in
//     CockroachCloud Serverless, AND different end-users should be
//     able to use different values, the setting should have class
//     ApplicationLevel.
//
//     2. if a setting should only be controlled by SREs in
//     CockroachCloud Serverless, OR a single value must apply to
//     multiple tenants (virtual clusters) simultaneously, the setting
//     must not use class ApplicationLevel.
//
//     3. if and only if a setting relevant to the KV/storage layer
//     and whose value is shared across all virtual cluster is ever
//     accessed by code in the application layer (SQL execution or
//     HTTP handlers), use SystemVisible.
//
//     4. in other cases, use SystemOnly.
type Class int8

const (
  // SystemOnly settings are specific to the KV/storage layer and
  // cannot be accessed from application layer code (in particular not
  // from SQL layer nor HTTP handlers).
  //
  // As a rule of thumb, use this class if:
  //
  //   - the setting may be accessed from the shared KV/storage layer;
  //
  //   - AND, the setting should only be controllable by SREs (not
  //     end-users) in CockroachCloud Serverless, AND a single value
  //     must apply to all virtual clusters simultaneously;
  //
  //     (If this part of the condition does not hold, consider
  //     ApplicationLevel instead.)
  //
  //   - AND, its value is never needed in the application layer (i.e.
  //     it is not read from SQL code, HTTP handlers or other code
  //     that would run in SQL pods in CC Serverless).
  //
  //     (If this part of the condition does not hold, consider
  //     SystemVisible instead.)
  SystemOnly Class = iota

  // SystemVisible settings are specific to the KV/storage layer and
  // are also visible to virtual clusters.
  //
  // As a rule of thumb, use this class if:
  //
  //   - the setting may be accessed from the shared KV/storage layer;
  //
  //   - AND the setting should only be controllable by SREs (not
  //     end-users) in CockroachCloud Serverless, AND a single value
  //     must apply to all virtual clusters simultaneously;
  //
  //     (If this part of the condition does not hold, consider
  //     ApplicationLevel instead.)
  //
  //   - AND, its value is sometimes needed in the application layer
  //     (i.e. it may be read from SQL code, HTTP handlers or other
  //     code that could run in SQL pods in CC Serverless).
  //
  //     (If this part of the condition does not hold, consider
  //     SystemOnly instead.)
  SystemVisible

  // ApplicationLevel settings are readable and can optionally be
  // modified by virtual clusters.
  //
  // As a rule of thumb, use this class if:
  //
  //   - the setting is never accessed by the shared KV/storage layer;
  //
  //   - AND, any of the following holds:
  //
  //     - end-users should legitimately be able to modify
  //       the setting in CockroachCloud Serverless;
  //
  //       (If this part of the condition does not hold, but the other
  //       part of the condition below does hold, consider still using
  //       ApplicationLevel and force an override using ALTER VIRTUAL
  //       CLUSTER SET CLUSTER SETTING. This makes the
  //       ApplicationLevel setting effectively read-only from the
  //       virtual cluster's perspective, because system overrides
  //       cannot be modified by the virtual cluster.)
  //
  //     - OR, different virtual clusters should be able to
  //       use different values for the setting.
  //
  //       (If this part of the condition does not hold, consider
  //       SystemOnly or SystemVisible instead.)
  ApplicationLevel

Release note: None

@knz knz requested review from a team September 27, 2023 21:08
@knz knz requested review from a team as code owners September 27, 2023 21:08
@knz knz requested a review from a team September 27, 2023 21:08
@knz knz requested a review from a team as a code owner September 27, 2023 21:08
@knz knz requested a review from a team September 27, 2023 21:08
@knz knz requested review from a team as code owners September 27, 2023 21:08
@knz knz requested review from Santamaura, lidorcarmel, RaduBerinde, cucaroach, jayshrivastava and herkolategan and removed request for a team September 27, 2023 21:08
@knz knz requested review from dt, stevendanna and yuzefovich and removed request for herkolategan and smg260 September 27, 2023 21:15
@mdlinville
Copy link
Contributor

Release note (cluster virtualization): Cluster settings are now grouped into 3 classes with clearer descriptions:

  • "system only" for settings only accessible to the shared KV/storage
    layer and thus only available to the operator.
  • "system visible" for storage-level settings that can be viewed from
    virtual clusters.
  • "application level" for settings that can be viewed from virtual
    clusters, may be different between virtual clusters, or can be
    customized by end-users.

Looks like the actual labels are SystemOnly, SystemVisible, and ApplicationLevel, right? (with that spacing and casing)

@knz
Copy link
Contributor Author

knz commented Sep 27, 2023

Looks like the actual labels are SystemOnly, SystemVisible, and ApplicationLevel, right? (with that spacing and casing)

These labels are internal to the source code and not user-facing, which is why they are not mentioned in the release note. Only the (auto-generated) table with settings will mention the classes, and the doc writer can choose which labels to use to generate the table (using the --class-labels parameter to cockroach gen setting-list).

//
// - SystemOnly should be used with caution: even internal tenant code is
// disallowed from using these settings at all.
// 3. if a non-ApplicationLevel setting is ever accessed by
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: You might want to word this as "if and only if" to avoid splitting the "if" and "only then" part between so many words. Additionally, you may want to split the last sentence out to its own bullet, as it's a pretty important point that's somewhat buried right now. Finally instead of "non-ApplicationLevel", can we say "System-level"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to word this as "if and only if" to avoid splitting the "if" and "only then" part between so many words.

Done.

you may want to split the last sentence out to its own bullet

Done.

Finally instead of "non-ApplicationLevel", can we say "System-level"?

I think we should include both. The 3 points so far only mentioned ApplicationLevel, so I believe the text here should refer to it primarily.

@knz knz force-pushed the 20230927-setting-classes branch 2 times, most recently from a7f368e to 2180082 Compare September 29, 2023 08:26
@knz knz force-pushed the 20230927-setting-classes branch from 2180082 to a7c5cf2 Compare September 29, 2023 14:58
Copy link
Collaborator

@stevendanna stevendanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I think this is moving us in the right direction. Just one small suggestion.

Comment on lines +214 to +218
// - OR, different virtual clusters should be able to
// use different values for the setting.
//
// (If this part of the condition does not hold, consider
// SystemOnly or SystemVisible instead.)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should provide some more guidance here. Namely, most settings should be ApplicationLevel if they aren't in the KV/storage layer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines +179 to +181
// - AND the setting should only be controllable by SREs (not
// end-users) in CockroachCloud Serverless, AND a single value
// must apply to all virtual clusters simultaneously;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have some settings like those in the tenantcostclient that sort of violate this as written. In the current documentation, it looks like we should have made those ApplicationLevel and CC should have set an override.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very astute observation. I am very keen to have that convo with the CC team. But I feel that this convo will only be productive after we settle on the guidance.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I don't think we should rely on external process to set those overrides though - we could set them ourselves by default (in a permanent upgrade).

@knz knz force-pushed the 20230927-setting-classes branch 2 times, most recently from c736aef to f0de329 Compare September 29, 2023 17:41
// cannot be accessed from application layer code (in particular not
// from SQL layer nor HTTP handlers).
//
// As a rule of thumb, this class should be rarely used. We expect
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should it be rarely used? It seems that all the settings related to KV and below (all the way down to Pebble settings) belong here, of which there are many.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok i'll soften that up.

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the new naming and guidance, nicely done!

@knz knz force-pushed the 20230927-setting-classes branch from f0de329 to ca52744 Compare September 29, 2023 21:28
**TLDR: "TenantReadOnly" -> "SystemVisible"; "TenantWritable" ->
"ApplicationLevel".**

See the new/extended explanatory comments in `pkg/settings/setting.go`
for details.

Review guidance: the only manual change is in
`pkg/settings/setting.go`. Everything else was automated
search-replace.

No release note because the classes are not user-visible.

Release note: None
@knz knz force-pushed the 20230927-setting-classes branch from ca52744 to e9a6d3d Compare September 29, 2023 21:30
@knz
Copy link
Contributor Author

knz commented Sep 29, 2023

bors r=ajstorm,stevendanna,dt,RaduBerinde

@craig
Copy link
Contributor

craig bot commented Sep 29, 2023

Build succeeded:

@craig craig bot merged commit bd27772 into cockroachdb:master Sep 29, 2023
3 checks passed
@knz knz deleted the 20230927-setting-classes branch September 29, 2023 22:48
@erikgrinaker
Copy link
Contributor

Thanks for the cleanup and improvements here!

ApplicationLevel settings are readable and can optionally be modified by virtual clusters.

Consider pointing out that virtual clusters never see the system setting, these are entirely independent per tenant.

AND a single value must apply to all virtual clusters simultaneously

Consider pointing out that it is still possible for the operator to set per-tenant values for a setting.

@knz
Copy link
Contributor Author

knz commented Oct 2, 2023

thanks for the extra feedback, let's discuss first.

craig bot pushed a commit that referenced this pull request Oct 2, 2023
111338: storage: strengthen time-bound iteration guarantees r=sumeerbhola a=jbowens

Previously, the minimum and maximum timestamps used to configure a "time-bound" iterator were only hints. The iterator would surface keys outside those bounds frequently if the keys were contained within a sstable block that also contained keys within bounds. This commit adapts the iterator construction to use Pebble's IterOptions.SkipPoint option to filter out-of-range keys without yielding them to the caller.

This adds a small additional overhead to processing KVs that are ultimately yielded to the user of a MVCCIncrementalIterator, but removes a large overhead to proessing KVs that are ultimately skipped. In the current MVCCIncrementalIterator implementation, keys that are outside the time range still reposition the iterator without time bounds. This repositioning no longer happens, and removing this overhead more than reclaims the RefreshRange benchmark's regression from value blocks packing keys more densely.

This also serves as a step towards #66869.

```
goos: linux
goarch: amd64
cpu: Intel(R) Xeon(R) CPU @ 2.80GHz
                                                         │    old.txt    │               new.txt               │
                                                         │    sec/op     │   sec/op     vs base                │
RefreshRange/linear-keys/refresh_window=[0.00,0.00]-24      150.73µ ± 1%   55.75µ ± 1%  -63.01% (p=0.000 n=10)
RefreshRange/linear-keys/refresh_window=[0.00,50.00]-24      16.52µ ± 1%   16.19µ ± 2%   -2.00% (p=0.005 n=10)
RefreshRange/linear-keys/refresh_window=[0.00,75.00]-24      13.94µ ± 1%   13.59µ ± 1%   -2.55% (p=0.000 n=10)
RefreshRange/linear-keys/refresh_window=[0.00,95.00]-24      13.97µ ± 1%   13.56µ ± 3%   -2.99% (p=0.002 n=10)
RefreshRange/linear-keys/refresh_window=[0.00,99.00]-24      13.96µ ± 1%   13.45µ ± 3%   -3.69% (p=0.000 n=10)
RefreshRange/linear-keys/refresh_window=[50.00,50.00]-24    149.95µ ± 1%   55.67µ ± 1%  -62.88% (p=0.000 n=10)
RefreshRange/linear-keys/refresh_window=[50.00,75.00]-24     22.05µ ± 1%   21.70µ ± 0%   -1.57% (p=0.000 n=10)
RefreshRange/linear-keys/refresh_window=[50.00,95.00]-24     22.08µ ± 1%   21.61µ ± 0%   -2.14% (p=0.000 n=10)
RefreshRange/linear-keys/refresh_window=[50.00,99.00]-24     21.91µ ± 1%   21.69µ ± 1%   -0.99% (p=0.000 n=10)
RefreshRange/linear-keys/refresh_window=[75.00,75.00]-24    139.27µ ± 1%   55.82µ ± 1%  -59.92% (p=0.000 n=10)
RefreshRange/linear-keys/refresh_window=[75.00,95.00]-24     23.76µ ± 1%   23.36µ ± 0%   -1.66% (p=0.000 n=10)
RefreshRange/linear-keys/refresh_window=[75.00,99.00]-24     23.85µ ± 1%   23.25µ ± 1%   -2.48% (p=0.000 n=10)
RefreshRange/linear-keys/refresh_window=[95.00,95.00]-24    138.94µ ± 1%   55.52µ ± 0%  -60.04% (p=0.000 n=10)
RefreshRange/linear-keys/refresh_window=[95.00,99.00]-24     26.68µ ± 1%   26.30µ ± 1%   -1.42% (p=0.005 n=10)
RefreshRange/linear-keys/refresh_window=[99.00,99.00]-24    141.39µ ± 1%   55.02µ ± 1%  -61.09% (p=0.000 n=10)
RefreshRange/random-keys/refresh_window=[0.00,0.00]-24      322.35µ ± 0%   51.21µ ± 0%  -84.11% (p=0.000 n=10)
RefreshRange/random-keys/refresh_window=[0.00,50.00]-24      16.35µ ± 1%   16.63µ ± 2%        ~ (p=0.105 n=10)
RefreshRange/random-keys/refresh_window=[0.00,75.00]-24      17.42µ ± 1%   17.29µ ± 3%        ~ (p=0.796 n=10)
RefreshRange/random-keys/refresh_window=[0.00,95.00]-24      13.40µ ± 1%   13.45µ ± 1%        ~ (p=0.529 n=10)
RefreshRange/random-keys/refresh_window=[0.00,99.00]-24      13.59µ ± 2%   13.41µ ± 0%        ~ (p=0.239 n=10)
RefreshRange/random-keys/refresh_window=[50.00,50.00]-24     707.5m ± 1%   111.7m ± 1%  -84.21% (p=0.000 n=10)
RefreshRange/random-keys/refresh_window=[50.00,75.00]-24     21.94µ ± 1%   17.86µ ± 0%  -18.59% (p=0.000 n=10)
RefreshRange/random-keys/refresh_window=[50.00,95.00]-24     13.95µ ± 1%   13.54µ ± 1%   -2.94% (p=0.000 n=10)
RefreshRange/random-keys/refresh_window=[50.00,99.00]-24     13.96µ ± 0%   13.53µ ± 1%   -3.06% (p=0.000 n=10)
RefreshRange/random-keys/refresh_window=[75.00,75.00]-24    395.22m ± 0%   33.81m ± 1%  -91.45% (p=0.000 n=10)
RefreshRange/random-keys/refresh_window=[75.00,95.00]-24     19.42µ ± 1%   19.40µ ± 1%        ~ (p=0.912 n=10)
RefreshRange/random-keys/refresh_window=[75.00,99.00]-24     19.37µ ± 1%   19.42µ ± 1%        ~ (p=0.247 n=10)
RefreshRange/random-keys/refresh_window=[95.00,95.00]-24    546.66m ± 3%   48.48m ± 3%  -91.13% (p=0.000 n=10)
RefreshRange/random-keys/refresh_window=[95.00,99.00]-24     21.69µ ± 1%   19.68µ ± 1%   -9.24% (p=0.000 n=10)
RefreshRange/random-keys/refresh_window=[99.00,99.00]-24    546.27m ± 0%   48.73m ± 3%  -91.08% (p=0.000 n=10)
RefreshRange/mixed-case/refresh_window=[0.00,0.00]-24        410.1µ ± 0%   221.1µ ± 1%  -46.09% (p=0.000 n=10)
RefreshRange/mixed-case/refresh_window=[0.00,50.00]-24       14.84µ ± 1%   14.84µ ± 1%        ~ (p=0.739 n=10)
RefreshRange/mixed-case/refresh_window=[0.00,75.00]-24       14.84µ ± 1%   14.83µ ± 1%        ~ (p=0.615 n=10)
RefreshRange/mixed-case/refresh_window=[0.00,95.00]-24       17.39µ ± 2%   17.51µ ± 2%   +0.68% (p=0.029 n=10)
RefreshRange/mixed-case/refresh_window=[0.00,99.00]-24       16.41µ ± 1%   16.38µ ± 1%        ~ (p=0.971 n=10)
RefreshRange/mixed-case/refresh_window=[50.00,50.00]-24      660.9m ± 0%   140.6m ± 3%  -78.73% (p=0.000 n=10)
RefreshRange/mixed-case/refresh_window=[50.00,75.00]-24      20.43µ ± 1%   15.46µ ± 1%  -24.31% (p=0.000 n=10)
RefreshRange/mixed-case/refresh_window=[50.00,95.00]-24      18.03µ ± 1%   17.66µ ± 1%   -2.01% (p=0.000 n=10)
RefreshRange/mixed-case/refresh_window=[50.00,99.00]-24      16.86µ ± 1%   16.70µ ± 1%   -0.93% (p=0.011 n=10)
RefreshRange/mixed-case/refresh_window=[75.00,75.00]-24      659.5m ± 1%   137.1m ± 3%  -79.21% (p=0.000 n=10)
RefreshRange/mixed-case/refresh_window=[75.00,95.00]-24      17.96µ ± 1%   17.65µ ± 1%   -1.77% (p=0.000 n=10)
RefreshRange/mixed-case/refresh_window=[75.00,99.00]-24      16.86µ ± 1%   16.66µ ± 1%   -1.23% (p=0.008 n=10)
RefreshRange/mixed-case/refresh_window=[95.00,95.00]-24     900.95µ ± 0%   32.18µ ± 0%  -96.43% (p=0.000 n=10)
RefreshRange/mixed-case/refresh_window=[95.00,99.00]-24      14.35µ ± 1%   14.50µ ± 2%   +1.03% (p=0.002 n=10)
RefreshRange/mixed-case/refresh_window=[99.00,99.00]-24    227.235m ± 1%   3.361m ± 1%  -98.52% (p=0.000 n=10)
geomean                                                      136.9µ        73.57µ       -46.24%

goos: linux
goarch: amd64
cpu: Intel(R) Xeon(R) CPU @ 2.80GHz
                                                    │  old2.txt   │              new2.txt               │
                                                    │   sec/op    │   sec/op     vs base                │
MVCCIncrementalIterator/ts=5-24                       24.93m ± 3%   24.53m ± 2%   -1.61% (p=0.004 n=10)
MVCCIncrementalIterator/ts=480-24                     560.4µ ± 1%   453.8µ ± 0%  -19.02% (p=0.000 n=10)
MVCCIncrementalIteratorForOldData/valueSize=100-24    1.444m ± 0%   1.434m ± 0%   -0.72% (p=0.000 n=10)
MVCCIncrementalIteratorForOldData/valueSize=500-24    1.994m ± 0%   1.974m ± 1%   -1.02% (p=0.000 n=10)
MVCCIncrementalIteratorForOldData/valueSize=1000-24   2.672m ± 1%   2.649m ± 1%        ~ (p=0.063 n=10)
MVCCIncrementalIteratorForOldData/valueSize=2000-24   4.059m ± 1%   4.009m ± 1%   -1.23% (p=0.011 n=10)
geomean                                               2.754m        2.635m        -4.33%
```

Epic: none
Informs #66869
Close #98881
Release note: none

111566: cli/sql: better report the virtual cluster name in the prompt r=stevendanna a=knz

First commit from #111565.
Fixes #111491.
Epic: CRDB-26691

Prior to this patch, the SQL shell was reporting the name of the
virtual cluster using the `cluster:` option in the connection URL.
This was brittle, as it didn't handle the case where the SQL
connection was routed to a virtual cluster implicitly via the cluster
setting `server.controller.default_target_cluster`.

This commit makes the display more robust by having the server report
the virtual cluster name via the `node_build_info` virtual table,
alongside the cluster ID and organization which were already
communicated in this way.

(No release note because this is new functionality in 23.2)

111579: settings: tweak the comment guidance r=erikgrinaker a=knz

Epic: CRDB-6671

As suggested by `@erikgrinaker` [here](#111378 (comment)) and discussed [here](https://cockroachlabs.slack.com/archives/C05N2J8ACQH/p1696255584272959).

Release note: None

Co-authored-by: Jackson Owens <[email protected]>
Co-authored-by: Raphael 'kena' Poss <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants