mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-06 13:08:29 +00:00
only log that we delete unused shard if it exists
This commit is contained in:
parent
d9b78000b1
commit
f5a3261e15
@ -115,6 +115,18 @@ public class FileSystemUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if at least one of the files exists.
|
||||||
|
*/
|
||||||
|
public static boolean exists(File... files) {
|
||||||
|
for (File file : files) {
|
||||||
|
if (file.exists()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean deleteRecursively(File[] roots) {
|
public static boolean deleteRecursively(File[] roots) {
|
||||||
boolean deleted = true;
|
boolean deleted = true;
|
||||||
for (File root : roots) {
|
for (File root : roots) {
|
||||||
|
@ -39,6 +39,8 @@ import org.elasticsearch.indices.IndicesService;
|
|||||||
import org.elasticsearch.node.settings.NodeSettingsService;
|
import org.elasticsearch.node.settings.NodeSettingsService;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -156,8 +158,11 @@ public class IndicesStore extends AbstractComponent implements ClusterStateListe
|
|||||||
if (indexService == null) {
|
if (indexService == null) {
|
||||||
// not physical allocation of the index, delete it from the file system if applicable
|
// not physical allocation of the index, delete it from the file system if applicable
|
||||||
if (nodeEnv.hasNodeFile()) {
|
if (nodeEnv.hasNodeFile()) {
|
||||||
logger.debug("[{}][{}] deleting shard that is no longer used", shardId.index().name(), shardId.id());
|
File[] shardLocations = nodeEnv.shardLocations(shardId);
|
||||||
FileSystemUtils.deleteRecursively(nodeEnv.shardLocations(shardId));
|
if (FileSystemUtils.exists(shardLocations)) {
|
||||||
|
logger.debug("[{}][{}] deleting shard that is no longer used", shardId.index().name(), shardId.id());
|
||||||
|
FileSystemUtils.deleteRecursively(shardLocations);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!indexService.hasShard(shardId.id())) {
|
if (!indexService.hasShard(shardId.id())) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user