Skip to content

Commit e942b71

Browse files
craig[bot]mgartnerUzair5162kev-caokyle-a-wong
committed
152882: sql: fix placeholder type checking r=mgartner a=mgartner Previously, an binary expression with two placeholders could be incorrectly typed in a prepared statement. The issue could occur when one placeholder had an `UNKNOWN` type hint and one with a non-ambiguous type hint, e.g., `INT`, `DECIMAL`, etc. The `UNKNOWN` type hint could take precedence over the non-ambiguous type. This could cause incorrect results in some cases. The bug has been fixed by preferring non-ambiguous type hints over ambiguous ones. Fixes #152664 Release note (bug fix): A bug in type-checking placeholders with `UNKNOWN` types has been fixed. It could cause incorrect results in some cases. 153419: sql/stats: merge all arbitrary partial and full table statistics r=Uzair5162 a=Uzair5162 This commit generalizes partial and full stat merging in the stats cache to support partial stats collected over any range of values in a column. Non-extreme partial stats are treated as covering a single span, and extreme partials continue to separate the lower and upper extreme buckets as before. Additionally, merged stats now apply all partial stats collected after the latest full stat, in order of creation. Previously, we could only merge partial stats collected at the extremes of the index, and would only merge the latest one. Part of: #93998 Release note (sql change): The optimizer can now use table statistics that merge the latest full statistic with all newer partial statistics, including those over arbitrary constraints over a single span. 154654: restore: deflake TestRestoreCheckpointing r=msbutler a=kev-cao The current `TestRestoreCheckpointing` waits for job progress to be updated by sleeping for a duration greater than the checkpoint interval. While this works the vast majority of the time, if the test cluster is overloaded, it is not sufficient and we can end up resuming the job before the progress was updated. This results in more spans being processed than expected. This commit updates the test to instead check the contents of the job progress checkpoint and wait until the checkpoint contains all processed spans from before the pause. Fixes: #153848 Release note: None 154676: stmtdiagnostics: don't create statement dignostics request for txn di… r=kyle-a-wong a=kyle-a-wong …agnostics Previously, `innerInsertStatementDiagnostics` was creating new statement diagnostics requests when a transaction diagnostics bundle was being created. Now, these new statement requests will no longer be created. Epic: CRDB-53541 Release note: None 154677: sql: remove canModifySchema interface r=mgartner a=mgartner The `canModifySchema` interface has been removed. The `CanModifySchema` function now has special logic for the two non-DDL statements that modify the schema: `DISCARD` and `SET ZONE CONFIG`. Additionally, `CanModifySchema` now returns early for DML statements—a very minor optimization to avoid an unnecessary invocation of the `StatementReturnType` method which can chase additional pointers for `RETURNING` nodes of `INSERT` and `UPDATE` statements. Release note: None 154679: sql: move bufferable session var lookup to init-time r=mgartner a=mgartner Lookups for bufferable session vars are now performed once at init-time rather than every time `(*connExecutor).reportSessionDataChanges` is called. Release note: None 154698: workflows: update names of GitHub Action runner groups r=rail a=rickystewart These are the new-style names that will make it easier to migrate to Ubuntu 22.04+ when the time comes. 154711: sql: update stats for descriptor table r=rafiss a=rafiss This is needed in order to enforce the sql.schema.approx_max_object_count cluster setting, which relies on optimizer table statistics to find the count. Since the schemachanger uses the KV API to write to the descriptor table, we need to explicitly notify the stats refresher when it should compute new stats for the table. informs: #148286 Release note: None ### schematelemetry: update object count gauge using table stats In order to support larger scales of object counts, we switch away from using a full table scan on system.descriptors in order to update the object count gauge. Instead, we use table stats on system.descriptor now. The schematelemetry job is updated so it notifies the stats refresher to keep the stats up to date. Note that the stats refresher is also notified with a partial count already. Epic CRDB-48806 Release note: None 154733: changefeedccl: fix slow acquisition log message r=andyyang890 a=stevendanna Previously, have been waiting rangefeed attempting to acquire changefeed quota (buffer=5.000049088s) Now, have been waiting 5.000049088s attempting to acquire changefeed quota (buffer=rangefeed) It would be nice if the buffer name `rangefeed` was something that indicated that this a buffer that lives in the changefeed, but changing the name impacts the metrics which doesn't seem worth it. Epic: none Release note: None 154742: dev-inf: Use pull_request_target for Claude Code review action r=rickystewart a=ajstorm Previously, the Claude Code PR Review GitHub Action used the pull_request trigger, which runs in the context of the PR branch. This prevents GitHub from injecting OIDC tokens when the PR comes from a forked repository, causing authentication failures with Google Cloud's Workload Identity Federation. This change updates the workflow to use pull_request_target instead, which runs in the context of the base repository. This allows OIDC tokens to be injected even for fork PRs, enabling authentication with Google Cloud for Vertex AI access. Our standard git flow requires developers to create PRs from forks, so this change is necessary for the action to function in our development workflow. The workflow is safe to run with pull_request_target because it does not check out the PR branch - all PR content is fetched safely via the GitHub API using 'gh pr diff' and 'gh pr view'. Release note: None Epic: None Co-authored-by: Marcus Gartner <[email protected]> Co-authored-by: Uzair Ahmad <[email protected]> Co-authored-by: Kevin Cao <[email protected]> Co-authored-by: Kyle Wong <[email protected]> Co-authored-by: Ricky Stewart <[email protected]> Co-authored-by: Rafi Shamim <[email protected]> Co-authored-by: Steven Danna <[email protected]> Co-authored-by: Adam Storm <[email protected]>
11 parents c3e2217 + 802d7e6 + db9a344 + b56401c + 3e01ba6 + 5814d5b + 4473e6c + bd2bce0 + a11aef2 + 45bbe65 + 2ac56a2 commit e942b71

