Skip to content

Commit

Permalink
[BugFix] Revert "[Enhancement] Remove partition directory with retry …
Browse files Browse the repository at this point in the history
…in shared data clusters (backport #41675) (#42483)" (#43221)
  • Loading branch information
sduzh committed Mar 27, 2024
1 parent 8da5e3b commit 8eea580
Show file tree
Hide file tree
Showing 37 changed files with 649 additions and 1,342 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public void updatePartitionTabletMeta(Database db,
addDirtyPartitionIndex(partition.getId(), index.getId(), index);
int schemaHash = olapTable.getSchemaHashByIndexId(index.getId());
for (Tablet tablet : index.getTablets()) {
Long backendId = Utils.chooseNodeId((LakeTablet) tablet);
Long backendId = Utils.chooseBackend((LakeTablet) tablet);
Set<Pair<Long, Integer>> tabletIdWithHash =
beIdToTabletIdWithHash.computeIfAbsent(backendId, k -> Sets.newHashSet());
tabletIdWithHash.add(new Pair<>(tablet.getId(), schemaHash));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ protected void runPendingJob() throws AlterCancelException {
for (Tablet shadowTablet : shadowIdx.getTablets()) {
long shadowTabletId = shadowTablet.getId();
LakeTablet lakeTablet = ((LakeTablet) shadowTablet);
Long backendId = Utils.chooseNodeId(lakeTablet);
Long backendId = Utils.chooseBackend(lakeTablet);
if (backendId == null) {
throw new AlterCancelException("No alive backend");
}
Expand Down Expand Up @@ -441,7 +441,7 @@ protected void runWaitingTxnJob() throws AlterCancelException {
long shadowIdxId = entry.getKey();
MaterializedIndex shadowIdx = entry.getValue();
for (Tablet shadowTablet : shadowIdx.getTablets()) {
Long backendId = Utils.chooseNodeId((LakeTablet) shadowTablet);
Long backendId = Utils.chooseBackend((LakeTablet) shadowTablet);
if (backendId == null) {
throw new AlterCancelException("No alive backend");
}
Expand Down
313 changes: 256 additions & 57 deletions fe/fe-core/src/main/java/com/starrocks/catalog/CatalogRecycleBin.java

Large diffs are not rendered by default.

74 changes: 39 additions & 35 deletions fe/fe-core/src/main/java/com/starrocks/catalog/OlapTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -969,41 +969,45 @@ public void addPartition(Partition partition) {
// This is a private method.
// Call public "dropPartitionAndReserveTablet" and "dropPartition"
private void dropPartition(long dbId, String partitionName, boolean isForceDrop, boolean reserveTablets) {
// 1. If "isForceDrop" is false, the partition will be added to the GlobalStateMgr Recyle bin, and all tablets of this
// partition will not be deleted.
// 2. If "ifForceDrop" is true, the partition will be dropped the immediately, but whether to drop the tablets
// of this partition depends on "reserveTablets"
// If "reserveTablets" is true, the tablets of this partition will not to delete.
// Otherwise, the tablets of this partition will be deleted immediately.
Partition partition = nameToPartition.get(partitionName);
if (partition == null) {
return;
}

if (!reserveTablets) {
RecyclePartitionInfo recyclePartitionInfo = buildRecyclePartitionInfo(dbId, partition);
recyclePartitionInfo.setRecoverable(!isForceDrop);
GlobalStateMgr.getCurrentState().getRecycleBin().recyclePartition(recyclePartitionInfo);
}

partitionInfo.dropPartition(partition.getId());
idToPartition.remove(partition.getId());
nameToPartition.remove(partitionName);

GlobalStateMgr.getCurrentState().getAnalyzeMgr().dropPartition(partition.getId());
}

protected RecyclePartitionInfo buildRecyclePartitionInfo(long dbId, Partition partition) {
if (partitionInfo.isRangePartition()) {
RangePartitionInfo rangePartitionInfo = (RangePartitionInfo) partitionInfo;
return new RecycleRangePartitionInfo(dbId, id, partition,
rangePartitionInfo.getRange(partition.getId()),
rangePartitionInfo.getDataProperty(partition.getId()),
rangePartitionInfo.getReplicationNum(partition.getId()),
rangePartitionInfo.getIsInMemory(partition.getId()),
rangePartitionInfo.getDataCacheInfo(partition.getId()));
} else if (partitionInfo.isListPartition()) {
return new RecycleListPartitionInfo(dbId, id, partition,
partitionInfo.getDataProperty(partition.getId()),
partitionInfo.getReplicationNum(partition.getId()),
partitionInfo.getIsInMemory(partition.getId()),
partitionInfo.getDataCacheInfo(partition.getId()));
} else {
throw new RuntimeException("Unknown partition type: " + partitionInfo.getType());
if (partition != null) {
if (partitionInfo.isRangePartition()) {
idToPartition.remove(partition.getId());
nameToPartition.remove(partitionName);
RangePartitionInfo rangePartitionInfo = (RangePartitionInfo) partitionInfo;
if (!isForceDrop) {
// recycle range partition
GlobalStateMgr.getCurrentRecycleBin().recyclePartition(dbId, id, partition,
rangePartitionInfo.getRange(partition.getId()),
rangePartitionInfo.getDataProperty(partition.getId()),
rangePartitionInfo.getReplicationNum(partition.getId()),
rangePartitionInfo.getIsInMemory(partition.getId()),
rangePartitionInfo.getDataCacheInfo(partition.getId()));
} else if (!reserveTablets) {
GlobalStateMgr.getCurrentState().onErasePartition(partition);
}
// drop partition info
rangePartitionInfo.dropPartition(partition.getId());
} else if (partitionInfo.getType() == PartitionType.LIST) {
ListPartitionInfo listPartitionInfo = (ListPartitionInfo) partitionInfo;
if (!isForceDrop) {
throw new SemanticException("List partition does not support recycle bin, " +
"you can use force drop to drop it.");
} else if (!reserveTablets) {
idToPartition.remove(partition.getId());
nameToPartition.remove(partitionName);
GlobalStateMgr.getCurrentState().onErasePartition(partition);
}
// drop partition info
listPartitionInfo.dropPartition(partition.getId());
}
GlobalStateMgr.getCurrentAnalyzeMgr().dropPartition(partition.getId());
}
}

Expand All @@ -1012,7 +1016,7 @@ public void dropPartitionAndReserveTablet(String partitionName) {
}

public void dropPartition(long dbId, String partitionName, boolean isForceDrop) {
dropPartition(dbId, partitionName, isForceDrop, false);
dropPartition(dbId, partitionName, isForceDrop, !isForceDrop);
}

/*
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 8eea580

Please sign in to comment.