On full cluster restart, replicas transaction logs are not getting cleaned, closes #465.
This commit is contained in:
parent
b8fa68f97a
commit
feb854b742
|
@ -464,6 +464,9 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
|||
}
|
||||
scheduleRefresherIfNeeded();
|
||||
engine.refresh(new Engine.Refresh(true));
|
||||
|
||||
// clear unreferenced files
|
||||
translog.clearUnreferenced();
|
||||
}
|
||||
|
||||
public void performRecoveryOperation(Translog.Operation operation) throws ElasticSearchException {
|
||||
|
|
|
@ -87,6 +87,11 @@ public interface Translog extends IndexShardComponent {
|
|||
*/
|
||||
Snapshot snapshot(Snapshot snapshot);
|
||||
|
||||
/**
|
||||
* Clears unreferenced transaclogs.
|
||||
*/
|
||||
void clearUnreferenced();
|
||||
|
||||
/**
|
||||
* Sync's the translog.
|
||||
*/
|
||||
|
|
|
@ -92,6 +92,24 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog
|
|||
return new ByteSizeValue(0, ByteSizeUnit.BYTES);
|
||||
}
|
||||
|
||||
@Override public void clearUnreferenced() {
|
||||
synchronized (mutex) {
|
||||
File[] files = location.listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
if (file.getName().equals("translog-" + id)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
file.delete();
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void newTranslog() throws TranslogException {
|
||||
synchronized (mutex) {
|
||||
operationCounter.set(0);
|
||||
|
|
Loading…
Reference in New Issue