Browse Source

Assert MetadataStateFormat#write not on transport thread (#98670)

David Turner 2 years ago
parent
commit
09cde394ae

+ 2 - 0
server/src/main/java/org/elasticsearch/gateway/MetadataStateFormat.java

@@ -24,6 +24,7 @@ import org.elasticsearch.common.lucene.store.InputStreamIndexInput;
 import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
 import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
 import org.elasticsearch.core.IOUtils;
 import org.elasticsearch.core.IOUtils;
 import org.elasticsearch.core.Tuple;
 import org.elasticsearch.core.Tuple;
+import org.elasticsearch.transport.Transports;
 import org.elasticsearch.xcontent.NamedXContentRegistry;
 import org.elasticsearch.xcontent.NamedXContentRegistry;
 import org.elasticsearch.xcontent.XContentBuilder;
 import org.elasticsearch.xcontent.XContentBuilder;
 import org.elasticsearch.xcontent.XContentFactory;
 import org.elasticsearch.xcontent.XContentFactory;
@@ -222,6 +223,7 @@ public abstract class MetadataStateFormat<T> {
     }
     }
 
 
     private long write(final T state, boolean cleanup, final Path... locations) throws WriteStateException {
     private long write(final T state, boolean cleanup, final Path... locations) throws WriteStateException {
+        assert Transports.assertNotTransportThread("MetadataStateFormat#write does IO and must not run on transport thread");
         if (locations == null) {
         if (locations == null) {
             throw new IllegalArgumentException("Locations must not be null");
             throw new IllegalArgumentException("Locations must not be null");
         }
         }