36 files changed

+1687
-652
lines changed

.github/workflows/github-actions-essential-ci.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ concurrency:
5454
cancel-in-progress: true
5555
jobs:
5656
acceptance:
57-
runs-on: [self-hosted, basic_big_runner_group]
57+
runs-on: [self-hosted, ubuntu_big_2004]
5858
timeout-minutes: 60
5959
steps:
6060
- uses: actions/checkout@v4
@@ -75,7 +75,7 @@ jobs:
7575
run: ./build/github/cleanup-engflow-keys.sh
7676
if: always()
7777
check_generated_code:
78-
runs-on: [self-hosted, basic_runner_group]
78+
runs-on: [self-hosted, ubuntu_2004]
7979
timeout-minutes: 60
8080
steps:
8181
- uses: actions/checkout@v4
@@ -90,7 +90,7 @@ jobs:
9090
run: ./build/github/cleanup-engflow-keys.sh
9191
if: always()
9292
docker_image_amd64:
93-
runs-on: [self-hosted, basic_runner_group]
93+
runs-on: [self-hosted, ubuntu_2004]
9494
timeout-minutes: 60
9595
steps:
9696
- uses: actions/checkout@v4
@@ -111,7 +111,7 @@ jobs:
111111
run: ./build/github/cleanup-engflow-keys.sh
112112
if: always()
113113
examples_orms:
114-
runs-on: [self-hosted, basic_big_runner_group]
114+
runs-on: [self-hosted, ubuntu_big_2004]
115115
timeout-minutes: 120
116116
steps:
117117
- uses: actions/checkout@v4
@@ -132,7 +132,7 @@ jobs:
132132
run: ./cockroach/build/github/cleanup-engflow-keys.sh
133133
if: always()
134134
lint:
135-
runs-on: [self-hosted, basic_big_runner_group]
135+
runs-on: [self-hosted, ubuntu_big_2004]
136136
timeout-minutes: 120
137137
steps:
138138
- uses: actions/checkout@v4
@@ -156,7 +156,7 @@ jobs:
156156
run: ./build/github/cleanup-engflow-keys.sh
157157
if: always()
158158
local_roachtest:
159-
runs-on: [self-hosted, basic_big_runner_group]
159+
runs-on: [self-hosted, ubuntu_big_2004]
160160
timeout-minutes: 120
161161
steps:
162162
- uses: actions/checkout@v4
@@ -181,7 +181,7 @@ jobs:
181181
run: ./build/github/cleanup-engflow-keys.sh
182182
if: always()
183183
local_roachtest_fips:
184-
runs-on: [self-hosted, basic_runner_group_fips]
184+
runs-on: [self-hosted, ubuntu_2004_fips]
185185
timeout-minutes: 120
186186
steps:
187187
- uses: actions/checkout@v4
@@ -206,7 +206,7 @@ jobs:
206206
run: ./build/github/cleanup-engflow-keys.sh
207207
if: always()
208208
linux_amd64_build:
209-
runs-on: [self-hosted, basic_runner_group]
209+
runs-on: [self-hosted, ubuntu_2004]
210210
timeout-minutes: 60
211211
steps:
212212
- uses: actions/checkout@v4
@@ -227,7 +227,7 @@ jobs:
227227
run: ./build/github/cleanup-engflow-keys.sh
228228
if: always()
229229
linux_amd64_fips_build:
230-
runs-on: [self-hosted, basic_runner_group]
230+
runs-on: [self-hosted, ubuntu_2004]
231231
timeout-minutes: 60
232232
steps:
233233
- uses: actions/checkout@v4
@@ -248,7 +248,7 @@ jobs:
248248
run: ./build/github/cleanup-engflow-keys.sh
249249
if: always()
250250
unit_tests:
251-
runs-on: [self-hosted, basic_runner_group]
251+
runs-on: [self-hosted, ubuntu_2004]
252252
timeout-minutes: 120
253253
steps:
254254
- uses: actions/checkout@v4

