Skip to content

Commit bfb43f5

Browse files
craig[bot]Dedej-Bergintbgwenyihu6mw5h
committed
147996: sql: add security_invoker feature flag and grammar support r=Dedej-Bergin a=Dedej-Bergin This change adds the `enable_view_security_invoker` feature flag. It also adds grammar support for the following two statements: ``` CREATE VIEW <view_name> WITH ( security_invoker = true ) AS SELECT * FROM <table_name>; ALTER VIEW <view_name> SET ( security_invoker = false ); ``` Informs: #138918 Epic: CRDB-48807 Release note: None 149757: asim,roachpb: follow-up to #149699 r=wenyihu6 a=tbg - **tests: add missing RaftCPUPerWrite** - **roachpb: rm a test** - **roachpb: improve a comment** - **asim: include WriteBytesPerSecond in StoreMetrics** - **asim: fix argument passing in BasicLoad.Generate** Epic: CRDB-25222 149767: util: add envAlwaysKeepTestLogsEnabled r=rickystewart a=wenyihu6 This commit adds support for a new environment variable, COCKROACH_ALWAYS_KEEP_TEST_LOGS, which ensures that crdb and test logs are kept even when tests fail. Example usage: ``` ./dev test .... -- --test_env=COCKROACH_ALWAYS_KEEP_TEST_LOGS=true ``` Epic: none Release note: none 149848: sql: default sql.stats.error_on_concurrent_create_stats.enabled to false r=mw5h a=mw5h 'sql.stats.error_on_concurrent_create_stats.enabled' was introduced with a default value of true to ease backporting. Going forward, we want this to default to false so that customers are not alarmed by error counters increasing. Informs: #148413 Release note (ops change): The value of sql.stats.error_on_concurrent_create_stats.enabled now defaults to false, supressing error counters for auto stats jobs that fail due to concurrent stats jobs in progress. Co-authored-by: Bergin Dedej <[email protected]> Co-authored-by: Tobias Grieger <[email protected]> Co-authored-by: wenyihu6 <[email protected]> Co-authored-by: Matt White <[email protected]>
5 parents 9dd8ce2 + 0e4a13d + 617dbf8 + e05dbbb + 0cb5664 commit bfb43f5

File tree

21 files changed

+311
-97
lines changed

21 files changed

+311
-97
lines changed

docs/generated/settings/settings-for-tenants.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ sql.stats.automatic_partial_collection.fraction_stale_rows float 0.05 target fra
356356
sql.stats.automatic_partial_collection.min_stale_rows integer 100 target minimum number of stale rows per table that will trigger a partial statistics refresh application
357357
sql.stats.cleanup.recurrence string @hourly cron-tab recurrence for SQL Stats cleanup job application
358358
sql.stats.detailed_latency_metrics.enabled boolean false label latency metrics with the statement fingerprint. Workloads with tens of thousands of distinct query fingerprints should leave this setting false. (experimental, affects performance for workloads with high fingerprint cardinality) application
359-
sql.stats.error_on_concurrent_create_stats.enabled boolean true set to true to error on concurrent CREATE STATISTICS jobs, instead of skipping them application
359+
sql.stats.error_on_concurrent_create_stats.enabled boolean false set to true to error on concurrent CREATE STATISTICS jobs, instead of skipping them application
360360
sql.stats.flush.enabled boolean true if set, SQL execution statistics are periodically flushed to disk application
361361
sql.stats.flush.interval duration 10m0s the interval at which SQL execution statistics are flushed to disk, this value must be less than or equal to 1 hour application
362362
sql.stats.forecasts.enabled boolean true when true, enables generation of statistics forecasts by default for all tables application

docs/generated/settings/settings.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@
311311
<tr><td><div id="setting-sql-stats-automatic-partial-collection-min-stale-rows" class="anchored"><code>sql.stats.automatic_partial_collection.min_stale_rows</code></div></td><td>integer</td><td><code>100</code></td><td>target minimum number of stale rows per table that will trigger a partial statistics refresh</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
312312
<tr><td><div id="setting-sql-stats-cleanup-recurrence" class="anchored"><code>sql.stats.cleanup.recurrence</code></div></td><td>string</td><td><code>@hourly</code></td><td>cron-tab recurrence for SQL Stats cleanup job</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
313313
<tr><td><div id="setting-sql-stats-detailed-latency-metrics-enabled" class="anchored"><code>sql.stats.detailed_latency_metrics.enabled</code></div></td><td>boolean</td><td><code>false</code></td><td>label latency metrics with the statement fingerprint. Workloads with tens of thousands of distinct query fingerprints should leave this setting false. (experimental, affects performance for workloads with high fingerprint cardinality)</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
314-
<tr><td><div id="setting-sql-stats-error-on-concurrent-create-stats-enabled" class="anchored"><code>sql.stats.error_on_concurrent_create_stats.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>set to true to error on concurrent CREATE STATISTICS jobs, instead of skipping them</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
314+
<tr><td><div id="setting-sql-stats-error-on-concurrent-create-stats-enabled" class="anchored"><code>sql.stats.error_on_concurrent_create_stats.enabled</code></div></td><td>boolean</td><td><code>false</code></td><td>set to true to error on concurrent CREATE STATISTICS jobs, instead of skipping them</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
315315
<tr><td><div id="setting-sql-stats-flush-enabled" class="anchored"><code>sql.stats.flush.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>if set, SQL execution statistics are periodically flushed to disk</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
316316
<tr><td><div id="setting-sql-stats-flush-interval" class="anchored"><code>sql.stats.flush.interval</code></div></td><td>duration</td><td><code>10m0s</code></td><td>the interval at which SQL execution statistics are flushed to disk, this value must be less than or equal to 1 hour</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
317317
<tr><td><div id="setting-sql-stats-forecasts-enabled" class="anchored"><code>sql.stats.forecasts.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>when true, enables generation of statistics forecasts by default for all tables</td><td>Serverless/Dedicated/Self-Hosted</td></tr>

