don't snapshot gateway when cleaning shard
This commit is contained in:
parent
4a2e076c6a
commit
a05c367c5e
|
@ -270,18 +270,21 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void close(boolean delete) {
|
public void snapshotOnClose() {
|
||||||
if (snapshotScheduleFuture != null) {
|
if (snapshotOnClose) {
|
||||||
snapshotScheduleFuture.cancel(true);
|
|
||||||
snapshotScheduleFuture = null;
|
|
||||||
}
|
|
||||||
if (!delete && snapshotOnClose) {
|
|
||||||
try {
|
try {
|
||||||
snapshot("shutdown");
|
snapshot("shutdown");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("failed to snapshot on close", e);
|
logger.warn("failed to snapshot on close", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void close(boolean delete) {
|
||||||
|
if (snapshotScheduleFuture != null) {
|
||||||
|
snapshotScheduleFuture.cancel(true);
|
||||||
|
snapshotScheduleFuture = null;
|
||||||
|
}
|
||||||
// don't really delete the shard gateway if we are *not* primary,
|
// don't really delete the shard gateway if we are *not* primary,
|
||||||
// the primary will close it
|
// the primary will close it
|
||||||
if (!indexShard.routingEntry().primary()) {
|
if (!indexShard.routingEntry().primary()) {
|
||||||
|
|
|
@ -208,7 +208,7 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde
|
||||||
threadPool.cached().execute(new Runnable() {
|
threadPool.cached().execute(new Runnable() {
|
||||||
@Override public void run() {
|
@Override public void run() {
|
||||||
try {
|
try {
|
||||||
deleteShard(shardId, delete, delete);
|
deleteShard(shardId, delete, !delete, delete);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("failed to close shard, delete [{}]", e, delete);
|
logger.warn("failed to close shard, delete [{}]", e, delete);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -276,10 +276,10 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public synchronized void cleanShard(int shardId) throws ElasticSearchException {
|
@Override public synchronized void cleanShard(int shardId) throws ElasticSearchException {
|
||||||
deleteShard(shardId, true, false);
|
deleteShard(shardId, true, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteShard(int shardId, boolean delete, boolean deleteGateway) throws ElasticSearchException {
|
private void deleteShard(int shardId, boolean delete, boolean snapshotGateway, boolean deleteGateway) throws ElasticSearchException {
|
||||||
Injector shardInjector;
|
Injector shardInjector;
|
||||||
IndexShard indexShard;
|
IndexShard indexShard;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
@ -335,8 +335,16 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// now, we can snapshot to the gateway, it will be only the translog
|
// now, we can snapshot to the gateway, it will be only the translog
|
||||||
|
if (snapshotGateway) {
|
||||||
|
shardInjector.getInstance(IndexShardGatewayService.class).snapshotOnClose();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
try {
|
||||||
shardInjector.getInstance(IndexShardGatewayService.class).close(deleteGateway);
|
shardInjector.getInstance(IndexShardGatewayService.class).close(deleteGateway);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ignore
|
// ignore
|
||||||
|
|
Loading…
Reference in New Issue