mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-01 16:39:11 +00:00
Merge pull request #17232 from areek/cleanup/handling_index_state
Cleanup writing upgraded index state
This commit is contained in:
commit
866a350599
@ -234,8 +234,8 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL
|
|||||||
// We successfully checked all indices for backward compatibility and found no non-upgradable indices, which
|
// We successfully checked all indices for backward compatibility and found no non-upgradable indices, which
|
||||||
// means the upgrade can continue. Now it's safe to overwrite index metadata with the new version.
|
// means the upgrade can continue. Now it's safe to overwrite index metadata with the new version.
|
||||||
for (IndexMetaData indexMetaData : updateIndexMetaData) {
|
for (IndexMetaData indexMetaData : updateIndexMetaData) {
|
||||||
// since we still haven't upgraded the index folders, we write index state in the old folder
|
// since we upgraded the index folders already, write index state in the upgraded index folder
|
||||||
metaStateService.writeIndex("upgrade", indexMetaData, nodeEnv.resolveIndexFolder(indexMetaData.getIndex().getUUID()));
|
metaStateService.writeIndex("upgrade", indexMetaData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,18 +121,11 @@ public class MetaStateService extends AbstractComponent {
|
|||||||
* Writes the index state.
|
* Writes the index state.
|
||||||
*/
|
*/
|
||||||
void writeIndex(String reason, IndexMetaData indexMetaData) throws IOException {
|
void writeIndex(String reason, IndexMetaData indexMetaData) throws IOException {
|
||||||
writeIndex(reason, indexMetaData, nodeEnv.indexPaths(indexMetaData.getIndex()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes the index state in <code>locations</code>, use {@link #writeGlobalState(String, MetaData)}
|
|
||||||
* to write index state in index paths
|
|
||||||
*/
|
|
||||||
void writeIndex(String reason, IndexMetaData indexMetaData, Path[] locations) throws IOException {
|
|
||||||
final Index index = indexMetaData.getIndex();
|
final Index index = indexMetaData.getIndex();
|
||||||
logger.trace("[{}] writing state, reason [{}]", index, reason);
|
logger.trace("[{}] writing state, reason [{}]", index, reason);
|
||||||
try {
|
try {
|
||||||
IndexMetaData.FORMAT.write(indexMetaData, indexMetaData.getVersion(), locations);
|
IndexMetaData.FORMAT.write(indexMetaData, indexMetaData.getVersion(),
|
||||||
|
nodeEnv.indexPaths(indexMetaData.getIndex()));
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
logger.warn("[{}]: failed to write index state", ex, index);
|
logger.warn("[{}]: failed to write index state", ex, index);
|
||||||
throw new IOException("failed to write state for [" + index + "]", ex);
|
throw new IOException("failed to write state for [" + index + "]", ex);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user