docs/generated/sql/bnf/stmt_block.bnf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,7 @@ unreserved_keyword ::=
14591459
| 'SEARCH'
14601460
| 'SECOND'
14611461
| 'SECURITY'
1462+
| 'SECURITY_INVOKER'
14621463
| 'SECONDARY'
14631464
| 'SERIALIZABLE'
14641465
| 'SEQUENCE'
@@ -4385,6 +4386,7 @@ bare_label_keywords ::=
43854386
| 'SEARCH'
43864387
| 'SECONDARY'
43874388
| 'SECURITY'
4389+
| 'SECURITY_INVOKER'
43884390
| 'SELECT'
43894391
| 'SEQUENCE'
43904392
| 'SEQUENCES'

pkg/kv/kvserver/asim/gen/generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ func (bl BasicLoad) Generate(seed int64, settings *config.SimulationSettings) []
165165
bl.RWRatio,
166166
bl.MaxBlockSize,
167167
bl.MinBlockSize,
168-
bl.RaftCPUPerWrite,
169168
bl.RequestCPUPerAccess,
169+
bl.RaftCPUPerWrite,
170170
),
171171
}
172172
}

pkg/kv/kvserver/asim/metrics/tracker.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -141,22 +141,23 @@ func (mt *Tracker) Tick(ctx context.Context, tick time.Time, s state.State) {
141141
desc := store.Descriptor()
142142

143143
sm := StoreMetrics{
144-
Tick: tick,
145-
StoreID: int64(storeID),
146-
QPS: int64(desc.Capacity.QueriesPerSecond),
147-
CPU: int64(desc.Capacity.CPUPerSecond),
148-
WriteKeys: u.WriteKeys,
149-
WriteBytes: u.WriteBytes,
150-
ReadKeys: u.ReadKeys,
151-
ReadBytes: u.ReadBytes,
152-
Replicas: int64(desc.Capacity.RangeCount),
153-
Leases: int64(desc.Capacity.LeaseCount),
154-
LeaseTransfers: u.LeaseTransfers,
155-
Rebalances: u.Rebalances,
156-
RebalanceSentBytes: u.RebalanceSentBytes,
157-
RebalanceRcvdBytes: u.RebalanceRcvdBytes,
158-
RangeSplits: u.RangeSplits,
159-
DiskFractionUsed: desc.Capacity.FractionUsed(),
144+
Tick: tick,
145+
StoreID: int64(storeID),
146+
QPS: int64(desc.Capacity.QueriesPerSecond),
147+
CPU: int64(desc.Capacity.CPUPerSecond),
148+
WriteKeys: u.WriteKeys,
149+
WriteBytes: u.WriteBytes,
150+
WriteBytesPerSecond: int64(desc.Capacity.WriteBytesPerSecond),
151+
ReadKeys: u.ReadKeys,
152+
ReadBytes: u.ReadBytes,
153+
Replicas: int64(desc.Capacity.RangeCount),
154+
Leases: int64(desc.Capacity.LeaseCount),
155+
LeaseTransfers: u.LeaseTransfers,
156+
Rebalances: u.Rebalances,
157+
RebalanceSentBytes: u.RebalanceSentBytes,
158+
RebalanceRcvdBytes: u.RebalanceRcvdBytes,
159+
RangeSplits: u.RangeSplits,
160+
DiskFractionUsed: desc.Capacity.FractionUsed(),
160161
}
161162
sms = append(sms, sm)
162163
}

pkg/kv/kvserver/asim/tests/default_settings.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func (f randTestingFramework) defaultLoadGen() gen.BasicLoad {
115115
MinKey: f.defaultStaticSettings.minKey,
116116
MaxKey: f.defaultStaticSettings.maxKey,
117117
RequestCPUPerAccess: f.defaultStaticSettings.requestCPUPerAccess,
118+
RaftCPUPerWrite: f.defaultStaticSettings.raftCPUPerWrite,
118119
}
119120
}
120121

