Skip to content

Commit

Permalink
On recovery (startup), the recovery translog file handle is not prope…
Browse files Browse the repository at this point in the history
…rly closed, closes elastic#1866.
  • Loading branch information
kimchy committed Apr 17, 2012
1 parent 78858f4 commit 66454c1
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -19,6 +19,7 @@

package org.elasticsearch.index.gateway.local;

import com.google.common.io.Closeables;
import org.apache.lucene.index.IndexReader;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.io.stream.InputStreamStreamInput;
Expand Down Expand Up @@ -178,8 +179,10 @@ public void recover(boolean indexShouldExists, RecoveryStatus recoveryStatus) th

recoveryStatus.translog().startTime(System.currentTimeMillis());
recoveryStatus.updateStage(RecoveryStatus.Stage.TRANSLOG);
FileInputStream fs = null;
try {
InputStreamStreamInput si = new InputStreamStreamInput(new FileInputStream(recoveringTranslogFile));
fs = new FileInputStream(recoveringTranslogFile);
InputStreamStreamInput si = new InputStreamStreamInput(fs);
while (true) {
Translog.Operation operation;
try {
Expand All @@ -199,6 +202,8 @@ public void recover(boolean indexShouldExists, RecoveryStatus recoveryStatus) th
// we failed to recovery, make sure to delete the translog file (and keep the recovering one)
indexShard.translog().close(true);
throw new IndexShardGatewayRecoveryException(shardId, "failed to recover shard", e);
} finally {
Closeables.closeQuietly(fs);
}
indexShard.performRecoveryFinalization(true);

Expand Down

0 comments on commit 66454c1

Please sign in to comment.