aws / aws/aws-sdk-java-v2

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

Aperta
#2,145 4 commenti 4 reazioni 0 assegnatari Vedi su GitHub
feature-request p3
Lingua principale
Java
Stelle
2.6k
Fork
1k
Merge medio
2g 9h
PR unite (30g)
51

Descrizione

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"
)
```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia da software.amazon.awssdk.http.nio.netty.internal.BetterSimpleChannelPool#close e confronta il relativo percorso delle chiamate con io.netty.channel.pool.SimpleChannelPool.close nello stack trace fornito. Riproduci l’arresto usando l’esempio DynamoDbEnhancedAsyncClient e lo scenario di chiusura del contesto Spring, quindi verifica che la chiusura dei pool di canali non produca più l’errore di BlockHound relativo a un’operazione bloccante né il problema di arresto segnalato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
aws, java
Ambito
backend, networking
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.