@@ -288,7 +288,14 @@ public void testIndexCanChangeCustomDataPath() throws Exception {
288
288
final Path indexDataPath = sharedDataPath .resolve ("start-" + randomAsciiLettersOfLength (10 ));
289
289
290
290
logger .info ("--> creating index [{}] with data_path [{}]" , index , indexDataPath );
291
- createIndex (index , Settings .builder ().put (IndexMetadata .SETTING_DATA_PATH , indexDataPath .toAbsolutePath ().toString ()).build ());
291
+ createIndex (
292
+ index ,
293
+ Settings .builder ()
294
+ .put (IndexMetadata .SETTING_DATA_PATH , indexDataPath .toAbsolutePath ().toString ())
295
+ .put (IndexSettings .INDEX_TRANSLOG_DURABILITY_SETTING .getKey (), Translog .Durability .REQUEST )
296
+ .put (IndexSettings .INDEX_MERGE_ON_FLUSH_ENABLED .getKey (), false )
297
+ .build ()
298
+ );
292
299
client ().prepareIndex (index ).setId ("1" ).setSource ("foo" , "bar" ).setRefreshPolicy (IMMEDIATE ).get ();
293
300
ensureGreen (index );
294
301
@@ -307,6 +314,16 @@ public void testIndexCanChangeCustomDataPath() throws Exception {
307
314
logger .info ("--> closing the index [{}] before updating data_path" , index );
308
315
assertAcked (client ().admin ().indices ().prepareClose (index ).setWaitForActiveShards (ActiveShardCount .DEFAULT ));
309
316
317
+ // race condition: async flush may cause translog file deletion resulting in an inconsistent stream from
318
+ // Files.walk below during copy phase
319
+ // temporarily disable refresh to avoid any flushes or syncs that may inadvertently cause the deletion
320
+ assertAcked (
321
+ client ().admin ()
322
+ .indices ()
323
+ .prepareUpdateSettings (index )
324
+ .setSettings (Settings .builder ().put (IndexSettings .INDEX_REFRESH_INTERVAL_SETTING .getKey (), "-1" ).build ())
325
+ );
326
+
310
327
final Path newIndexDataPath = sharedDataPath .resolve ("end-" + randomAlphaOfLength (10 ));
311
328
IOUtils .rm (newIndexDataPath );
312
329
@@ -326,11 +343,17 @@ public void testIndexCanChangeCustomDataPath() throws Exception {
326
343
}
327
344
328
345
logger .info ("--> updating data_path to [{}] for index [{}]" , newIndexDataPath , index );
346
+ // update data path and re-enable refresh
329
347
assertAcked (
330
348
client ().admin ()
331
349
.indices ()
332
350
.prepareUpdateSettings (index )
333
- .setSettings (Settings .builder ().put (IndexMetadata .SETTING_DATA_PATH , newIndexDataPath .toAbsolutePath ().toString ()).build ())
351
+ .setSettings (
352
+ Settings .builder ()
353
+ .put (IndexMetadata .SETTING_DATA_PATH , newIndexDataPath .toAbsolutePath ().toString ())
354
+ .put (IndexSettings .INDEX_REFRESH_INTERVAL_SETTING .getKey (), IndexSettings .DEFAULT_REFRESH_INTERVAL .toString ())
355
+ .build ()
356
+ )
334
357
.setIndicesOptions (IndicesOptions .fromOptions (true , false , true , true ))
335
358
);
336
359
0 commit comments