Skip to content

Commit

Permalink
[BugFix] fix schema change hang when data loading concurrent with sch…
Browse files Browse the repository at this point in the history
…ema change (StarRocks#23456)

Fixes StarRocks#23452
1. Assume there is a partition, current visible version is 13378, and
all loading task is finished.
2. Trigger schema change, it will create new replica, and at the same
time, one loading task is trigger and finished, and it's version is
13379.
3. Before send alter replica request, FE check that all loading task is
finished, but loading task on new create replica haven't finish yet and
V=1, LFV=13379.
4. Alter replica finish on BE, and BE send finish alter replica request
back to FE. When call `handleFinishAlterTask`, `checkState` fail because
LFV != -1.

Signed-off-by: Moonm3n <[email protected]>
  • Loading branch information
luohaha authored and Moonm3n committed May 23, 2023
1 parent 3bd7081 commit b1456ac
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions fe/fe-core/src/main/java/com/starrocks/task/AlterReplicaTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ public TAlterTabletReqV2 toThrift() {
* There are new load jobs after alter task, and at least one of them is succeed on this replica.
* So the replica's version should be larger than X. So we don't need to modify the replica version
* because its already looks like normal.
* Case 3:
* There are new load jobs after alter task, and their version and LFV is smaller or equal to X.
* And because alter request report success, it means that we can increase replica's version to X.
*/
public void handleFinishAlterTask() throws Exception {
Database db = GlobalStateMgr.getCurrentState().getDb(getDbId());
Expand Down Expand Up @@ -227,18 +230,10 @@ public void handleFinishAlterTask() throws Exception {
getVersion());
boolean versionChanged = false;
if (replica.getVersion() <= getVersion()) {
if (replica.getLastFailedVersion() > getVersion()) {
// Case 2.1
replica.updateRowCount(getVersion(), replica.getDataSize(),
replica.getRowCount());
versionChanged = true;
} else {
// Case 1
Preconditions.checkState(replica.getLastFailedVersion() == -1, replica.getLastFailedVersion());
replica.updateRowCount(getVersion(), replica.getDataSize(),
replica.getRowCount());
versionChanged = true;
}
// Case 1, Case 2.1 or Case 3
replica.updateRowCount(getVersion(), replica.getDataSize(),
replica.getRowCount());
versionChanged = true;
}

if (versionChanged) {
Expand Down

0 comments on commit b1456ac

Please sign in to comment.