Skip to content

lease: migrate lease to rbr compatible index#98446

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
jeffswenson:jeffswenson-rbr-lease-migration
Mar 16, 2023
Merged

lease: migrate lease to rbr compatible index#98446
craig[bot] merged 1 commit intocockroachdb:masterfrom
jeffswenson:jeffswenson-rbr-lease-migration

Conversation

@jeffswenson
Copy link
Copy Markdown
Collaborator

@jeffswenson jeffswenson commented Mar 11, 2023

Migrate the system.lease table to an index that is byte compatible with
a regional by row index. The version gates are intended to follow the
protocol discussed in the comment at the top of
upgrades/system_rbr_indexes.go

Writing to the lease table always occurs throught he kv API. The table
is read via the SQL api. The SQL uses of the system.lease table are
forwards compatible as long as they do not need to read the crdb_region.
Queries that interact with individual leases need to retrieve the
crdb_region and must consult the version gate.

Part of #94843

Release Note: None

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@jeffswenson jeffswenson force-pushed the jeffswenson-rbr-lease-migration branch 4 times, most recently from d67a639 to e7a2512 Compare March 12, 2023 22:49
@jeffswenson jeffswenson force-pushed the jeffswenson-rbr-lease-migration branch 4 times, most recently from 64a52fe to 0248924 Compare March 14, 2023 19:04
@jeffswenson jeffswenson changed the title lease: migrate lease to rbr compatible table lease: migrate lease to rbr compatible index Mar 14, 2023
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Mar 14, 2023
Previously the role members test used the v23_1 schema with the
V23_1RoleMembersTableHasIDColumns version gate. This caused problems for
PR cockroachdb#98446 because the lease schema does not match the lease version
gates.

Now, the test uses the BootstrapVersionKeyOverride to bootstrap with the
V22_2 schema. Setting the cluster version walks the cluster through all
of the migrations including the role members migration.

Part of cockroachdb#98446

Release Note: none
@jeffswenson jeffswenson marked this pull request as ready for review March 14, 2023 19:28
@jeffswenson jeffswenson requested a review from a team March 14, 2023 19:28
@jeffswenson jeffswenson requested a review from a team as a code owner March 14, 2023 19:28
Copy link
Copy Markdown
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

Seems straightforward enough. There's a test that's failing related to the mixed version state that seems interesting.

Reviewed 18 of 18 files at r2, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

@jeffswenson
Copy link
Copy Markdown
Collaborator Author

Seems straightforward enough. There's a test that's failing related to the mixed version state that seems interesting.

Reviewed 18 of 18 files at r2, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

I'll root cause the failure before merging this. The test is failing consistently. The schema changer is getting stuck trying to roll back a change and the error seems to suggest it is leasing related:

I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407  job 847905911162306561: reverting execution encountered retriable error: table version mismatch: 157, expected: 156
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +(1) forced error mark
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  | "retriable job error"
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  | github.com/cockroachdb/errors/withstack/*withstack.withStack::
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +Wraps: (2) secondary error attachment
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  | original error when rolling back mutations: validation of CHECK "i < 0:::INT8" failed on row: a=1, x=NULL, y=1.3, z=1.4, d=NULL, f=NULL, g=1, h=NULL, i=1
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  | (1) attached stack trace
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   -- stack trace:
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   | github.com/cockroachdb/cockroach/pkg/sql.(*SchemaChanger).handlePermanentSchemaChangeError
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   | 	github.com/cockroachdb/cockroach/pkg/sql/schema_changer.go:854
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   | github.com/cockroachdb/cockroach/pkg/sql.schemaChangeResumer.OnFailOrCancel
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   | 	github.com/cockroachdb/cockroach/pkg/sql/schema_changer.go:2821
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   | github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).stepThroughStateMachine.func3
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   | 	github.com/cockroachdb/cockroach/pkg/jobs/registry.go:1630
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   | github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).stepThroughStateMachine
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   | 	github.com/cockroachdb/cockroach/pkg/jobs/registry.go:1631
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   | github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).stepThroughStateMachine
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   | 	github.com/cockroachdb/cockroach/pkg/jobs/registry.go:1576
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   | github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).runJob
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   | 	github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:417
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   | github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).resumeJob.func1
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   | 	github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:335
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   | github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTaskEx.func2
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   | 	github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:470
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   | runtime.goexit
I230314 21:52:28.963643 11526 jobs/registry.go:1648  [T1,n1] 1407 +  |   | 	GOROOT/src/runtime/asm_amd64.s:1594

craig bot pushed a commit that referenced this pull request Mar 15, 2023
98613: upgrades: use v22_2 bootstrap schema with role_members test r=JeffSwenson a=JeffSwenson

Previously the role members test used the v23_1 schema with the V23_1RoleMembersTableHasIDColumns version gate. This caused problems for PR #98446 because the lease schema does not match the lease version gates.

Now, the test uses the BootstrapVersionKeyOverride to bootstrap with the V22_2 schema. Setting the cluster version walks the cluster through all of the migrations including the role members migration.

Part of #98446

Release Note: none

Co-authored-by: Jeff <swenson@cockroachlabs.com>
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Mar 15, 2023
Previously, the v22.2-v23.1 mixed version test was using the v22.2
version gate with a v23.1 schema. This caused the alter_table test to
fail on PR cockroachdb#98446. The lease protocol only works if the version gates
and the schema are in sync.

As part of this change I simplified the version configuration in the
logic tests so that the only version key is the bootstrap version. It
doesn't really make sense to specify a binary version different than the
build version. The binary will always have the build version's behavior.

This change also deletes the local-v1.1-at-v1.0-noupgrade test. The
version can't be described by a version key and the tests do not
represent a situation that occurs in real world deployments.

Part of cockroachdb#94843

Release note: None
@jeffswenson jeffswenson force-pushed the jeffswenson-rbr-lease-migration branch from 0248924 to 42b99ce Compare March 15, 2023 19:21
@jeffswenson jeffswenson requested a review from a team as a code owner March 15, 2023 19:21
@jeffswenson jeffswenson requested a review from cucaroach March 15, 2023 19:21
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Mar 15, 2023
Previously, the v22.2-v23.1 mixed version test was using the v22.2
version gate with a v23.1 schema. This caused the alter_table test to
fail on PR cockroachdb#98446. The lease protocol only works if the version gates
and the schema are in sync.

As part of this change I simplified the version configuration in the
logic tests so that the only version key is the bootstrap version. It
doesn't really make sense to specify a binary version different than the
build version. The binary will always have the build version's behavior.

This change also deletes the local-v1.1-at-v1.0-noupgrade test. The
version can't be described by a version key and the tests do not
represent a situation that occurs in real world deployments.

Part of cockroachdb#94843

Release note: None
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Mar 15, 2023
Previously, the v22.2-v23.1 mixed version test was using the v22.2
version gate with a v23.1 schema. This caused the alter_table test to
fail on PR cockroachdb#98446. The lease protocol only works if the version gates
and the schema are in sync.

As part of this change I simplified the version configuration in the
logic tests so that the only version key is the bootstrap version. It
doesn't really make sense to specify a binary version different than the
build version. The binary will always have the build version's behavior.

This change also deletes the local-v1.1-at-v1.0-noupgrade test. The
version can't be described by a version key and the tests do not
represent a situation that occurs in real world deployments.

Part of cockroachdb#94843

Release note: None
craig bot pushed a commit that referenced this pull request Mar 15, 2023
98695: logictest: use v22_2 schema in mixed version test r=JeffSwenson a=JeffSwenson

Previously, the v22.2-v23.1 mixed version test was using the v22.2 version gate with a v23.1 schema. This caused the alter_table test to fail on PR #98446. The lease protocol only works if the version gates and the schema are in sync.

As part of this change I simplified the version configuration in the logic tests so that the only version key is the bootstrap version. It doesn't really make sense to specify a binary version different than the build version. The binary will always have the build version's behavior.

This change also deletes the local-v1.1-at-v1.0-noupgrade test. The version can't be described by a version key and the tests do not represent a situation that occurs in real world deployments.

Part of #94843

Release note: None

98697: sql: make sure mixed version logic tests are enabled for declarative schema changer enabled DDL in 22.2 r=chengxiong-ruan a=chengxiong-ruan

Informs: #98637

This PR makes sure we enable mixed version logic tests for ddl statements enabled in declarative schema changer in 22.2.

We already have mixed version test coverage for `CREATE INDEX`, `DROP INDEX`, `ADD COLUMN`, `DROP COLUMN` and `ADD CONSTRAINT`.

Each commit turns on mixed version logic test for each of `DROP OWNED BY`, `COMMENT ON` and `ALTER PRIMARY KEY`.

98711: storage,kv: reenable rewrite concurrency and add format error checking r=jbowens a=sumeerbhola

Epic: none

Fixes: #97076

Release note: None

Co-authored-by: Jeff <swenson@cockroachlabs.com>
Co-authored-by: Chengxiong Ruan <chengxiongruan@gmail.com>
Co-authored-by: sumeerbhola <sumeer@cockroachlabs.com>
Migrate the system.lease table to an index that is byte compatible with
a regional by row index. The version gates are intended to follow the
protocol discussed in the comment at the top of
upgrades/system_rbr_indexes.go

Writing to the lease table always occurs throught he kv API. The table
is read via the SQL api. The SQL uses of the system.lease table are
forwards compatible as long as they do not need to read the crdb_region.
Queries that interact with individual leases need to retrieve the
crdb_region and must consult the version gate.

Part of cockroachdb#94843

Release Note: None
@jeffswenson jeffswenson force-pushed the jeffswenson-rbr-lease-migration branch from 42b99ce to ee55464 Compare March 16, 2023 00:49
@jeffswenson
Copy link
Copy Markdown
Collaborator Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Mar 16, 2023

Build succeeded:

@craig craig bot merged commit d6bef5e into cockroachdb:master Mar 16, 2023
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.

3 participants