Fix bug that only REPLICA_MISSING repair need to create a new replica (#590)

This commit is contained in:
Mingyu Chen
2019-01-25 17:56:42 +08:00
committed by GitHub
parent 9d71a930a2
commit 67cdc723ac
2 changed files with 27 additions and 13 deletions

View File

@ -432,7 +432,7 @@ public class SchemaChangeJob extends AlterJob {
// but in case some edge cases are not took into consideration, we cancel
// the schema change job here.
cancelMsg = String.format(
"replica %d of tablet %d in backend %d state is invalid: %s",
"replica %d of tablet %d in backend %d state is invalid: %s [send]",
replica.getId(), tablet.getId(), replica.getBackendId(),
replica.getState().name());
LOG.warn(cancelMsg);
@ -688,7 +688,7 @@ public class SchemaChangeJob extends AlterJob {
if (replica.getState() != ReplicaState.SCHEMA_CHANGE) {
// all replicas should be in state SCHEMA_CHANGE
cancelMsg = String.format(
"replica %d of tablet %d in backend %d state is invalid: %s",
"replica %d of tablet %d in backend %d state is invalid: %s [try finish]",
replica.getId(), tablet.getId(), replica.getBackendId(),
replica.getState().name());
LOG.warn(cancelMsg);
@ -793,7 +793,7 @@ public class SchemaChangeJob extends AlterJob {
if (replica.getState() != ReplicaState.SCHEMA_CHANGE) {
// all replicas should be in state SCHEMA_CHANGE
cancelMsg = String.format(
"replica %d of tablet %d in backend %d state is invalid: %s",
"replica %d of tablet %d in backend %d state is invalid: %s [finish]",
replica.getId(), tablet.getId(), replica.getBackendId(),
replica.getState().name());
LOG.warn(cancelMsg);

View File

@ -601,16 +601,30 @@ public class TabletSchedCtx implements Comparable<TabletSchedCtx> {
visibleVersion, visibleVersionHash);
cloneTask.setPathHash(srcPathHash, destPathHash);
Replica cloneReplica = new Replica(
Catalog.getCurrentCatalog().getNextId(), destBackendId,
-1 /* version */, 0 /* version hash */, schemaHash,
-1 /* data size */, -1 /* row count */,
ReplicaState.CLONE,
committedVersion, committedVersionHash, /* use committed version as last failed version */
-1 /* last success version */, 0 /* last success version hash */);
// addReplica() method will add this replica to tablet inverted index too.
tablet.addReplica(cloneReplica);
if (tabletStatus == TabletStatus.REPLICA_MISSING || tabletStatus == TabletStatus.REPLICA_MISSING_IN_CLUSTER) {
// only these 2 status need to create a new replica.
Replica cloneReplica = new Replica(
Catalog.getCurrentCatalog().getNextId(), destBackendId,
-1 /* version */, 0 /* version hash */, schemaHash,
-1 /* data size */, -1 /* row count */,
ReplicaState.CLONE,
committedVersion, committedVersionHash, /* use committed version as last failed version */
-1 /* last success version */, 0 /* last success version hash */);
// addReplica() method will add this replica to tablet inverted index too.
tablet.addReplica(cloneReplica);
} else if (tabletStatus == TabletStatus.VERSION_INCOMPLETE) {
// double check
Replica replica = tablet.getReplicaByBackendId(destBackendId);
if (replica == null) {
throw new SchedException(Status.SCHEDULE_FAILED, "dest replica does not exist on BE " + destBackendId);
}
if (replica.getPathHash() != destPathHash) {
throw new SchedException(Status.SCHEDULE_FAILED, "dest replica's path hash is changed. "
+ "current: " + replica.getPathHash() + ", scheduled: " + destPathHash);
}
}
taskTimeoutMs = getApproximateTimeoutMs();