Skip to content

Commit fc63227

Browse files
craig[bot]bghalkev-caoyuzefovichrafiss
committed
157030: sql: alter column identity with the declarative schema changer r=bghal a=bghal Adds support for the `ALTER COLUMN ... [RESTART | SET [CACHE | CYCLE | ... ]` identity operations in the declarative schema changer. Fixes:#142914 Epic: CRDB-31283 Release note (sql change): The `ALTER COLUMN ...` sequence identity commands are run by the declarative schema changer. 158631: jobs: hold claim on failed job for one adoption cycle r=dt,stevendanna a=kev-cao This commit teaches the job system to hold the claim on failed jobs for one adoption cycle before releasing the claim. This alleviates hot loops where a fast-failing job can be picked up repeatedly by different nodes within an adoption cycle. Fixes: #158597 Release note: None 158796: logictest: reduce test churn when adding new system table r=yuzefovich a=yuzefovich This commit reduces the test churn when adding a new system table via: - eliding rangeID prefix from 'sending batch ...' trace message - replacing the tableIDs in messages like '<before:/Table/77>' and '<after:/Table/107/1>' with 'XX'. Additionally it adjusts a handful of tests to avoid requesting the range ID where it didn't seem required for the purpose of the test. It also removes duplicated query from `information_schema` test which should've been removed when `local-mixed-23.2` config was removed. Addresses: #135989. Epic: None Release note: None 158998: .claude: add commit-helper and backport-pr-assistant skills according to CockroachDB conventions r=rafiss a=rafiss ### .claude: add commit-helper skill for CockroachDB conventions Add a Claude Code skill that assists with creating properly formatted commit messages and release notes following CockroachDB conventions. The skill encodes the project's commit message structure, release note categories, and best practices to help ensure consistency across contributions. The skill covers: - Commit message structure (package prefix, imperative mood, body format) - Release note categories and when to include/exclude them - Issue and epic reference formatting - Common mistakes to avoid ### .claude: add backport-pr-assistant skill for conflict resolution Add a Claude Code skill that assists with backporting PRs to release branches when merge conflicts require manual resolution. The skill provides reference documentation for the backport CLI tool and guidelines for resolving conflicts during the backport process. This is implemented as a skill (rather than an agent) because simple backports are handled by automation, so Claude is only invoked for cases with conflicts that require interactive discussion and resolution. The skill covers: - Backport CLI tool usage and common commands - Workflow for handling conflicts during backports - Guidelines for simple vs complex conflict resolution - Quality checks after successful backport Epic: None Release note: None Co-authored-by: Brendan Gerrity <[email protected]> Co-authored-by: Kevin Cao <[email protected]> Co-authored-by: Yahor Yuzefovich <[email protected]> Co-authored-by: Rafi Shamim <[email protected]>
5 parents 3ace0a2 + 3f8973d + 5eec53c + 0724d85 + 7c14e12 commit fc63227

File tree

152 files changed

