-
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
sql: adding version gates for changes related to JSON forward indexes #101932
sql: adding version gates for changes related to JSON forward indexes #101932
Conversation
b52df42
to
e2f02db
Compare
3671e0b
to
5e32b80
Compare
@@ -23,7 +23,7 @@ upgrade 1 | |||
query B | |||
SELECT crdb_internal.node_executable_version() SIMILAR TO '1000023.1-%' | |||
---- | |||
true | |||
false |
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.
we shouldn't just rewrite these to false. instead, change the assertion so it's SIMILAR TO 1000023.2-%
b3790b9
to
a9401c3
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 @fqazi, @mgartner, and @rafiss)
pkg/sql/logictest/testdata/logic_test/mixed_version_can_login
line 26 at r1 (raw file):
Previously, rafiss (Rafi Shamim) wrote…
we shouldn't just rewrite these to false. instead, change the assertion so it's
SIMILAR TO 1000023.2-%
I don't think this is required anymore since the new version to be added still has the minor
number to be set to 1
. Thus, running this test with 1000023.1 worked unless this itself is wrong.
1e16696
to
107903c
Compare
f342320
to
e287ba9
Compare
pkg/upgrade/upgrades/upgrades.go
Outdated
"enable JSON forward indexes and ORDER BY on JSON columns", | ||
toCV(clusterversion.V23_2_JSONForwardIndexes), | ||
upgrade.NoPrecondition, | ||
NoTenantUpgradeFunc, |
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.
why do we need an upgrade at all?
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 @dt, @fqazi, @mgartner, and @rafiss)
pkg/upgrade/upgrades/upgrades.go
line 317 at r2 (raw file):
Previously, dt (David Taylor) wrote…
why do we need an upgrade at all?
Not sure if I understand your question to the fullest, but do you mean why we need an upgrade to this version? I believe this is required since each node in a given cluster has to be at this specific cluster version before it can start ordering/creating forward indexes on JSON columns. Thus, I wanted to add some checks in the code based on the cluster version number.
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.
It isn't clear to me that this needs a new version minted versus just having the usage gates be on IsActive(V23_1) ?
Either way, even if it does need to mint a new version, then I don't think you need the no-op upgrade.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @fqazi, @mgartner, 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.
@dt We haven't backported Shiv's JSON forward index support to 23.1 and only plan to have it available on 23.2. Please correct me if I'm wrong, but my understanding is that gating on IsActive(V23_1)
would allow usage on 23.1, which is not what we want. I could see gating on IsActive(V23_2)
, except it seems we're at a point in this release cycle where that version hasn't been created yet.
Gating this feature, which doesn't require any upgrade steps, correctly has been confusing, so we're happy to get input on the best way to do it.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @dt, @fqazi, @mgartner, 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.
TIL Thank you!
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @dt, @fqazi, @mgartner, and @rafiss)
5ee49ff
to
676c402
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.
Thank for the great pointers everyone! The changes have been made and it is RFAL!
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @dt, @fqazi, @mgartner, and @rafiss)
// Setting an older cluster version and expecting an error when creating | ||
// forward indexes on JSON columns. | ||
_, err = tc.Conns[0].ExecContext(ctx, `SET CLUSTER SETTING version = $1`, | ||
clusterversion.ByKey(clusterversion.V23_1WebSessionsTableHasUserIDColumn).String()) |
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.
can this just be V23_1?
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 @dt, @fqazi, @mgartner, @rafiss, and @Shivs11)
pkg/upgrade/upgrades/json_forward_indexes_test.go
line 27 at r4 (raw file):
) func TestJSONForwardingIndexes(t *testing.T) {
I was thinking about how what is really desirable to test is mixed versions -- which the version upgrade tests do, and happened to see Renato's fix for the version upgrade test that was failing with json forward indexes: https://github.com/cockroachdb/cockroach/pull/101638/files
There's a small bug there, which is that we should check for V23_2, not V23_1, for json forwarding indexes. If you have time do you mind adding a fix in this PR or a new one?
pkg/upgrade/upgrades/json_forward_indexes_test.go
line 83 at r4 (raw file):
)`) require.Error(t, err)
Can we also upgrade to 23.2 here and check that the previous commands succeed?
676c402
to
a7ecb81
Compare
1f534a6
to
30fc318
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.
I'm picking up Shiv's PR to bring it over the finish line. I added the version gate for JSON forward indexes to the declarative schema changer (which supports CREATE INDEX as of 23.1) and a minor fix to operation_generator since JSON forward indexes are enabled in a different version than ARRAY. PTAL!
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @dt, @fqazi, @mgartner, @rafiss, @smg260, and @srosenberg)
pkg/upgrade/upgrades/json_forward_indexes_test.go
line 27 at r4 (raw file):
Previously, rharding6373 (Rachael Harding) wrote…
I was thinking about how what is really desirable to test is mixed versions -- which the version upgrade tests do, and happened to see Renato's fix for the version upgrade test that was failing with json forward indexes: https://github.com/cockroachdb/cockroach/pull/101638/files
There's a small bug there, which is that we should check for V23_2, not V23_1, for json forwarding indexes. If you have time do you mind adding a fix in this PR or a new one?
Done.
pkg/upgrade/upgrades/json_forward_indexes_test.go
line 58 at r4 (raw file):
Previously, dt (David Taylor) wrote…
can this just be V23_1?
Thanks for the suggestion. We found that it couldn't, and it took us a long time to realize it was because create index uses the declarative schema changer in 23.1 and therefore a different path to create the index that we hadn't protected with the version gate. We now have tests for V22_2 and V23_1 to cover both possible paths.
pkg/upgrade/upgrades/json_forward_indexes_test.go
line 83 at r4 (raw file):
Previously, rharding6373 (Rachael Harding) wrote…
Can we also upgrade to 23.2 here and check that the previous commands succeed?
Done.
Previously, cockroachdb#99275 and cockroachdb#97928 were responsible for laying the foundations of a JSON lexicographical order as well as enabling JSON forward indexes in CRDB. However, these commits did not account for version gates. In a given cluster, all of its nodes are required to be at a certain version number for creating JSON forward indexes as well as for ordering JSON columns. Thus, this PR aims to enable version gates for ensuring all nodes in a given cluster meet this requirement. Epic: CRDB-24501 Fixes: cockroachdb#35706 Release note (sql change): This PR adds version gates which requires all nodes in a given cluster to have a minimum binary version number which in turn is required for creating forward indexes on JSON columns and for ordering JSON columns.
30fc318
to
33a903e
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.
Turns out someone already fixed operation_generator since I last reviewed this :-) RFAL!
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @dt, @fqazi, @mgartner, @rafiss, @smg260, and @srosenberg)
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.
Reviewed 3 of 19 files at r1, 1 of 2 files at r6, 6 of 6 files at r8, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @dt, @mgartner, and @rafiss)
Last call for comments! If there are no objections I will try to merge this EOD. |
bors r=fqazi |
Build succeeded: |
Previously, #99275 and #97928 were responsible for laying the
foundations of a JSON lexicographical order as well as enabling JSON
forward indexes in CRDB. However, these commits did not account for
version gates. In a given cluster, all of its nodes are required to be
at a certain version number for creating JSON forward indexes as well as
for ordering JSON columns. Thus, this PR aims to enable version gates
for ensuring all nodes in a given cluster meet this requirement.
Epic: CRDB-24501
Fixes: #35706
Release note (sql change): This PR adds version gates which requires all
nodes in a given cluster to have a minimum binary version number which
in turn is required for creating forward indexes on JSON columns and for
ordering JSON columns.