Skip to content
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

upgrades,sql: alter system.comments table primary key #91060

Conversation

chengxiong-ruan
Copy link
Contributor

Part of #88571

We need to read and write system.comments through kv.Batch if we want extend the uncommitted layer of collection to cache original comments and changes to comments, and be able to write changes to comments together with other mutations to descriptor in same transaction. To achieve that it'd be more convenient to have the descriptor id as the first column of primary key, so that we can construct a kv key like /commentsTableID/descID to fetch all comments of an object. Otherwise we'd need to loop through all comment types.

We're lucky that none of the existing code really rely on the old primary key column order.

Release note: None

@chengxiong-ruan chengxiong-ruan requested a review from a team November 1, 2022 14:47
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Part of cockroachdb#88571

We need to read and write `system.comments` through `kv.Batch`
if we want extend the `uncommitted` layer of collection to cache
original comments and changes to comments, and be able to write
changes to comments together with other mutations to descriptor
in same transaction. To achieve that it'd be more convenient to
have the descriptor id as the first column of primary key, so that
we can construct a kv key like `/commentsTableID/descID` to fetch
all comments of an object. Otherwise we'd need to loop through
all comment types.

We're lucky that none of the existing code really rely on the old
primary key column order.

Release note: None
@chengxiong-ruan chengxiong-ruan force-pushed the alter-system-comments-primary-key branch from 3d76422 to 95baec0 Compare November 1, 2022 17:17
@chengxiong-ruan
Copy link
Contributor Author

hmmm...altering a primary key creates a new primary key but with different index id, which means pk index id would be different between clusters upgraded to this version and clusters bootstrapped with this version >_> . This would make the kv scan/write confusing. I can live with the old primary key. Closing this PR....

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.

2 participants