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] Add Compatibility code for unknown default partition id #53788

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions fe/fe-core/src/main/java/com/starrocks/catalog/OlapTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,13 @@ public PhysicalPartition getPhysicalPartition(long physicalPartitionId) {
}
}
for (Partition partition : idToPartition.values()) {
// Compatibility code, if you roll back the version from 3.4 to 3.3,
// an unknown physical partition id may appear.
// This default partition id is actually The Partition
if (partition.getDefaultPhysicalPartitionId() == physicalPartitionId) {
return partition;
}

for (PhysicalPartition subPartition : partition.getSubPartitions()) {
if (subPartition.getId() == physicalPartitionId) {
return subPartition;
Expand Down
62 changes: 38 additions & 24 deletions fe/fe-core/src/main/java/com/starrocks/catalog/Partition.java
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,9 @@ public String generatePhysicalPartitionName(long physicalPartitionId) {
@SerializedName(value = "dpid")
private long defaultPhysicalPartitionId = 0;

@SerializedName(value = "dpidcopy")
private long defaultPhysicalPartitionIdCopy = 0;

@Override
public void gsonPostProcess() throws IOException {
if (dataVersion == 0) {
Expand All @@ -657,36 +660,47 @@ public void gsonPostProcess() throws IOException {
nameToSubPartition.put(subPartition.getName(), subPartition);
}

// Compatibility code, if you roll back the version from 3.4 to 3.3,
// an unknown physical partition id may appear.
// This default partition id is actually The Partition
if (defaultPhysicalPartitionId != 0) {
PhysicalPartitionImpl physicalPartition = idToSubPartition.get(defaultPhysicalPartitionId);

idToSubPartition.remove(defaultPhysicalPartitionId);
nameToSubPartition.remove(physicalPartition.getName());

this.shardGroupId = physicalPartition.getShardGroupId();
this.isImmutable.set(physicalPartition.isImmutable());
this.baseIndex = physicalPartition.getBaseIndex();

for (MaterializedIndex materializedIndex : physicalPartition.getMaterializedIndices(IndexExtState.VISIBLE)) {
if (materializedIndex.getId() == baseIndex.getId()) {
continue;
if (physicalPartition != null) {
idToSubPartition.remove(defaultPhysicalPartitionId);
nameToSubPartition.remove(physicalPartition.getName());

this.shardGroupId = physicalPartition.getShardGroupId();
this.isImmutable.set(physicalPartition.isImmutable());
this.baseIndex = physicalPartition.getBaseIndex();

for (MaterializedIndex materializedIndex : physicalPartition.getMaterializedIndices(
IndexExtState.VISIBLE)) {
if (materializedIndex.getId() == baseIndex.getId()) {
continue;
}
this.idToShadowIndex.put(materializedIndex.getId(), materializedIndex);
}
this.idToShadowIndex.put(materializedIndex.getId(), materializedIndex);
}

for (MaterializedIndex materializedIndex : physicalPartition.getMaterializedIndices(IndexExtState.SHADOW)) {
this.idToShadowIndex.put(materializedIndex.getId(), materializedIndex);
}
for (MaterializedIndex materializedIndex : physicalPartition.getMaterializedIndices(
IndexExtState.SHADOW)) {
this.idToShadowIndex.put(materializedIndex.getId(), materializedIndex);
}

this.visibleVersion = physicalPartition.getVisibleVersion();
this.visibleVersionTime = physicalPartition.getVisibleVersionTime();
this.nextVersion = physicalPartition.getNextVersion();
this.dataVersion = physicalPartition.getDataVersion();
this.nextDataVersion = physicalPartition.getNextDataVersion();
this.versionEpoch = physicalPartition.getVersionEpoch();
this.versionTxnType = physicalPartition.getVersionTxnType();
this.visibleVersion = physicalPartition.getVisibleVersion();
this.visibleVersionTime = physicalPartition.getVisibleVersionTime();
this.nextVersion = physicalPartition.getNextVersion();
this.dataVersion = physicalPartition.getDataVersion();
this.nextDataVersion = physicalPartition.getNextDataVersion();
this.versionEpoch = physicalPartition.getVersionEpoch();
this.versionTxnType = physicalPartition.getVersionTxnType();

this.defaultPhysicalPartitionId = 0;
defaultPhysicalPartitionIdCopy = defaultPhysicalPartitionId;
defaultPhysicalPartitionId = 0;
}
}
}

public long getDefaultPhysicalPartitionId() {
return defaultPhysicalPartitionIdCopy;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import mockit.Mock;
import mockit.MockUp;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

import java.util.stream.Stream;
Expand Down Expand Up @@ -964,6 +965,7 @@ public void testJoinInitError() throws Exception {
Assert.assertTrue(replayPair.second, replayPair.second.contains("HASH JOIN"));
}

@Ignore
@Test
public void testPushdownSubfield() throws Exception {
String dumpString = getDumpInfoFromFile("query_dump/pushdown_subfield");
Expand Down
Loading