Skip to content
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

get startTime outside the executor task to avoid flaky time checks #13250

Merged
merged 1 commit into from
May 28, 2024
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 @@ -34,6 +34,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Nullable;
import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -285,8 +286,8 @@ public void testConsistencyModeSync()
upsertMetadataManager.replaceDocId(seg03, validDocIds03, null, seg01, 0, 12, recordInfo);
});
// This thread gets segment contexts, but it's blocked until the first thread finishes replaceDocId.
long startMs = System.currentTimeMillis();
Future<Long> future = executor.submit(() -> {
long startMs = System.currentTimeMillis();
// Check called flag to let the first thread do replaceDocId, thus get WLock, first.
while (!called.get()) {
Thread.sleep(10);
Expand All @@ -299,7 +300,7 @@ public void testConsistencyModeSync()
// So the 2nd thread getting segment contexts will be blocked for 2s+.
Thread.sleep(2000);
latch.countDown();
long duration = future.get();
long duration = future.get(3, TimeUnit.SECONDS);
assertTrue(duration >= 2000, duration + " was less than expected");
} finally {
executor.shutdownNow();
Expand Down Expand Up @@ -365,8 +366,8 @@ public void testConsistencyModeSnapshot()
upsertMetadataManager.replaceDocId(seg03, validDocIds03, null, seg01, 0, 12, recordInfo);
});
// This thread gets segment contexts, but it's blocked until the first thread finishes replaceDocId.
long startMs = System.currentTimeMillis();
Future<Long> future = executor.submit(() -> {
long startMs = System.currentTimeMillis();
// Check called flag to let the first thread do replaceDocId, thus get WLock, first.
while (!called.get()) {
Thread.sleep(10);
Expand All @@ -380,7 +381,7 @@ public void testConsistencyModeSnapshot()
// So the 2nd thread getting segment contexts will be blocked for 2s+.
Thread.sleep(2000);
latch.countDown();
long duration = future.get();
long duration = future.get(3, TimeUnit.SECONDS);
assertTrue(duration >= 2000, duration + " was less than expected");
} finally {
executor.shutdownNow();
Expand Down
Loading