From 50249f4e527a7663fce13374b4bfd4a0e25a7174 Mon Sep 17 00:00:00 2001 From: kimchy Date: Thu, 1 Apr 2010 22:56:05 +0300 Subject: [PATCH] wait before closing the shard if a snapshot is still in progress --- .../index/gateway/IndexShardGatewayService.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayService.java index df90d058bbd..becf2415d42 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayService.java @@ -161,19 +161,25 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem }); } catch (IllegalIndexShardStateException e) { // ignore, that's fine + } catch (IndexShardGatewaySnapshotFailedException e) { + throw e; } catch (Exception e) { - logger.warn("Failed to snapshot on close", e); + throw new IndexShardGatewaySnapshotFailedException(shardId, "Failed to snapshot", e); } } - public void close(boolean delete) { + public synchronized void close(boolean delete) { if (snapshotScheduleFuture != null) { snapshotScheduleFuture.cancel(true); snapshotScheduleFuture = null; } if (!delete && snapshotOnClose) { logger.debug("Snapshotting on close ..."); - snapshot(); + try { + snapshot(); + } catch (Exception e) { + logger.warn("Failed to snapshot on close", e); + } } // don't really delete the shard gateway if we are *not* primary, // the primary will close it @@ -213,7 +219,7 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem try { snapshot(); } catch (Exception e) { - logger.warn("Failed to snapshot", e); + logger.warn("Failed to snapshot (scheduled)", e); } } }