-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: Add syntax for cluster settings #76929
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just had nits and needs tests!
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ajstorm, @ajwerner, @dt, and @RaduBerinde)
pkg/sql/set_cluster_setting.go, line 178 at r1 (raw file):
if n.tenantID.IsSet() || n.tenantAll { return errors.UnimplementedError(
nit: use unimplemented.NewWithIssue
pkg/sql/show_cluster_setting.go, line 122 at r1 (raw file):
) (planNode, error) { if n.TenantID.IsSet() { return nil, errors.UnimplementedError(
nit: use unimplemented.NewWithIssue
pkg/sql/delegate/show_all_cluster_settings.go, line 26 at r1 (raw file):
) (tree.Statement, error) { if stmt.TenantID.IsSet() { return nil, errors.UnimplementedError(
nit: use unimplemented.NewWithIssue
pkg/sql/sem/tree/set.go, line 81 at r1 (raw file):
// Format implements the NodeFormatter interface. func (node *SetClusterSetting) Format(ctx *FmtCtx) {
we should test this formatting logic as well. could you add test cases to pkg/sql/parser/testdata/show
and pkg/sql/parser/testdata/set
(or a new test file if you like)
4fb5bc5
to
d6ac859
Compare
ac18423
to
e2d0312
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Rafi.
I've addressed your comments, but you might want to have another full look. I reworked things considerably due to @RaduBerinde's suggestion that we create a new tree node for alter tenant.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner, @dt, @RaduBerinde, and @rafiss)
pkg/sql/sem/tree/set.go, line 81 at r1 (raw file):
Previously, rafiss (Rafi Shamim) wrote…
we should test this formatting logic as well. could you add test cases to
pkg/sql/parser/testdata/show
andpkg/sql/parser/testdata/set
(or a new test file if you like)
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good overall! just one comment on the formatting
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ajstorm, @ajwerner, @dt, @RaduBerinde, and @rafiss)
pkg/sql/sem/tree/alter_tenant.go, line 33 at r2 (raw file):
ctx.WriteString("ALTER TENANT ALL ") } else if node.TenantID.IsSet() { s := fmt.Sprintf("ALTER TENANT %d ", node.TenantID.ToUint64())
i don't think we should make the TenantID skip the FmtCtx flags (unless there's a specific reason?)
so we'd want:
ctx.WriteString("ALTER TENANT ")
ctx.FormatNode(node.TenantID)
ctx.WriteString(" ")
(same goes for SHOW formatting)
pkg/sql/parser/testdata/alter_tenant, line 6 at r2 (raw file):
ALTER TENANT 1 SET CLUSTER SETTING a = 3 ALTER TENANT 1 SET CLUSTER SETTING a = (3) -- fully parenthesized ALTER TENANT 1 SET CLUSTER SETTING a = _ -- literals removed
i would expect the 1
to be removed in the "literals removed" step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ajstorm, @ajwerner, @dt, @RaduBerinde, and @rafiss)
pkg/sql/sem/tree/alter_tenant.go, line 33 at r2 (raw file):
Previously, rafiss (Rafi Shamim) wrote…
i don't think we should make the TenantID skip the FmtCtx flags (unless there's a specific reason?)
so we'd want:
ctx.WriteString("ALTER TENANT ") ctx.FormatNode(node.TenantID) ctx.WriteString(" ")
(same goes for SHOW formatting)
I was thinking that the tenant ID would never contain PII, but could be useful in debugging in all cases? Is this the proper justification for having it skip the flags?
It's a good intuition, but our formatting logic has two separate notions:
|
e2d0312
to
5e6c2cf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner, @dt, @RaduBerinde, and @rafiss)
pkg/sql/sem/tree/alter_tenant.go, line 33 at r2 (raw file):
Previously, ajstorm (Adam Storm) wrote…
I was thinking that the tenant ID would never contain PII, but could be useful in debugging in all cases? Is this the proper justification for having it skip the flags?
As mentioned on Slack, I'm going to leave this as-is for now, pending the broader investigation as to what to do here.
pkg/sql/parser/testdata/alter_tenant, line 6 at r2 (raw file):
Previously, rafiss (Rafi Shamim) wrote…
i would expect the
1
to be removed in the "literals removed" step.
Does this key off of the Format function? If so I think we're stuck with showing this literal pending the investigation mentioned above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to hold off on that change to the TenantID formatting. This should be RFAL now.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner, @dt, @RaduBerinde, and @rafiss)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ajstorm, @ajwerner, @dt, @RaduBerinde, and @rafiss)
pkg/sql/parser/testdata/alter_tenant, line 6 at r2 (raw file):
Previously, ajstorm (Adam Storm) wrote…
Does this key off of the Format function? If so I think we're stuck with showing this literal pending the investigation mentioned above.
yeah, this is the result of formatting with FmtHideConstants
. we can address it during the stability period
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @ajstorm, @ajwerner, @dt, and @rafiss)
pkg/sql/alter_tenant.go, line 60 at r3 (raw file):
} if setting.Class() == settings.SystemOnly && !p.execCfg.Codec.ForSystemTenant() {
Here we need to error out if it is a SystemOnly setting. For all others, we need to check ForSystemTenant()
and only allow that (I think that should be the first thing to check - this is a "system/operator only" statement).
5e6c2cf
to
867042b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @ajstorm, @ajwerner, @dt, @RaduBerinde, and @rafiss)
pkg/sql/alter_tenant.go, line 60 at r3 (raw file):
Previously, RaduBerinde wrote…
Here we need to error out if it is a SystemOnly setting. For all others, we need to check
ForSystemTenant()
and only allow that (I think that should be the first thing to check - this is a "system/operator only" statement).
@RaduBerinde I don't think I fully appreciated how we should error out here from a first read of the RFC. I took another crack at this logic based on your comments and I think I've got it right now. PTAL (assuming you're still checking email) and let me know what you think.
c9983f7
to
3975247
Compare
3975247
to
30eb035
Compare
5ddcb3b
to
382c4da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @ajstorm, @ajwerner, @dt, @RaduBerinde, and @rafiss)
pkg/sql/alter_tenant.go, line 67 at r5 (raw file):
"%s is a system-only setting and must be set using SET CLUSTER SETTING", name) } if !p.execCfg.Codec.ForSystemTenant() && setting.Class() != settings.TenantWritable {
This should just be `if !ForSystemTenant() and I'd move it to be the first check.
ALTER TENANT should only be runnable by the system tenant. Non-system tenants can only use SET CLUSTER SETTING
to change their settings. ALTER TENANT
is only about operator-set overrides. It's very similar to calling crdb_internal.create_tenant()
from the standpoint of who can run it.
638fe16
to
c130708
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @ajstorm, @ajwerner, @dt, @RaduBerinde, and @rafiss)
pkg/sql/alter_tenant.go, line 67 at r5 (raw file):
Previously, RaduBerinde wrote…
This should just be `if !ForSystemTenant() and I'd move it to be the first check.
ALTER TENANT should only be runnable by the system tenant. Non-system tenants can only use
SET CLUSTER SETTING
to change their settings.ALTER TENANT
is only about operator-set overrides. It's very similar to callingcrdb_internal.create_tenant()
from the standpoint of who can run it.
Done.
Before this commit, there was no syntax to SET or SHOW cluster settings which exist for a given tenant. This commit adds the following syntax: * ALTER TENANT <id> SET CLUSTER SETTING <setting> = <value> * ALTER TENANT ALL SET CLUSTER SETTING <setting> = <value> * ALTER TENANT <id> RESET CLUSTER SETTING <setting> * ALTER TENANT ALL RESET CLUSTER SETTING <setting> * SHOW CLUSTER SETTING <setting> FOR TENANT <id> * SHOW [ALL] CLUSTER SETTINGS FOR TENANT <id> Note that the syntax is added but the underlying commands are currently unimplemented. The implementation of these commands will come with a subsequent commit. Release note (sql change): Added syntax for modifying cluster settings at the tenant level. Release justification: Completion of feature for 22.1.
c130708
to
89091fe
Compare
TFTR! bors r=raduberinde,rafiss |
Build failed (retrying...): |
Build succeeded: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 0 LGTMs obtained
Before this commit, there was no syntax to SET or SHOW cluster settings which
exist for a given tenant. This commit adds the following syntax:
Note that the syntax is added but the underlying commands are currently
unimplemented. The implementation of these commands will come with a subsequent
commit.
Release note (sql change): Added syntax for modifying cluster settings at the
tenant level.
Informs: #73857.