Skip to content

Commit 28c007f

Browse files
committed
another approach: force normal niofs for fdt tmp file read access when flushing stored fields
1 parent 9bbca7e commit 28c007f

File tree

1 file changed

+5
-35
lines changed

1 file changed

+5
-35
lines changed

server/src/main/java/org/elasticsearch/index/store/FsDirectoryFactory.java

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -173,40 +173,6 @@ protected boolean useDirectIO(String name, IOContext context, OptionalLong fileL
173173

174174
@Override
175175
public IndexInput openInput(String name, IOContext context) throws IOException {
176-
// Force normal read advice for stored field temp fdt files:
177-
// (tmp fdt files should only exist when index sorting is enabled)
178-
if (LuceneFilesExtensions.TMP.getExtension().equals(getExtension(name)) && name.contains("fdt")) {
179-
ensureOpen();
180-
ensureCanRead(name);
181-
var niofsDelegate = super.openInput(name, context);
182-
var ioContext = context;
183-
return new FilterIndexInput(niofsDelegate.toString(), niofsDelegate) {
184-
185-
IndexInput directIOInput;
186-
187-
@Override
188-
public IndexInput clone() {
189-
// HACK: only StoredFieldsWriter#checkIntegrity() will invoking this clone method for fdt tmp file.
190-
if (directIOInput == null) {
191-
try {
192-
directIOInput = directIODelegate.openInput(name, ioContext);
193-
} catch (IOException e) {
194-
throw new UncheckedIOException(e);
195-
}
196-
}
197-
return directIOInput.clone();
198-
}
199-
200-
@Override
201-
public void close() throws IOException {
202-
super.close();
203-
if (directIOInput != null) {
204-
directIOInput.close();
205-
}
206-
}
207-
};
208-
}
209-
210176
if (useDelegate(name, context)) {
211177
// we need to do these checks on the outer directory since the inner doesn't know about pending deletes
212178
ensureOpen();
@@ -258,7 +224,11 @@ static boolean useDelegate(String name, IOContext ioContext) {
258224
}
259225

260226
final LuceneFilesExtensions extension = LuceneFilesExtensions.fromExtension(getExtension(name));
261-
if (extension == null || extension.shouldMmap() == false) {
227+
if (extension == null
228+
|| extension.shouldMmap() == false
229+
// Force normal read advice for stored field temp fdt files:
230+
// (tmp fdt files should only exist when index sorting is enabled)
231+
|| (LuceneFilesExtensions.TMP.getExtension().equals(getExtension(name)) && name.contains("fdt"))) {
262232
// Other files are either less performance-sensitive (e.g. stored field index, norms metadata)
263233
// or are large and have a random access pattern and mmap leads to page cache trashing
264234
// (e.g. stored fields and term vectors).

0 commit comments

Comments
 (0)