Stability (#324)

* propagate rootcause of JsonRpcException
* increase pool size
* Log WsConnectionImpl exceptions
This commit is contained in:
a10zn8
2023-10-24 09:04:16 +03:00
committed by GitHub
parent 89880355d8
commit 5157d6fe7f
4 changed files with 10 additions and 11 deletions

View File

@@ -273,7 +273,7 @@ open class WsConnectionImpl(
}
onMessage(msg)
} catch (t: Throwable) {
log.warn("Failed to process WS message. ${t.javaClass}: ${t.message}. Message: ${String(it)}")
log.warn("Failed to process WS message", t)
Mono.empty()
}
}

View File

@@ -22,10 +22,13 @@ open class JsonRpcException(
val error: JsonRpcError,
val upstreamId: String? = null,
writableStackTrace: Boolean = true,
) : Exception(error.message, null, true, writableStackTrace) {
cause: Throwable? = null,
) : Exception(error.message, cause, true, writableStackTrace) {
constructor(id: Int, message: String) : this(JsonRpcResponse.NumberId(id), JsonRpcError(-32005, message))
constructor(id: Int, message: String, cause: Throwable) : this(JsonRpcResponse.NumberId(id), JsonRpcError(-32005, message), cause = cause)
companion object {
fun from(err: RpcException): JsonRpcException {
val id = err.details?.let {

View File

@@ -25,7 +25,6 @@ import io.netty.handler.codec.http.HttpHeaders
import io.netty.handler.ssl.SslContextBuilder
import io.netty.resolver.DefaultAddressResolverGroup
import org.apache.commons.lang3.time.StopWatch
import org.slf4j.LoggerFactory
import reactor.core.publisher.Mono
import reactor.netty.http.client.HttpClient
import reactor.netty.resources.ConnectionProvider
@@ -50,18 +49,15 @@ class JsonRpcHttpClient(
tlsCAAuth: ByteArray? = null,
) : JsonRpcReader {
companion object {
private val log = LoggerFactory.getLogger(JsonRpcHttpClient::class.java)
}
private val parser = ResponseRpcParser()
private val httpClient: HttpClient
init {
val connectionProvider = ConnectionProvider.builder("dshackleConnectionPool")
.maxConnections(1000)
.pendingAcquireMaxCount(5000)
.maxConnections(1500)
.pendingAcquireMaxCount(10000)
.build()
var build = HttpClient.create(connectionProvider)
.compress(true)
.resolver(DefaultAddressResolverGroup.INSTANCE)
@@ -152,7 +148,7 @@ class JsonRpcHttpClient(
val err = when (t) {
is RpcException -> JsonRpcException.from(t)
is JsonRpcException -> t
else -> JsonRpcException(key.id, t.message ?: t.javaClass.name)
else -> JsonRpcException(key.id, t.message ?: t.javaClass.name, cause = t)
}
// here we're measure the internal errors, not upstream errors
metrics.fails.increment()

View File

@@ -176,7 +176,7 @@ class NativeCallSpec extends Specification {
nativeCall.rpcReaderFactory = Mock(RpcReaderFactory) {
1 * create(_) >> Mock(RpcReader) {
1 * read(new JsonRpcRequest("eth_test", [], 10)) >> Mono.error(
new JsonRpcException(JsonRpcResponse.Id.from(12), new JsonRpcError(-32123, "Foo Bar", "Foo Bar Baz"), null, true)
new JsonRpcException(JsonRpcResponse.Id.from(12), new JsonRpcError(-32123, "Foo Bar", "Foo Bar Baz"), null, true, null)
)
}
}