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

sql: mark index as GCed if table has been GCed in legacy gc path #99888

Merged

Conversation

chengxiong-ruan
Copy link
Contributor

@chengxiong-ruan chengxiong-ruan commented Mar 29, 2023

Previously, if a table is GCed before an index is GCed by a TRUNCATE TABLE gc job, the TRUNCATE TABLE gc job can be stuck in running status because the table descriptor is missing. This is problematic because these jobs will never succeed and doing nothing. This commit marks the indexes as GCed if the descriptor cannot be found assuming that the table has been GCed. Also, table GC should have GCed all the indexes.

Note that this only affect the legacy GC path.

Epic: None

Release note (bug fix): This commit fixes a bug where TRUNCATE TABLE gc job can be stuck in running status if table descriptor has been GCed before the truncated indexes are GCed. The bug was only a problem before DelRange is not available.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@chengxiong-ruan chengxiong-ruan added backport-23.1.x Flags PRs that need to be backported to 23.1 backport-22.2.x labels Mar 29, 2023
@chengxiong-ruan chengxiong-ruan marked this pull request as ready for review March 29, 2023 02:22
@chengxiong-ruan chengxiong-ruan requested a review from a team March 29, 2023 02:22
Copy link
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.

:lgtm:

Reviewed 3 of 3 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @chengxiong-ruan)


-- commits line 17 at r1:
I think you should update the release note to say something also about dropped indexes. Also, don't say anything about DelRange, folks don't know what this is, and we don't really document it much. It's fine to not tell people about the edge case (they flipped un undocumented cluster setting) that might have made the bug not apply.

@rafiss
Copy link
Collaborator

rafiss commented Mar 29, 2023

nit: I think this should be marked as a bug fix in the release note, rather than a SQL change.

Previously, if a table is GCed before an index is GCed by a TRUNCATE TABLE
gc job, the TRUNCATE TABLE gc job can be stuck in running status because
the table descriptor is missing. This is problematic because these jobs will
never succeed and doing nothing. This commit marks the indexes as GCed if
the descriptor cannot be found assuming that the table has been GCed. Also,
table GC should have GCed all the indexes.

Note that this only affect the legacy GC path.

Epic: None

Release note (bug fix): This commit fixes a bug where TRUNCATE TABLE gc
job can be stuck in running status if the table descriptor has been GCed.
It was because TRUNCATE TABLE actually creates new empty indexes, then
replaces and drops the old indexes. The dropped indexes data are deleted
and GCed within the TRUNCATE TABLE gc job which needed to see the table
descriptor to make progress. But, if the table data has been GCed, the
TRUNCATE TABLE gc job couldn't make progress. This patch makes it able
to handle the missing descriptor edge case and let the TRUNCATE TABLE
gc job succeed.
@chengxiong-ruan chengxiong-ruan force-pushed the mark-index-gced-if-table-gced branch from 9f623c7 to a22ef53 Compare March 29, 2023 14:05
@chengxiong-ruan
Copy link
Contributor Author

I've updated the release. Thanks for the good calls.

@chengxiong-ruan
Copy link
Contributor Author

TFTR!
bors r+

@craig
Copy link
Contributor

craig bot commented Mar 30, 2023

Build succeeded:

@blathers-crl
Copy link

blathers-crl bot commented Mar 30, 2023

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from a22ef53 to blathers/backport-release-22.1-99888: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.1.x failed. See errors above.


error creating merge commit from a22ef53 to blathers/backport-release-22.2-99888: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.2.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-23.1.x Flags PRs that need to be backported to 23.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants