aws / aws/aws-sdk-java-v2

Blocking call inside of a software.amazon.awssdk.http.nio.netty.internal.BetterSimpleChannelPool.close

Abierto
#2,145 4 comentarios 4 reacciones 0 asignados Ver en GitHub
feature-request p3
Lenguaje dominante
Java
Estrellas
2.6k
Forks
1k
Merge medio
2 d 9 h
PR fusionados (30 d)
51

Descripción

Since v2 is claimed to be non-blocking, we still facing a blocking call in `software.amazon.awssdk.http.nio.netty.internal.BetterSimpleChannelPool#close` which could be concidered as illegal in this case.
We use https://github.com/reactor/BlockHound in pair with Reactor in spring as well as localstack in testcontainers in our tests, where this blocking call is popping out.

## Describe the issue
We see in test logs this stacktrace:

```java
2020-11-13 11:15:00.917 WARN 63962 --- [entExecutor-2-1] i.n.util.concurrent.GlobalEventExecutor : Unexpected exception from the global event executor:

reactor.blockhound.BlockingOperationError: Blocking call! java.lang.Object#wait
at java.base/java.lang.Object.wait(Object.java)
at java.base/java.lang.Object.wait(Object.java:321)
at io.netty.util.concurrent.DefaultPromise.awaitUninterruptibly(DefaultPromise.java:274)
at io.netty.channel.DefaultChannelPromise.awaitUninterruptibly(DefaultChannelPromise.java:137)
at io.netty.channel.DefaultChannelPromise.awaitUninterruptibly(DefaultChannelPromise.java:30)
at io.netty.channel.pool.SimpleChannelPool.close(SimpleChannelPool.java:402)
at software.amazon.awssdk.http.nio.netty.internal.BetterSimpleChannelPool.close(BetterSimpleChannelPool.java:38)
at software.amazon.awssdk.http.nio.netty.internal.HonorCloseOnReleaseChannelPool.close(HonorCloseOnReleaseChannelPool.java:75)
at software.amazon.awssdk.http.nio.netty.internal.IdleConnectionCountingChannelPool.close(IdleConnectionCountingChannelPool.java:106)
at software.amazon.awssdk.http.nio.netty.internal.utils.BetterFixedChannelPool.lambda$close0$3(BetterFixedChannelPool.java:391)
at io.netty.util.concurrent.GlobalEventExecutor$TaskRunner.run(GlobalEventExecutor.java:243)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:832)

2020-11-13 11:15:05.917 ERROR 63962 --- [extShutdownHook] s.a.a.h.n.netty.NettyNioAsyncHttpClient : Unable to close channel pools
```

## Steps to Reproduce
It's hard actually to reproduce the issue, as it's visible or affecting test execution not 100% of the times.

However we're doing in tests something really simple like
```java
var client = DynamoDbEnhancedAsyncClient.builder().dynamoDbClient(DynamoDbAsyncClient.builder().build()).build();
dynamoDb.table("table-name", TableSchema.fromBean(Content.class)).createTable()/.query()
```

within the test. Later when the context closes (we defined clients as spring beans), the close method seems to be called.

## Current Behavior

`BetterSimpleChannelPool#close` blocks the thread

## Your Environment

* AWS Java SDK version used: 2.15.26
* JDK version used: 1.14
* Operating System and version: any

Current workaround is to whitelist this in the BlockHound
```java
.allowBlockingCallsInside(
"software.amazon.awssdk.http.nio.netty.internal.BetterSimpleChannelPool",
"close"
)
```

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza en software.amazon.awssdk.http.nio.netty.internal.BetterSimpleChannelPool#close y compara su ruta de llamadas con io.netty.channel.pool.SimpleChannelPool.close en el stack trace proporcionado. Reproduce el apagado usando el ejemplo de DynamoDbEnhancedAsyncClient y el escenario de cierre del contexto de Spring; después, verifica que cerrar los pools de canales ya no produzca el error de BlockHound por una operación bloqueante ni el fallo de apagado notificado.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
aws, java
Área
backend, networking
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.