+1496
-821
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+1496
-821
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
name: backport-pr-assistant
3+
description: Help backport PRs to release branches using the backport CLI tool. Use when backporting changes that have merge conflicts requiring manual resolution.
4+
---
5+
6+
# CockroachDB Backport Assistant
7+
8+
Help the user backport pull requests to older release branches, especially when conflicts need resolution.
9+
10+
## Backport CLI Tool Reference
11+
12+
**Basic Usage:**
13+
```bash
14+
backport <pull-request>... # Backport entire PR(s)
15+
backport <pr> -r <release> # Target specific release (e.g., -r 23.2)
16+
backport <pr> -b <branch> # Target specific branch (e.g., -b release-23.1.10-rc)
17+
backport <pr> -j "justification" # Add release justification
18+
backport <pr> -c <commit> -c <commit> # Cherry-pick specific commits only
19+
backport <pr> -f # Force operation
20+
```
21+
22+
**Conflict Resolution:**
23+
```bash
24+
backport --continue # Resume after resolving conflicts
25+
backport --abort # Cancel in-progress backport
26+
```
27+
28+
**Common Examples:**
29+
```bash
30+
backport 23437 # Simple backport
31+
backport 23437 -r 23.2 # To release-23.2 branch
32+
backport 23437 -j "test-only changes" # With justification
33+
backport 23437 -b release-23.1.10-rc # To specific release candidate branch
34+
```
35+
36+
## Workflow
37+
38+
1. **Start the backport**: Run `backport <pr> -r <release>` for the target branch
39+
2. **When conflicts occur**: The tool stops and lists conflicting files
40+
3. **Analyze conflicts**: Read the conflicting files, understand what's different between branches
41+
4. **Resolve conflicts**: Edit files to resolve, then `git add` the resolved files
42+
5. **Continue**: Run `backport --continue` to resume
43+
6. **Repeat** if more conflicts arise
44+
7. **Complete**: The backport tool pushes and creates the PR (do not use `gh` CLI to make the PR)
45+
46+
## Conflict Resolution Guidelines
47+
48+
**Simple conflicts you can resolve directly:**
49+
- Import statement conflicts
50+
- Simple variable name changes
51+
- Basic formatting differences
52+
- Minor API signature changes that are obvious
53+
54+
**Complex conflicts - ask the user for guidance:**
55+
- Conflicts involving significant logic changes
56+
- Dependencies that don't exist in the target branch
57+
- API changes requiring substantial modification
58+
- Multiple conflicting files with interdependent changes
59+
- Changes that may not be appropriate for the target branch
60+
61+
## When Resolving Conflicts
62+
63+
1. **Explain what's conflicting** - show the relevant code sections
64+
2. **Explain why** - what's different between branches that caused this
65+
3. **Propose a resolution** - or ask for guidance if complex
66+
4. **After resolving**: `git add <files>` then `backport --continue`
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
name: commit-helper
3+
description: Help create git commits and PRs with properly formatted messages and release notes following CockroachDB conventions. Use when committing changes or creating pull requests.
4+
---
5+
6+
# CockroachDB Commit Helper
7+
8+
Help the user create properly formatted commit messages and release notes that follow CockroachDB conventions.
9+
10+
## Workflow
11+
12+
1. **Analyze the changes**: Run `git diff --staged` or `git diff` to understand what was modified
13+
2. **Determine the package prefix**: Identify the primary package affected
14+
3. **Ask the user** for:
15+
- Issue/epic number if not already known
16+
- Whether release notes are needed and what category fits best
17+
4. **Write the subject line**: Imperative mood, no period, under 72 characters
18+
5. **Write the body**: Explain the before/after, why the change was needed
19+
6. **Add issue references**: Include Resolves/Epic as appropriate
20+
7. **Write the release note**: Clear, user-focused description of the change
21+
8. **Create the commit** using the properly formatted message
22+
23+
## Commit Message Structure
24+
25+
**Basic Format:**
26+
```
27+
package: imperative title without period
28+
29+
Detailed explanation of what changed, why it changed, and
30+
how it impacts users. Explain the problem that existed
31+
before and how this commit solves it.
32+
33+
Include context about alternate approaches considered and
34+
any side effects or consequences.
35+
36+
Resolves: #123
37+
Epic: CRDB-357
38+
39+
Release note (category): Description of user-facing change
40+
in past or present tense explaining what changed, how users
41+
can see the change, and why it's important.
42+
```
43+
44+
**Key Requirements:**
45+
- **Must** include release note annotation (even if "Release note: None")
46+
- **Must** include issue or epic reference
47+
- **Must** separate subject from body with blank line
48+
- **Recommended** prefix subject with affected package/area
49+
- **Recommended** use imperative mood in subject (e.g. "fix bug" not "fixes bug")
50+
- **Recommended** wrap body at 72-100 characters
51+
52+
## Release Note Categories
53+
54+
**When to include release notes:**
55+
- Changes to user interaction or experience
56+
- Changes to product behavior (performance, command responses, architecture)
57+
- Bug fixes affecting external users
58+
59+
**When to exclude release notes:**
60+
- Internal refactors, testing, infrastructure work
61+
- Code that's too immature for docs (private preview features)
62+
- Internal settings beginning with `crdb_internal.`
63+
- Functionality not accessible to external users
64+
65+
**Valid Categories:**
66+
- `backward-incompatible change` - Breaking changes to stable interfaces
67+
- `enterprise change` - Features requiring enterprise license
68+
- `ops change` - Commands/endpoints for operators (logging, metrics, CLI flags)
69+
- `cli change` - Commands for developers/contributors (SQL shells, debug tools)
70+
- `sql change` - SQL statements, functions, system catalogs
71+
- `ui change` - DB Console changes
72+
- `security update` - Security feature changes
73+
- `performance improvement` - Performance enhancements
74+
- `cluster virtualization` - Multi-tenancy infrastructure
75+
- `bug fix` - Problem fixes
76+
- `general change` - Changes that don't fit elsewhere
77+
- `build change` - Source build requirements
78+
79+
## Release Note Best Practices
80+
81+
**Description guidelines:**
82+
- Default to more information rather than less
83+
- Explain **what** changed, **how** it changed, and **why** it's relevant
84+
- Use past tense ("Added", "Fixed") or present tense ("CockroachDB now supports")
85+
- For bug fixes: describe cause, symptoms, and affected versions
86+
- Note if change is part of broader roadmap feature
87+
88+
**Examples:**
89+
90+
**Good bug fix:**
91+
```
92+
Release note (bug fix): Fixed a bug introduced in v19.2.3 that
93+
caused duplicate rows in CREATE TABLE ... AS results when multiple
94+
nodes attempt to populate the results.
95+
```
96+
97+
**Good feature:**
98+
```
99+
Release note (enterprise change): Shortened the default interval
100+
for the kv.closed_timestamp.target_duration cluster setting from
101+
30s to 3s. This allows follower reads at 4.8 seconds in the past,
102+
a much shorter window than the previous 48 seconds.
103+
```
104+
105+
## Issue References
106+
- `Resolves: #123` - Auto-closes issue on PR merge
107+
- `See also: #456, #789` - Cross-references issues
108+
- `Epic: CRDB-357` - Links to epic
109+
110+
## How to Avoid Common Pitfalls
111+
- Always include a release note annotation (even "Release note: None")
112+
- Use only valid category names from the list above
113+
- Keep release notes focused on user-facing information
114+
- Write specific descriptions that explain the impact to users
115+
- Use `backward-incompatible change` category for any breaking changes
116+
- End subject lines without punctuation
117+
- Explain the "why" behind changes, not just the "what"
118+
119+
## Pull Request Guidelines
120+
- **Create PRs from your personal fork**, not directly on cockroachdb/cockroach
121+
- **Single-commit PRs**: PR title should match commit title, PR body should match commit body

