Skip to content

Commit 6009dc3

Browse files
committed
More detailed tracing during writing metadata
Packaging tests are occasionally failing (elastic#30295) because of very slow index template creation. It looks like the slow part is updating the on-disk cluster state, and this change will help to confirm this.
1 parent 74c6f18 commit 6009dc3

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

server/src/main/java/org/elasticsearch/gateway/MetaDataStateFormat.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.apache.lucene.store.IndexInput;
3030
import org.apache.lucene.store.OutputStreamIndexOutput;
3131
import org.apache.lucene.store.SimpleFSDirectory;
32+
import org.elasticsearch.common.logging.Loggers;
3233
import org.elasticsearch.core.internal.io.IOUtils;
3334
import org.elasticsearch.ExceptionsHelper;
3435
import org.elasticsearch.common.bytes.BytesArray;
@@ -76,6 +77,7 @@ public abstract class MetaDataStateFormat<T> {
7677
private final String prefix;
7778
private final Pattern stateFilePattern;
7879

80+
private static final Logger logger = Loggers.getLogger(MetaDataStateFormat.class);
7981

8082
/**
8183
* Creates a new {@link MetaDataStateFormat} instance
@@ -134,6 +136,7 @@ public void close() throws IOException {
134136
IOUtils.fsync(tmpStatePath, false); // fsync the state file
135137
Files.move(tmpStatePath, finalStatePath, StandardCopyOption.ATOMIC_MOVE);
136138
IOUtils.fsync(stateLocation, true);
139+
logger.trace("written state to {}", finalStatePath);
137140
for (int i = 1; i < locations.length; i++) {
138141
stateLocation = locations[i].resolve(STATE_DIR_NAME);
139142
Files.createDirectories(stateLocation);
@@ -145,6 +148,7 @@ public void close() throws IOException {
145148
// we are on the same FileSystem / Partition here we can do an atomic move
146149
Files.move(tmpPath, finalPath, StandardCopyOption.ATOMIC_MOVE);
147150
IOUtils.fsync(stateLocation, true);
151+
logger.trace("copied state to {}", finalPath);
148152
} finally {
149153
Files.deleteIfExists(tmpPath);
150154
}

server/src/main/java/org/elasticsearch/gateway/MetaStateService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public void writeIndex(String reason, IndexMetaData indexMetaData) throws IOExce
123123
try {
124124
IndexMetaData.FORMAT.write(indexMetaData,
125125
nodeEnv.indexPaths(indexMetaData.getIndex()));
126+
logger.trace("[{}] state written", index);
126127
} catch (Exception ex) {
127128
logger.warn(() -> new ParameterizedMessage("[{}]: failed to write index state", index), ex);
128129
throw new IOException("failed to write state for [" + index + "]", ex);
@@ -136,6 +137,7 @@ void writeGlobalState(String reason, MetaData metaData) throws IOException {
136137
logger.trace("[_global] writing state, reason [{}]", reason);
137138
try {
138139
MetaData.FORMAT.write(metaData, nodeEnv.nodeDataPaths());
140+
logger.trace("[_global] state written");
139141
} catch (Exception ex) {
140142
logger.warn("[_global]: failed to write global state", ex);
141143
throw new IOException("failed to write global state", ex);

0 commit comments

Comments
 (0)