Skip to content

[dnm] use clusterversion.Refer to tie arbitrary code to cluster versions#90428

Closed
tbg wants to merge 1 commit intocockroachdb:masterfrom
tbg:deprecation-poc
Closed

[dnm] use clusterversion.Refer to tie arbitrary code to cluster versions#90428
tbg wants to merge 1 commit intocockroachdb:masterfrom
tbg:deprecation-poc

Conversation

@tbg
Copy link
Copy Markdown
Member

@tbg tbg commented Oct 21, 2022

Release note: None

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@tbg tbg changed the title [dnm] use clusterversion.Refer to arbitrary code to cluster versions [dnm] use clusterversion.Refer to tie arbitrary code to cluster versions Oct 21, 2022
// TODO(irfansharif): Remove this field in the release after the one where we
// stop consulting the protobuf copy of the replica state when applying a
// snapshot.
// This field can be removed together with
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The comment here is interesting, btw. We thought we had figured out when this was safe to remove, but it wasn't actually true yet. No amount of version gating would've fixed that.

import "github.com/cockroachdb/cockroach/pkg/clusterversion"

func init() {
// In the real world, when the field below was deprecated, we'd have
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2¢: Eh, I donno if I agree with this comment's assertion that we should be linking to a named version?

Let's say that ReplicaState{}.DeprecatedUsingAppliedStateKey is still referenced by/used by 22.1, so we need to keep it as long as 22.1 is in the cluster, but can get rid of it once we're on 22.2+ binaries (i.e. the cluster verison is >22.1).

In that case, I'd Refer to to clusterversion.V22_1, since that's the maximum version where we still need the field, and when we delete that version, we can delete the field.

@dt
Copy link
Copy Markdown
Contributor

dt commented Oct 26, 2022

@tbg You inclined to de-DNM this and merge it? I think it's a good pattern to push. My only suggestion would be to extend the comment on Refer with an example, and adjust example usage, in which Refer points to the minimum final version where the field is still used rather than a named intermediate upgrade version, i.e. Refer(clusterversion.V22_2, myCoolField) if the field is unused after the upgrade from 22.2 to 23.1

Copy link
Copy Markdown
Collaborator

@celiala celiala left a comment

Choose a reason for hiding this comment

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

I couldn't tell if we really wanted to tie ReplicaState{}.DeprecatedUsingAppliedStateKey to clusterversion.Start22_2, or if this was purely an example to show how .Refer() might work. So I pulled this .Refer() example, along with @dt 's suggestions of adding examples into a separate PR.

Would appreciate a look to ensure I've captured everyone's suggestions:

#90818

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @dt and @tbg)

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.

4 participants