mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 18:35:25 +00:00
[CORE] close all resources even if #beforeIndexShardClosed throws an exception
Conflicts: src/main/java/org/elasticsearch/index/IndexService.java
This commit is contained in:
parent
16f19bf7bd
commit
3e2f4b86e4
@ -375,8 +375,11 @@ public class IndexService extends AbstractIndexComponent implements IndexCompone
|
|||||||
|
|
||||||
private void closeShardInjector(String reason, ShardId sId, Injector shardInjector, IndexShard indexShard) {
|
private void closeShardInjector(String reason, ShardId sId, Injector shardInjector, IndexShard indexShard) {
|
||||||
final int shardId = sId.id();
|
final int shardId = sId.id();
|
||||||
|
try {
|
||||||
try {
|
try {
|
||||||
indicesLifecycle.beforeIndexShardClosed(sId, indexShard, indexSettings);
|
indicesLifecycle.beforeIndexShardClosed(sId, indexShard, indexSettings);
|
||||||
|
} finally {
|
||||||
|
// close everything else even if the beforeIndexShardClosed threw an exception
|
||||||
for (Class<? extends Closeable> closeable : pluginsService.shardServices()) {
|
for (Class<? extends Closeable> closeable : pluginsService.shardServices()) {
|
||||||
try {
|
try {
|
||||||
shardInjector.getInstance(closeable).close();
|
shardInjector.getInstance(closeable).close();
|
||||||
@ -406,6 +409,7 @@ public class IndexService extends AbstractIndexComponent implements IndexCompone
|
|||||||
|
|
||||||
// call this before we close the store, so we can release resources for it
|
// call this before we close the store, so we can release resources for it
|
||||||
indicesLifecycle.afterIndexShardClosed(sId, indexShard, indexSettings);
|
indicesLifecycle.afterIndexShardClosed(sId, indexShard, indexSettings);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
shardInjector.getInstance(Store.class).close();
|
shardInjector.getInstance(Store.class).close();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user