problem: upstream which didn't respond to head block is available for calls, may fail

solution: mark as unavailable immediately after head request error
This commit is contained in:
Igor Artamonov
2019-09-06 01:29:10 -04:00
parent b1b348e32c
commit 1ea6345cd6

View File

@@ -41,6 +41,7 @@ import java.lang.Exception
import java.math.BigInteger
import java.time.Duration
import java.util.*
import java.util.concurrent.TimeoutException
import java.util.concurrent.atomic.AtomicReference
import java.util.function.Function
import kotlin.collections.ArrayList
@@ -122,10 +123,11 @@ open class GrpcUpstream(
}.flatMap {
getApi(Selector.EmptyMatcher())
.flatMap { api -> api.executeAndConvert(Commands.eth().getBlock(it.hash)) }
.timeout(Duration.ofSeconds(5), Mono.error(Exception("Timeout requesting block from upstream")))
.timeout(Duration.ofSeconds(5), Mono.error(TimeoutException("Timeout from upstream")))
.doOnError { t ->
val msg = "Failed to download block data for chain $chain"
if (t is RpcException) {
setStatus(UpstreamAvailability.UNAVAILABLE)
val msg = "Failed to download block data for chain $chain on $parentId"
if (t is RpcException || t is TimeoutException) {
log.warn("$msg. Message: ${t.message}")
} else {
log.error(msg, t)