pkg/ccl/logictestccl/testdata/logic_test/crdb_internal_tenant

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,15 @@ SELECT * FROM crdb_internal.node_txn_execution_insights WHERE query = ''
248248
----
249249
txn_id txn_fingerprint_id query implicit_txn session_id start_time end_time user_name app_name rows_read rows_written priority retries last_retry_reason contention problems causes stmt_execution_ids cpu_sql_nanos last_error_code last_error_redactable status
250250

251-
query ITTI
252-
SELECT range_id, start_pretty, end_pretty, lease_holder FROM crdb_internal.ranges
251+
query TTI
252+
SELECT start_pretty, end_pretty, lease_holder FROM crdb_internal.ranges
253253
----
254-
80 /Tenant/10 /Tenant/11 1
254+
/Tenant/10 /Tenant/11 1
255255

256-
query ITT
257-
SELECT range_id, start_pretty, end_pretty FROM crdb_internal.ranges_no_leases
256+
query TT
257+
SELECT start_pretty, end_pretty FROM crdb_internal.ranges_no_leases
258258
----
259-
80 /Tenant/10 /Tenant/11
259+
/Tenant/10 /Tenant/11
260260

261261
query IT
262262
SELECT zone_id, target FROM crdb_internal.zones ORDER BY 1

pkg/ccl/logictestccl/testdata/logic_test/multi_region_remote_access_error

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,9 @@ messages_global
468468

