Skip to content

Commit

Permalink
[fix](restore) Reset next version for remote table when restore (#40118)
Browse files Browse the repository at this point in the history
We should reset next version to visible version + 1 for all partitions
of remote table, when restoring table that do not exist locally.

在高并发insert场景,CCR源端表的next version可能比visible
version大比较多,目标集群restore全量快照后,切换到增量binlog后,commit事务时使用的version(来自next
version)就可能比当前visible version大比较多。

此时,对于MoW表,就会出现publish
version不连续,增量binlog一直无法publish的问题。事务状态会一直是`COMMITTED`,并伴随类似ErrMsg `wait
for publishing partition 15027 version 1037597. self version: 1037627.
table 15025`。
  • Loading branch information
smallx authored and w41ter committed Aug 30, 2024
1 parent d6ee2ff commit 1bd9c40
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,9 @@ private void checkAndPrepareMeta() {
return;
}

// reset next version to visible version + 1 for all partitions
remoteOlapTbl.resetVersionForRestore();

// Reset properties to correct values.
remoteOlapTbl.resetPropertiesForRestore(reserveDynamicPartitionEnable, reserveReplica,
replicaAlloc, isBeingSynced);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,12 @@ public void resetPropertiesForRestore(boolean reserveDynamicPartitionEnable, boo
setColocateGroup(null);
}

public void resetVersionForRestore() {
for (Partition partition : idToPartition.values()) {
partition.setNextVersion(partition.getVisibleVersion() + 1);
}
}

public Status resetIdsForRestore(Env env, Database db, ReplicaAllocation restoreReplicaAlloc,
boolean reserveReplica, String srcDbName) {
// ATTN: The meta of the restore may come from different clusters, so the
Expand Down

0 comments on commit 1bd9c40

Please sign in to comment.