.github/workflows/microbenchmarks-ci.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ env:
1717
jobs:
1818
base:
1919
name: build merge base
20-
runs-on: [self-hosted, basic_runner_group]
20+
runs-on: [self-hosted, ubuntu_2004]
2121
timeout-minutes: 30
2222
if: ${{ !contains(github.event.pull_request.labels.*.name, 'X-skip-perf-check') }}
2323
outputs:
@@ -33,7 +33,7 @@ jobs:
3333
pkg: ${{ env.PACKAGE }}
3434
head:
3535
name: build head
36-
runs-on: [self-hosted, basic_runner_group]
36+
runs-on: [self-hosted, ubuntu_2004]
3737
timeout-minutes: 30
3838
if: ${{ !contains(github.event.pull_request.labels.*.name, 'X-skip-perf-check') }}
3939
steps:
@@ -46,7 +46,7 @@ jobs:
4646
ref: head
4747
pkg: ${{ env.PACKAGE }}
4848
run-group-1:
49-
runs-on: [self-hosted, basic_microbench_runner_group]
49+
runs-on: [self-hosted, ubuntu_2004_microbench]
5050
timeout-minutes: 60
5151
needs: [base, head]
5252
steps:
@@ -59,7 +59,7 @@ jobs:
5959
pkg: ${{ env.PACKAGE }}
6060
group: 1
6161
run-group-2:
62-
runs-on: [self-hosted, basic_microbench_runner_group]
62+
runs-on: [self-hosted, ubuntu_2004_microbench]
6363
timeout-minutes: 60
6464
needs: [base, head]
6565
steps:
@@ -72,7 +72,7 @@ jobs:
7272
pkg: ${{ env.PACKAGE }}
7373
group: 2
7474
compare:
75-
runs-on: [self-hosted, basic_runner_group]
75+
runs-on: [self-hosted, ubuntu_2004]
7676
timeout-minutes: 30
7777
permissions:
7878
contents: read

.github/workflows/pr-analyzer-threestage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Claude Code PR Review
22