469469
# Non-DML SHOW RANGES statement on RBR table should succeed.
470470
skipif config multiregion-9node-3region-3azs-vec-off
471-
query I retry
471+
retry
472+
statement ok
472473
SELECT DISTINCT range_id FROM [SHOW RANGES FROM TABLE messages_rbr]
473-
----
474-
85
475474

476475
# Update does not fail when accessing all rows in messages_rbr because lookup
477476
# join does not error out the lookup table in phase 1.

pkg/ccl/logictestccl/testdata/logic_test/regional_by_row_insert_fast_path

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ query T rowsort
200200
SELECT message FROM [SHOW KV TRACE FOR SESSION]
201201
WHERE message LIKE '%batch%' AND message LIKE '%Scan%'
202202
----
203-
r79: sending batch 4 Scan to (n1,s1):1
203+
sending batch 4 Scan to (n1,s1):1
204204

205205
# Regression test for #115377.
206206
statement ok

pkg/ccl/logictestccl/testdata/logic_test/regional_by_row_query_behavior

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ ap-southeast-2 23
266266
query TT
267267
SELECT start_key, end_key FROM [SHOW RANGE FROM TABLE regional_by_row_table FOR ROW ('ap-southeast-2', 1)]
268268
----
269-
<before:/Table/76> …
269+
<before:/Table/XX> …
270270

