From 84282e15e08e60ba0112f62172bcdb5f0e8a2ae7 Mon Sep 17 00:00:00 2001 From: yujun Date: Mon, 26 Aug 2024 21:26:01 +0800 Subject: [PATCH] [fix](replay) fix replay ReplicaPersistInfo no update lastFailedVersion and lastSuccVersion (#39918) --- .../doris/datasource/InternalCatalog.java | 3 +- .../test_clone_no_missing_version.groovy | 78 +++++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 regression-test/suites/clone_p0/test_clone_no_missing_version.groovy diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java index 732776832a213d..1fb8826903bcb7 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java @@ -1071,7 +1071,8 @@ private void unprotectUpdateReplica(OlapTable olapTable, ReplicaPersistInfo info Tablet tablet = materializedIndex.getTablet(info.getTabletId()); Replica replica = tablet.getReplicaById(info.getReplicaId()); Preconditions.checkNotNull(replica, info); - replica.updateVersion(info.getVersion()); + replica.updateVersionWithFailed(info.getVersion(), info.getLastFailedVersion(), + info.getLastSuccessVersion()); replica.setDataSize(info.getDataSize()); replica.setRemoteDataSize(info.getRemoteDataSize()); replica.setRowCount(info.getRowCount()); diff --git a/regression-test/suites/clone_p0/test_clone_no_missing_version.groovy b/regression-test/suites/clone_p0/test_clone_no_missing_version.groovy new file mode 100644 index 00000000000000..75eb3866ec8302 --- /dev/null +++ b/regression-test/suites/clone_p0/test_clone_no_missing_version.groovy @@ -0,0 +1,78 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import org.apache.doris.regression.suite.ClusterOptions +import org.apache.doris.regression.util.NodeType + +suite('test_clone_no_missing_version') { + def tbl = 'tbl_test_clone_no_missing_version' + def options = new ClusterOptions() + options.feConfigs += [ + 'disable_tablet_scheduler=true', + 'tablet_checker_interval_ms=500', + 'schedule_batch_size=1000', + 'schedule_slot_num_per_hdd_path=1000', + ] + options.beConfigs += [ + 'report_tablet_interval_seconds=100000', // don't report tablets + ] + + options.feNum = 3 + options.cloudMode = false + options.connectToFollower = true + + docker(options) { + sql '''SET forward_to_master = false''' + + sql """ + CREATE TABLE ${tbl} (k INT) DISTRIBUTED BY HASH(k) BUCKETS 1; + """ + + sql """INSERT INTO ${tbl} VALUES (1) """ + sql """INSERT INTO ${tbl} VALUES (2) """ + + def tablets = sql_return_maparray "SHOW TABLETS FROM ${tbl}" + assertEquals(3, tablets.size()) + + def originTablet = tablets[0] + + sql """ ADMIN SET REPLICA VERSION PROPERTIES ( + "tablet_id" = "${originTablet.TabletId}", "backend_id" = "${originTablet.BackendId}", + "version" = "3", "last_failed_version" = "4" + ); """ + + def checkTabletIsGood = { good -> + def changedTablet = sql_return_maparray("SHOW TABLETS FROM ${tbl}").find { it.BackendId == originTablet.BackendId } + assertNotNull(changedTablet) + assertEquals(3L, changedTablet.Version.toLong()) + if (good) { + assertEquals(-1L, changedTablet.LstFailedVersion.toLong()) + } else { + assertEquals(4L, changedTablet.LstFailedVersion.toLong()) + } + } + + sleep 1000 + + checkTabletIsGood(false) + + sql "ADMIN SET FRONTEND CONFIG ('disable_tablet_scheduler' = 'false')" + + sleep 5000 + checkTabletIsGood(true) + } +}