33
on:
4-
pull_request:
4+
pull_request_target:
55
types: [synchronize, ready_for_review, reopened, labeled]
66

77
jobs:

pkg/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,6 +2339,7 @@ GO_TARGETS = [
23392339
"//pkg/sql/sem/plpgsqltree:plpgsqltree",
23402340
"//pkg/sql/sem/semenumpb:semenumpb",
23412341
"//pkg/sql/sem/transform:transform",
2342+
"//pkg/sql/sem/tree/datumrange:datumrange",
23422343
"//pkg/sql/sem/tree/evalgen:evalgen",
23432344
"//pkg/sql/sem/tree/evalgen:evalgen_lib",
23442345
"//pkg/sql/sem/tree/treebin:treebin",

pkg/backup/backup_test.go

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,8 +1301,12 @@ func TestRestoreCheckpointing(t *testing.T) {
13011301
defer jobs.TestingSetProgressThresholds()()
13021302

13031303
// totalEntries represents the number of entries to appear in the persisted frontier.
1304-
totalEntries := 7
1305-
entriesBeforePause := 4
1304+
const totalEntries = 7
1305+
const entriesBeforePause = 4
1306+
processedSpans := struct {
1307+
syncutil.Mutex
1308+
spans roachpb.Spans
1309+
}{}
13061310
entriesCount := 0
13071311
var alreadyPaused atomic.Bool
13081312
postResumeCount := 0
@@ -1313,7 +1317,7 @@ func TestRestoreCheckpointing(t *testing.T) {
13131317
knobs := base.TestingKnobs{
13141318
DistSQL: &execinfra.TestingKnobs{
13151319
BackupRestoreTestingKnobs: &sql.BackupRestoreTestingKnobs{
1316-
RunAfterProcessingRestoreSpanEntry: func(_ context.Context, _ *execinfrapb.RestoreSpanEntry) error {
1320+
RunAfterProcessingRestoreSpanEntry: func(_ context.Context, entry *execinfrapb.RestoreSpanEntry) error {
13171321
// Because the restore processor has several workers that
13181322
// concurrently send addsstable requests and because all workers will
13191323
// wait on the lock below, when one flush gets blocked on the
@@ -1325,12 +1329,20 @@ func TestRestoreCheckpointing(t *testing.T) {
13251329
// checking if the job was paused in each request before it began
13261330
// waiting for the lock.
13271331
wasPausedBeforeWaiting := alreadyPaused.Load()
1332+
13281333
mu.Lock()
13291334
defer mu.Unlock()
13301335
if entriesCount == entriesBeforePause {
13311336
close(waitForProgress)
13321337
<-blockDBRestore
1338+
} else if entriesCount < entriesBeforePause {
1339+
// We save all spans from before the pause to ensure that they have
1340+
// been checkpointed and saved in the job progress.
1341+
processedSpans.Lock()
1342+
defer processedSpans.Unlock()
1343+
processedSpans.spans = append(processedSpans.spans, entry.Span)
13331344
}
1345+
13341346
entriesCount++
13351347
if wasPausedBeforeWaiting {
13361348
postResumeCount++
@@ -1373,8 +1385,25 @@ func TestRestoreCheckpointing(t *testing.T) {
13731385
// Pause the job after some progress has been logged.
13741386
<-waitForProgress
13751387

1376-
// To ensure that progress gets persisted, sleep well beyond the test only job update interval.
1377-
time.Sleep(time.Second)
1388+
// To ensure that progress has been persisted, we wait until all processed
1389+
// spans from before the pause are stored in the job progress.
1390+
testutils.SucceedsSoon(t, func() error {
1391+
jobProgress := jobutils.GetJobProgress(t, sqlDB, jobID)
1392+
checkpointedSpans := jobProgress.GetRestore().Checkpoint
1393+
checkpointedSpanGroup := roachpb.SpanGroup{}
1394+
for _, span := range checkpointedSpans {
1395+
checkpointedSpanGroup.Add(span.Span)
1396+
}
1397+
1398+
processedSpans.Lock()
1399+
defer processedSpans.Unlock()
1400+
for _, span := range processedSpans.spans {
1401+
if !checkpointedSpanGroup.Encloses(span) {
1402+
return errors.Newf("span %s was processed but not saved in job progress yet")
1403+
}
1404+
}
1405+
return nil
1406+
})
13781407

13791408
sqlDB.Exec(t, `PAUSE JOB $1`, &jobID)
13801409
jobutils.WaitForJobToPause(t, sqlDB, jobID)

pkg/ccl/changefeedccl/kvevent/blocking_buffer.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,13 +523,16 @@ func logSlowAcquisition(
523523
return func(ctx context.Context, poolName string, r quotapool.Request, start time.Time) func() {
524524
shouldLog := logSlowAcquire.ShouldLog()
525525
if shouldLog {
526-
log.Changefeed.Warningf(ctx, "have been waiting %s attempting to acquire changefeed quota (buffer=%s)", redact.SafeString(bufType),
527-
timeutil.Since(start))
526+
log.Changefeed.Warningf(ctx, "have been waiting %s attempting to acquire changefeed quota (buffer=%s)",
527+
timeutil.Since(start),
528+
redact.SafeString(bufType))
528529
}
529530

530531
return func() {
531532
if shouldLog {
532-
log.Changefeed.Infof(ctx, "acquired changefeed quota after %s (buffer=%s)", timeutil.Since(start), redact.SafeString(bufType))
533+
log.Changefeed.Infof(ctx, "acquired changefeed quota after %s (buffer=%s)",
534+
timeutil.Since(start),
535+
redact.SafeString(bufType))
533536
}
534537
}
535538
}

pkg/sql/catalog/descs/collection.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -273,21 +273,17 @@ func (tc *Collection) IsVersionBumpOfUncommittedDescriptor(id descpb.ID) bool {
273273
return tc.uncommitted.versionBumpOnly[id]
274274
}
275275

276-
// HasUncommittedNewOrDroppedDescriptors returns true if the collection contains
277-
// any uncommitted descriptors that are newly created or dropped.
278-
func (tc *Collection) HasUncommittedNewOrDroppedDescriptors() bool {
279-
isNewDescriptor := false
280-
err := tc.uncommitted.iterateUncommittedByID(func(desc catalog.Descriptor) error {
276+
// CountUncommittedNewOrDroppedDescriptors returns the number of uncommitted
277+
// descriptors that are newly created or dropped.
278+
func (tc *Collection) CountUncommittedNewOrDroppedDescriptors() int {
279+
count := 0
280+
_ = tc.uncommitted.iterateUncommittedByID(func(desc catalog.Descriptor) error {
281281
if desc.GetVersion() == 1 || desc.Dropped() {
282-
isNewDescriptor = true
283-
return iterutil.StopIteration()
282+
count++
284283
}
285284
return nil
286285
})
287-
if err != nil {
288-
return false
289-
}
290-
return isNewDescriptor
286+
return count
291287
}
292288

293289
// HasUncommittedTypes returns true if the Collection contains uncommitted

pkg/sql/catalog/schematelemetry/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ go_library(
1212
deps = [
1313
"//pkg/jobs",
1414
"//pkg/jobs/jobspb",
15+
"//pkg/keys",
1516
"//pkg/scheduledjobs",
1617
"//pkg/security/username",
1718
"//pkg/server/telemetry",

pkg/sql/catalog/schematelemetry/schema_telemetry_job.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ package schematelemetry
77

88
import (
99
"context"
10+
"math"
1011

1112
"github.com/cockroachdb/cockroach/pkg/jobs"
1213
"github.com/cockroachdb/cockroach/pkg/jobs/jobspb"
14+
"github.com/cockroachdb/cockroach/pkg/keys"
1315
"github.com/cockroachdb/cockroach/pkg/server/telemetry"
1416
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
1517
"github.com/cockroachdb/cockroach/pkg/sql"
@@ -63,6 +65,31 @@ func (t schemaTelemetryResumer) Resume(ctx context.Context, execCtx interface{})
6365
if k := p.ExecCfg().SchemaTelemetryTestingKnobs; k != nil {
6466
knobs = *k
6567
}
68+
// Notify the stats refresher to update the system.descriptors table stats,
69+
// and update the object count in schema changer metrics.
70+
err := p.ExecCfg().InternalDB.DescsTxn(ctx, func(ctx context.Context, txn descs.Txn) error {
71+
desc, err := txn.Descriptors().ByIDWithLeased(txn.KV()).Get().Table(ctx, keys.DescriptorTableID)
72+
if err != nil {
73+
return err
74+
}
75+
p.ExecCfg().StatsRefresher.NotifyMutation(desc, math.MaxInt64 /* rowCount */)
76+
77+
// Note: This won't be perfectly up-to-date, but it will make sure the
78+
// metric gets updated periodically. It also gets updated after every
79+
// schema change.
80+
tableStats, err := p.ExecCfg().TableStatsCache.GetTableStats(ctx, desc, nil /* typeResolver */)
81+
if err != nil {
82+
return err
83+
}
84+
if len(tableStats) > 0 {
85+
// Use the row count from the most recent statistic.
86+
p.ExecCfg().SchemaChangerMetrics.ObjectCount.Update(int64(tableStats[0].RowCount))
87+
}
88+
return nil
89+
})
90+
if err != nil {
91+
return errors.Wrap(err, "failed to notify stats refresher to update system.descriptors table stats")
92+
}
6693

6794
// Outside of tests, scan the catalog tables AS OF SYSTEM TIME slightly in the
6895
// past. Schema telemetry is not latency-sensitive to the point where a few

pkg/sql/conn_executor.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4169,11 +4169,10 @@ func (ex *connExecutor) txnStateTransitionsApplyWrapper(
41694169
if err := ex.waitForInitialVersionForNewDescriptors(cachedRegions); err != nil {
41704170
return advanceInfo{}, err
41714171
}
4172-
}
4173-
if ex.extraTxnState.descCollection.HasUncommittedNewOrDroppedDescriptors() {
4172+
41744173
execCfg := ex.planner.ExecCfg()
41754174
if err := UpdateDescriptorCount(ex.Ctx(), execCfg, execCfg.SchemaChangerMetrics); err != nil {
4176-
log.Dev.Warningf(ex.Ctx(), "failed to scan descriptor table: %v", err)
4175+
log.Dev.Warningf(ex.Ctx(), "failed to update descriptor count metric: %v", err)
41774176
}
41784177
}
41794178
fallthrough
@@ -4572,6 +4571,16 @@ func (ex *connExecutor) notifyStatsRefresherOfNewTables(ctx context.Context) {
45724571
ex.planner.execCfg.StatsRefresher.NotifyMutation(desc, math.MaxInt32 /* rowsAffected */)
45734572
}
45744573
}
4574+
if cnt := ex.extraTxnState.descCollection.CountUncommittedNewOrDroppedDescriptors(); cnt > 0 {
4575+
// Notify the refresher of a mutation on the system.descriptor table.
4576+
// We conservatively assume that any transaction which creates or
4577+
desc, err := ex.extraTxnState.descCollection.ByIDWithLeased(ex.planner.txn).Get().Table(ctx, keys.DescriptorTableID)
4578+
if err != nil {
4579+
log.Dev.Warningf(ctx, "failed to fetch descriptor table to refresh stats: %v", err)
4580+
return
4581+
}
4582+
ex.planner.execCfg.StatsRefresher.NotifyMutation(desc, cnt)
4583+
}
45754584
}
45764585

45774586
func (ex *connExecutor) getDescIDGenerator() eval.DescIDGenerator {

0 commit comments

Comments
 (0)