271271
query TIIII
272272
SELECT crdb_region, pk, pk2, a, b FROM regional_by_row_table
@@ -404,9 +404,9 @@ SELECT start_key, end_key, replicas, lease_holder FROM [SHOW RANGES FROM INDEX r
404404
ORDER BY 1
405405
----
406406
start_key end_key replicas lease_holder
407-
<before:/Table/76> …/"\x80"/0 {1} 1
407+
<before:/Table/XX> …/"\x80"/0 {1} 1
408408
…/"\x80"/0 …/"\xc0"/0 {4} 4
409-
…/"\xc0"/0 <after:/Table/110/5> {7} 7
409+
…/"\xc0"/0 <after:/Table/XX/5> {7} 7
410410

411411
statement ok
412412
SET locality_optimized_partitioned_index_scan = false

pkg/cmd/roachtest/tests/mixed_version_job_compatibility_in_declarative_schema_changer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ func executeSupportedDDLs(
127127
v261DDLs := []string{
128128
`ALTER TABLE testdb.testsc.t2 ALTER COLUMN j SET NOT VISIBLE`,
129129
`ALTER TABLE testdb.testsc.t2 ALTER COLUMN j SET VISIBLE`,
130+
`ALTER TABLE testdb.testsc.t2 ALTER COLUMN l SET MAXVALUE 40 RESTART WITH 20 SET CACHE 5 SET INCREMENT BY 2`,
130131
}
131132

132133
// Used to clean up our CREATE-d elements after we are done with them.
@@ -209,7 +210,7 @@ CREATE DATABASE IF NOT EXISTS testdb;
209210
CREATE SCHEMA IF NOT EXISTS testdb.testsc;
210211
CREATE TABLE IF NOT EXISTS testdb.testsc.t (i INT PRIMARY KEY, j INT NOT NULL, INDEX idx (j), CONSTRAINT check_j CHECK (j > 0));
211212
INSERT INTO testdb.testsc.t VALUES (1, 1);
212-
CREATE TABLE IF NOT EXISTS testdb.testsc.t2 (i INT NOT NULL, j INT NOT NULL, k STRING NOT NULL);
213+
CREATE TABLE IF NOT EXISTS testdb.testsc.t2 (i INT NOT NULL, j INT NOT NULL, k STRING NOT NULL, l INT GENERATED ALWAYS AS IDENTITY);
213214
INSERT INTO testdb.testsc.t2 VALUES (2, 3, 'foo');
214215
CREATE TABLE IF NOT EXISTS testdb.testsc.t3 (i INT NOT NULL, j INT NOT NULL, k STRING NOT NULL);
215216
INSERT INTO testdb.testsc.t3 VALUES (3, 3, 'bar');

pkg/jobs/adopt.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"context"
1010
"fmt"
1111
"sync"
12+
"time"
1213

1314
"github.com/cockroachdb/cockroach/pkg/jobs/jobspb"
1415
"github.com/cockroachdb/cockroach/pkg/kv"
@@ -423,14 +424,28 @@ func (r *Registry) runJob(
423424
}
424425

425426
r.maybeRecordExecutionFailure(ctx, err, job)
426-
// NB: After this point, the job may no longer have the claim
427-
// and further updates to the job record from this node may
428-
// fail.
429-
r.maybeClearLease(job, err)
430427
r.maybeDumpTrace(ctx, resumer, job.ID())
428+
431429
if r.knobs.AfterJobStateMachine != nil {
432430
r.knobs.AfterJobStateMachine(job.ID())
433431
}
432+
433+
// NB: After this point, the job may no longer have the claim and further
434+
// updates to the job record from this node may fail.
435+
if err != nil {
436+
// We delay clearing the lease to avoid situations where a job fast-fails
437+
// and is immediately re-adopted by another node, causing a hot loop of job
438+
// status changes. See #158597 for more info.
439+
//
440+
// NB: The node that holds this claim also will not rerun the job until
441+
// this interval elapses and the job is removed from the list of currently
442+
// running jobs.
443+
select {
444+
case <-ctx.Done():
445+
case <-time.After(r.GetLoopInterval(adoptIntervalSetting, r.knobs.IntervalOverrides.ClaimTTLOnFailure)):
446+
}
447+
r.maybeClearLease(job, err)
448+
}
434449
return err
435450
}
436451

pkg/jobs/config.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"time"
1212

1313
"github.com/cockroachdb/cockroach/pkg/settings"
14-
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
1514
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
1615
)
1716

@@ -177,18 +176,13 @@ type loopController struct {
177176
// at regular intervals. The structure's cleanup method should be deferred to
178177
// execute before destroying the instantiated structure.
179178
func makeLoopController(
180-
st *cluster.Settings, s *settings.DurationSetting, overrideKnob *time.Duration,
179+
r *Registry, s *settings.DurationSetting, overrideKnob *time.Duration,
181180
) loopController {
182181
lc := loopController{
183182
lastRun: timeutil.Now(),
184183
updated: make(chan struct{}, 1),
185-
// getInterval returns the value of the associated cluster setting. If
186-
// overrideKnob is not nil, it overrides the cluster setting.
187184
getInterval: func() time.Duration {
188-
if overrideKnob != nil {
189-
return *overrideKnob
190-
}
191-
return time.Duration(intervalBaseSetting.Get(&st.SV) * float64(s.Get(&st.SV)))
185+
return r.GetLoopInterval(s, overrideKnob)
192186
},
193187
}
194188

@@ -202,8 +196,8 @@ func makeLoopController(
202196
}
203197

204198
// register onChange() to get a notification when the cluster is updated.
205-
s.SetOnChange(&st.SV, onChange)
206-
intervalBaseSetting.SetOnChange(&st.SV, onChange)
199+
s.SetOnChange(&r.settings.SV, onChange)
200+
intervalBaseSetting.SetOnChange(&r.settings.SV, onChange)
207201

208202
lc.timer.Reset(jitter(lc.getInterval()))
209203
return lc

0 commit comments

Comments
 (0)