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

WIP: See if we can consistently repro flaky IoUringTest.ioUringIsAvailableOnLinux() #2758

Closed
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@

import io.netty.incubator.channel.uring.IOUring;
import io.netty.incubator.channel.uring.IOUringEventLoopGroup;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import static io.servicetalk.http.api.HttpExecutionStrategies.defaultStrategy;
import static io.servicetalk.http.api.HttpExecutionStrategies.offloadNone;
import static io.servicetalk.http.api.HttpResponseStatus.OK;
Expand Down Expand Up @@ -73,7 +78,7 @@ void ioUringIsAvailableOnLinux(boolean noOffloading) throws Exception {
System.getProperty("os.name") + ' ' + System.getProperty("os.version"));
IOUring.ensureAvailability();

ioUringExecutor = NettyIoExecutors.createIoExecutor(2, "io-uring");
ioUringExecutor = NettyIoExecutors.createIoExecutor(1, "io-uring");
assertThat(ioUringExecutor.eventLoopGroup(), is(instanceOf(IOUringEventLoopGroup.class)));

try (ServerContext serverContext = HttpServers.forAddress(localAddress(0))
Expand All @@ -92,9 +97,37 @@ void ioUringIsAvailableOnLinux(boolean noOffloading) throws Exception {
} finally {
IoUringUtils.tryIoUring(false);
if (ioUringExecutor != null) {
ioUringExecutor.closeAsync().toFuture().get();
try {
// It seems that if we attempt to close gracefully we never actually close down.
ioUringExecutor.closeAsync().toFuture().get(10, TimeUnit.SECONDS); // the offending line.
} catch (TimeoutException ex) {
final boolean isShutdown = ioUringExecutor.eventLoopGroup().isShutdown();
StringBuilder sb = new StringBuilder();
sb.append("Timed out shutting down executor. isShutdown(): ")
.append(isShutdown)
.append('\n');
for (Map.Entry<Thread, StackTraceElement[]> entry : Thread.getAllStackTraces().entrySet()) {
if (!entry.getKey().getName().startsWith("io-uring")) {
// Not one of our threads.
continue;
}
sb.append("Thread: ").append(entry.getKey().getName()).append('\n');
for (StackTraceElement e : entry.getValue()) {
sb.append('\t').append(e).append('\n');
}
}
Exception next = new TimeoutException(sb.toString());
next.initCause(ex);
throw next;
}
assertTrue(ioUringExecutor.eventLoopGroup().isShutdown());
}
}
}

@RepeatedTest(5000)
@EnabledOnOs(LINUX)
void repro() throws Exception {
ioUringIsAvailableOnLinux(false);
}
}
Loading