|
45 | 45 | import com.starrocks.catalog.MaterializedIndex; |
46 | 46 | import com.starrocks.catalog.OlapTable; |
47 | 47 | import com.starrocks.catalog.Partition; |
| 48 | +import com.starrocks.catalog.Replica; |
48 | 49 | import com.starrocks.catalog.Replica.ReplicaState; |
| 50 | +import com.starrocks.catalog.Tablet; |
49 | 51 | import com.starrocks.common.Config; |
50 | 52 | import com.starrocks.common.TraceManager; |
51 | 53 | import com.starrocks.common.UserException; |
@@ -386,6 +388,28 @@ public void setTabletCommitInfos(List<TabletCommitInfo> infos) { |
386 | 388 | this.tabletCommitInfos.addAll(infos); |
387 | 389 | } |
388 | 390 |
|
| 391 | + public boolean checkReplicaNeedSkip(Tablet tablet, Replica replica, PartitionCommitInfo partitionCommitInfo) { |
| 392 | + boolean isContain = tabletCommitInfosContainsReplica(tablet.getId(), replica.getBackendId(), replica.getState()); |
| 393 | + if (isContain) { |
| 394 | + return false; |
| 395 | + } |
| 396 | + |
| 397 | + // In order for the transaction to complete in time for this scenario: the server machine is not recovered. |
| 398 | + // 1. Transaction TA writes to a two-replicas tablet and enters the committed state. |
| 399 | + // The tablet's repliace are replicaA, replicaB. |
| 400 | + // 2. replicaA, replicaB generate tasks: PublishVersionTaskA, PublishVersionTaskB. |
| 401 | + // PublishVersionTaskA/PublishVersionTaskB successfully submitted to the beA/beB via RPC. |
| 402 | + // 3. The machine where beB is located hangs and is not recoverable. |
| 403 | + // Therefore PublishVersionTaskA is finished,PublishVersionTaskB is unfinished. |
| 404 | + // 4. FE clone replicaC from replicaA, BE report replicaC info. |
| 405 | + // So transactions must rely on replicaA and replicaC to accomplish visible state. |
| 406 | + if (replica.getVersion() >= partitionCommitInfo.getVersion()) { |
| 407 | + return false; |
| 408 | + } |
| 409 | + |
| 410 | + return true; |
| 411 | + } |
| 412 | + |
389 | 413 | public boolean tabletCommitInfosContainsReplica(long tabletId, long backendId, ReplicaState state) { |
390 | 414 | TabletCommitInfo info = new TabletCommitInfo(tabletId, backendId); |
391 | 415 | if (this.tabletCommitInfos == null) { |
|
0 commit comments