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

add feature and fix bugs #148

Merged
merged 4 commits into from
Nov 30, 2017
Merged
Changes from 1 commit
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
Prev Previous commit
fix bugs when try to schema change a clone replica
  • Loading branch information
morningman-cmy committed Nov 30, 2017
commit c36244560c2c7d51951a027278a800e23b14a6bb
28 changes: 24 additions & 4 deletions fe/src/com/baidu/palo/alter/SchemaChangeJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
import com.baidu.palo.catalog.Database;
import com.baidu.palo.catalog.KeysType;
import com.baidu.palo.catalog.MaterializedIndex;
import com.baidu.palo.catalog.MaterializedIndex.IndexState;
import com.baidu.palo.catalog.OlapTable;
import com.baidu.palo.catalog.OlapTable.OlapTableState;
import com.baidu.palo.catalog.Partition;
import com.baidu.palo.catalog.Partition.PartitionState;
import com.baidu.palo.catalog.Replica;
import com.baidu.palo.catalog.Replica.ReplicaState;
import com.baidu.palo.catalog.Table;
import com.baidu.palo.catalog.Tablet;
import com.baidu.palo.catalog.MaterializedIndex.IndexState;
import com.baidu.palo.catalog.OlapTable.OlapTableState;
import com.baidu.palo.catalog.Partition.PartitionState;
import com.baidu.palo.catalog.Replica.ReplicaState;
import com.baidu.palo.common.Config;
import com.baidu.palo.common.FeMetaVersion;
import com.baidu.palo.common.MetaNotFoundException;
Expand Down Expand Up @@ -313,6 +313,7 @@ public boolean sendTasks() {
List<AgentTask> tasks = new LinkedList<AgentTask>();
for (Partition partition : olapTable.getPartitions()) {
long partitionId = partition.getId();
short replicationNum = olapTable.getPartitionInfo().getReplicationNum(partitionId);
for (Long indexId : this.changedIndexIdToSchema.keySet()) {
MaterializedIndex alterIndex = partition.getIndex(indexId);
if (alterIndex == null) {
Expand Down Expand Up @@ -340,7 +341,15 @@ public boolean sendTasks() {

for (Tablet tablet : alterIndex.getTablets()) {
long tabletId = tablet.getId();
short replicaSendNum = 0;
for (Replica replica : tablet.getReplicas()) {
if (replica.getState() == ReplicaState.CLONE) {
// There may be MIGRATION or SUPPLEMENT clone replica generated
// before starting this schema change job.
// And we cannot add schema change task to this clone replica.
// So here we skip it.
continue;
}
long backendId = replica.getBackendId();
long replicaId = replica.getId();
SchemaChangeTask schemaChangeTask =
Expand All @@ -351,6 +360,17 @@ public boolean sendTasks() {
storageType, bfColumns, bfFpp, schemaChangeKeysType);
addReplicaId(indexId, replicaId, backendId);
tasks.add(schemaChangeTask);
replicaSendNum++;
}

if (replicaSendNum < replicationNum / 2 + 1) {
// In the case that quorum num of non-NORMAL replica(probably CLONE)
// in this tablet, schema change job can not finish.
// So cancel it.
cancelMsg = String.format("num of normal replica in tablet %d is less than quorum num",
tabletId);
LOG.warn(cancelMsg);
return false;
}
} // end for tablets
} // end for alter indices
Expand Down