pkg/roachpb/metadata.proto

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,9 @@ message NodeCapacity {
303303

304304
// NodeCPURateUsage is the node's actual CPU usage in ns/sec, measured by the
305305
// runtime load monitor tracking user+system CPU time. This is typically
306-
// higher than StoresCPURate gaps in the fine-grained instrumentation used to
307-
// compute StoresCPURate.
306+
// higher than StoresCPURate due gaps in the fine-grained instrumentation used to
307+
// compute StoresCPURate, and due to the fact that there are uses of CPU not
308+
// occurring in the context of a Store.
308309
optional int64 node_cpu_rate_usage = 3 [(gogoproto.nullable) = false, (gogoproto.customname) = "NodeCPURateUsage"];
309310

310311
// NodeCPURateCapacity is the node's total CPU capacity in nanoseconds per

pkg/roachpb/metadata_test.go

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -850,68 +850,3 @@ func TestRangeDescriptorsByStartKey(t *testing.T) {
850850
}
851851
}
852852
}
853-
854-
// TestNodeCapacity tests the NodeCapacity struct.
855-
func TestNodeCapacity(t *testing.T) {
856-
t.Run("basic", func(t *testing.T) {
857-
actual := NodeCapacity{
858-
StoresCPURate: 1,
859-
NumStores: 1,
860-
NodeCPURateUsage: 800000000,
861-
NodeCPURateCapacity: 10,
862-
}
863-
require.Equal(t, int64(1), actual.StoresCPURate)
864-
require.Equal(t, int32(1), actual.NumStores)
865-
require.Equal(t, int64(800000000), actual.NodeCPURateUsage)
866-
require.Equal(t, int64(10), actual.NodeCPURateCapacity)
867-
})
868-
869-
t.Run("zero values", func(t *testing.T) {
870-
actual := NodeCapacity{}
871-
require.Equal(t, int64(0), actual.StoresCPURate)
872-
require.Equal(t, int32(0), actual.NumStores)
873-
require.Equal(t, int64(0), actual.NodeCPURateUsage)
874-
require.Equal(t, int64(0), actual.NodeCPURateCapacity)
875-
})
876-
877-
t.Run("equality", func(t *testing.T) {
878-
nc1 := NodeCapacity{
879-
StoresCPURate: 1000000000,
880-
NumStores: 3,
881-
NodeCPURateUsage: 800000000,
882-
NodeCPURateCapacity: 1000000000,
883-
}
884-
nc2 := nc1
885-
require.Equal(t, nc1, nc2)
886-
require.Equal(t, int64(1000000000), nc2.StoresCPURate)
887-
require.Equal(t, int32(3), nc2.NumStores)
888-
require.Equal(t, int64(800000000), nc2.NodeCPURateUsage)
889-
require.Equal(t, int64(1000000000), nc2.NodeCPURateCapacity)
890-
})
891-
892-
t.Run("wrap in store descriptor", func(t *testing.T) {
893-
nc := NodeCapacity{
894-
StoresCPURate: 1000000000,
895-
NumStores: 3,
896-
NodeCPURateUsage: 800000000,
897-
NodeCPURateCapacity: 1000000000,
898-
}
899-
900-
storeDesc := StoreDescriptor{
901-
StoreID: 1,
902-
Node: NodeDescriptor{
903-
NodeID: 1,
904-
},
905-
Capacity: StoreCapacity{
906-
Capacity: 1000000000,
907-
Available: 500000000,
908-
RangeCount: 100,
909-
},
910-
NodeCapacity: nc,
911-
}
912-
require.Equal(t, int64(1000000000), storeDesc.NodeCapacity.StoresCPURate)
913-
require.Equal(t, int32(3), storeDesc.NodeCapacity.NumStores)
914-
require.Equal(t, int64(800000000), storeDesc.NodeCapacity.NodeCPURateUsage)
915-
require.Equal(t, int64(1000000000), storeDesc.NodeCapacity.NodeCPURateCapacity)
916-
})
917-
}

pkg/sql/create_stats.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ var errorOnConcurrentCreateStats = settings.RegisterBoolSetting(
8787
settings.ApplicationLevel,
8888
"sql.stats.error_on_concurrent_create_stats.enabled",
8989
"set to true to error on concurrent CREATE STATISTICS jobs, instead of skipping them",
90-
true,
90+
false,
9191
settings.WithPublic)
9292

9393
const nonIndexColHistogramBuckets = 2

pkg/sql/create_view.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ func (n *createViewNode) startExec(params runParams) error {
7777
return pgerror.Newf(pgcode.ReadOnlySQLTransaction, "schema changes are not allowed on a reader catalog")
7878
}
7979
createView := n.createView
80+
81+
if !params.SessionData().AllowViewWithSecurityInvokerClause && createView.Options != nil && createView.Options.SecurityInvoker {
82+
return pgerror.Newf(pgcode.FeatureNotSupported,
83+
"security invoker views are not supported")
84+
}
85+
8086
tableType := tree.GetTableType(
8187
false /* isSequence */, true /* isView */, createView.Materialized,
8288
)

0 commit comments

Comments
 (0)