Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public enum Stage {
FAILURE
}

private Stage stage = Stage.INIT;
private volatile Stage stage = Stage.INIT;

private long startTime;

Expand All @@ -68,14 +68,14 @@ public enum Stage {

private volatile boolean aborted;

private String failure;
private volatile String failure;

/**
* Returns current snapshot stage
*
* @return current snapshot stage
*/
public Stage stage() {
public synchronized Stage stage() {
return this.stage;
}

Expand All @@ -84,8 +84,27 @@ public Stage stage() {
*
* @param stage new snapshot stage
*/
public void updateStage(Stage stage) {
public void updateStage(final Stage stage) {
updateStage(stage, null);
}

/**
* Sets new snapshot stage and the reason for the failure if the snapshot
* is in the {@link IndexShardSnapshotStatus.Stage#FAILURE} state
*
* @param stage new snapshot stage
* @param failure the reason for the failure
*/
public synchronized void updateStage(final Stage stage, final String failure) {
this.stage = stage;
this.failure = failure;
}

/**
* Returns the reason for the failure if the snapshot is in the {@link IndexShardSnapshotStatus.Stage#FAILURE} state
*/
public synchronized String failure() {
return failure;
}

/**
Expand Down Expand Up @@ -224,18 +243,4 @@ public void indexVersion(long indexVersion) {
public long indexVersion() {
return indexVersion;
}

/**
* Sets the reason for the failure if the snapshot is in the {@link IndexShardSnapshotStatus.Stage#FAILURE} state
*/
public void failure(String failure) {
this.failure = failure;
}

/**
* Returns the reason for the failure if the snapshot is in the {@link IndexShardSnapshotStatus.Stage#FAILURE} state
*/
public String failure() {
return failure;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,7 @@ public void snapshotShard(IndexShard shard, SnapshotId snapshotId, IndexId index
snapshotStatus.updateStage(IndexShardSnapshotStatus.Stage.DONE);
} catch (Exception e) {
snapshotStatus.time(System.currentTimeMillis() - snapshotStatus.startTime());
snapshotStatus.updateStage(IndexShardSnapshotStatus.Stage.FAILURE);
snapshotStatus.failure(ExceptionsHelper.detailedMessage(e));
snapshotStatus.updateStage(IndexShardSnapshotStatus.Stage.FAILURE,ExceptionsHelper.detailedMessage(e));
if (e instanceof IndexShardSnapshotFailedException) {
throw (IndexShardSnapshotFailedException) e;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ private void processIndexShardSnapshots(ClusterChangedEvent event) {
// running shards is missed, then the snapshot is removed is a subsequent cluster
// state update, which is being processed here
for (IndexShardSnapshotStatus snapshotStatus : entry.getValue().shards.values()) {
if (snapshotStatus.stage() == Stage.INIT || snapshotStatus.stage() == Stage.STARTED) {
Stage stage = snapshotStatus.stage();
if (stage == Stage.INIT || stage == Stage.STARTED) {
snapshotStatus.abort();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,7 @@ public Map<ShardId, IndexShardSnapshotStatus> snapshotShards(final String reposi
SnapshotShardFailure shardFailure = findShardFailure(snapshotInfo.shardFailures(), shardId);
if (shardFailure != null) {
IndexShardSnapshotStatus shardSnapshotStatus = new IndexShardSnapshotStatus();
shardSnapshotStatus.updateStage(IndexShardSnapshotStatus.Stage.FAILURE);
shardSnapshotStatus.failure(shardFailure.reason());
shardSnapshotStatus.updateStage(IndexShardSnapshotStatus.Stage.FAILURE, shardFailure.reason());
shardStatus.put(shardId, shardSnapshotStatus);
} else {
final IndexShardSnapshotStatus shardSnapshotStatus;
Expand All @@ -610,8 +609,7 @@ public Map<ShardId, IndexShardSnapshotStatus> snapshotShards(final String reposi
// a status for the shard to indicate that the shard snapshot
// could not be taken due to partial being set to false.
shardSnapshotStatus = new IndexShardSnapshotStatus();
shardSnapshotStatus.updateStage(IndexShardSnapshotStatus.Stage.FAILURE);
shardSnapshotStatus.failure("skipped");
shardSnapshotStatus.updateStage(IndexShardSnapshotStatus.Stage.FAILURE, "skipped");
} else {
shardSnapshotStatus = repository.getShardSnapshotStatus(
snapshotInfo.snapshotId(),
Expand Down