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

[BugFix] Recalculate max_continuous_version after schema change finished (backport #28473) #28512

Closed
wants to merge 1 commit into from

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Aug 2, 2023

This is an automatic backport of pull request #28473 done by Mergify.
Cherry-pick of bbedba4 has failed:

On branch mergify/bp/branch-2.5/pr-28473
Your branch is up to date with 'origin/branch-2.5'.

You are currently cherry-picking commit bbedba49f0.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   be/src/storage/schema_change.cpp
	modified:   be/src/storage/version_graph.cpp
	modified:   be/src/storage/version_graph.h

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   be/src/storage/tablet.h

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/github/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally


Mergify commands and options

More conditions and actions can be found in the documentation.

You can also trigger Mergify actions by commenting on this pull request:

  • @Mergifyio refresh will re-evaluate the rules
  • @Mergifyio rebase will rebase this PR on its base branch
  • @Mergifyio update will merge the base branch into this PR
  • @Mergifyio backport <destination> will backport this PR on <destination> branch

Additionally, on Mergify dashboard you can:

  • look at your merge queues
  • generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com

…hed (#28473)

We will create a new tablet for each original tablet and we will write
original tablet and new tablet during schema change. We will construct a
`version_graph` to keep versions info for each table and the following
code is how to update `version_graph`:
```
void VersionGraph::add_version_to_graph(const Version& version) {
    _add_version_to_graph(version);
    if (version.first == _max_continuous_version + 1) {
        _max_continuous_version = _get_max_continuous_version_from(_max_continuous_version + 1);
    } else if (version.first == 0) {
        // We need to reconstruct max_continuous_version from zero if input version is starting from zero
        // e.g.
        // 1. Tablet A is doing schema change
        // 2. We create a new tablet B releated A, and we will create a initial rowset and _max_continuous_version
        //    will be updated to 1
        // 3. Tablet A has a rowset R with version (0, m)
        // 4. Schema change will try convert R
        // 5. The start version of R (0) is not equal to `_max_continuous_version + 1`, and the _max_continuous_version
        //    will not update
        _max_continuous_version = _get_max_continuous_version_from(0);
    }
}
```
There exists a scenario where _max_continuous_version cannot be updated
correctly
e.g.
1. create a new tablet `t2` for origin tablet `t1` during schema change
and `t2` has version 91,92,93,95,96,97,98. version 94 write failed.
2. when running schema change job, alter version is 98 and `t1` has
version [0-90], [91-96], 97, 98
3. `max_continuous_version` of `t2` is 0 before convert rowset. After
convert version [0-90], `max_continuous_version` is update to 93 because
`t2` has version 91-93 before.
4. `max_continuous_version` don't update because the left rowsets
version is not satisfy update condition(version.fisrt == 0 or
version.first == _max_continuous_verison + 1). So the
`max_continuous_version` will keep 93 after convert rowset finished.
5. we will check the max_continuous_version of `t2` at last and it
should not less than alter version. But max_continuous_version(93) is
less than alter version(98), so the alter job failed at last.

The main reason is we don't update `_max_continuous_version` correctly
during alter job, we should recalculate the `max_continuous_version`
after rowset conversion.
---------

Signed-off-by: zhangqiang <[email protected]>
(cherry picked from commit bbedba4)

# Conflicts:
#	be/src/storage/tablet.h
@mergify mergify bot added the conflicts label Aug 2, 2023
@wanpengfei-git wanpengfei-git enabled auto-merge (rebase) August 2, 2023 10:11
@mergify mergify bot closed this Aug 2, 2023
auto-merge was automatically disabled August 2, 2023 10:11

Pull request was closed

@mergify
Copy link
Contributor Author

mergify bot commented Aug 2, 2023

@mergify[bot]: Backport conflict, please reslove the conflict and resubmit the pr

@mergify mergify bot deleted the mergify/bp/branch-2.5/pr-28473 branch August 2, 2023 10:11
@wanpengfei-git
Copy link
Collaborator

[FE PR Coverage Check]

😍 pass : 0 / 0 (0%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants