Skip to content

TESTS: Fix Race Condition in Temp Path Creation #33352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.elasticsearch.index.engine;

import java.nio.file.Path;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.internal.io.IOUtils;
import org.elasticsearch.index.IndexSettings;
Expand Down Expand Up @@ -191,13 +192,12 @@ public void testDedupByPrimaryTerm() throws Exception {
}
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/33344")
public void testUpdateAndReadChangesConcurrently() throws Exception {
Follower[] followers = new Follower[between(1, 3)];
CountDownLatch readyLatch = new CountDownLatch(followers.length + 1);
AtomicBoolean isDone = new AtomicBoolean();
for (int i = 0; i < followers.length; i++) {
followers[i] = new Follower(engine, isDone, readyLatch);
followers[i] = new Follower(engine, isDone, readyLatch, createTempDir());
followers[i].start();
}
boolean onPrimary = randomBoolean();
Expand Down Expand Up @@ -236,13 +236,15 @@ class Follower extends Thread {
private final TranslogHandler translogHandler;
private final AtomicBoolean isDone;
private final CountDownLatch readLatch;
private final Path translogPath;

Follower(Engine leader, AtomicBoolean isDone, CountDownLatch readLatch) {
Follower(Engine leader, AtomicBoolean isDone, CountDownLatch readLatch, Path translogPath) {
this.leader = leader;
this.isDone = isDone;
this.readLatch = readLatch;
this.translogHandler = new TranslogHandler(xContentRegistry(), IndexSettingsModule.newIndexSettings(shardId.getIndexName(),
engine.engineConfig.getIndexSettings().getSettings()));
this.translogPath = translogPath;
}

void pullOperations(Engine follower) throws IOException {
Expand All @@ -261,7 +263,7 @@ void pullOperations(Engine follower) throws IOException {
@Override
public void run() {
try (Store store = createStore();
InternalEngine follower = createEngine(store, createTempDir())) {
InternalEngine follower = createEngine(store, translogPath)) {
readLatch.countDown();
readLatch.await();
while (isDone.get() == false ||
Expand Down