Package com.linkedin.venice.router.api
Class VeniceDelegateMode
java.lang.Object
com.linkedin.alpini.router.api.ScatterGatherMode
com.linkedin.venice.router.api.VeniceDelegateMode
This class contains all the
ScatterGatherMode
being used in Venice Router.
IMPORTANT!!!
In scatter(com.linkedin.alpini.router.api.Scatter<H, P, K>, java.lang.String, java.lang.String, com.linkedin.alpini.router.api.PartitionFinder<K>, com.linkedin.alpini.router.api.HostFinder<H, R>, com.linkedin.alpini.router.api.HostHealthMonitor<H>, R)
function, only RouterException
is expected, otherwise, the netty buffer leaking issue
will happen.
This vulnerability is related to Alpini since ScatterGatherMode.scatter(com.linkedin.alpini.router.api.Scatter<H, P, K>, java.lang.String, java.lang.String, com.linkedin.alpini.router.api.PartitionFinder<K>, com.linkedin.alpini.router.api.HostFinder<H, R>, com.linkedin.alpini.router.api.HostHealthMonitor<H>, R)
only catches RouterException
to
return the exceptional future, otherwise, that function will throw exception to miss the release operation in ScatterGatherRequestHandlerImpl.prepareRetry(com.linkedin.alpini.base.concurrency.AsyncFuture<H>, P, BHS, R, com.linkedin.alpini.base.concurrency.AsyncPromise<java.util.List<HR>>, com.linkedin.alpini.base.concurrency.AsyncFuture<java.lang.Void>, java.util.concurrent.Executor, com.linkedin.alpini.router.api.HostHealthMonitor<H>, com.linkedin.alpini.router.monitoring.ScatterGatherStats.Delta, com.linkedin.alpini.base.misc.Metrics)
.
Here are the details:
1. If the current implementation of scatter(com.linkedin.alpini.router.api.Scatter<H, P, K>, java.lang.String, java.lang.String, com.linkedin.alpini.router.api.PartitionFinder<K>, com.linkedin.alpini.router.api.HostFinder<H, R>, com.linkedin.alpini.router.api.HostHealthMonitor<H>, R)
throws other exceptions than RouterException
, ScatterGatherMode.scatter(com.linkedin.alpini.router.api.Scatter<H, P, K>, java.lang.String, java.lang.String, com.linkedin.alpini.router.api.PartitionFinder<K>, com.linkedin.alpini.router.api.HostFinder<H, R>, com.linkedin.alpini.router.api.HostHealthMonitor<H>, R)
will rethrow the exception instead of returning an exceptional future.
2. For long-tail retry, ScatterGatherRequestHandlerImpl.prepareRetry(com.linkedin.alpini.base.concurrency.AsyncFuture<H>, P, BHS, R, com.linkedin.alpini.base.concurrency.AsyncPromise<java.util.List<HR>>, com.linkedin.alpini.base.concurrency.AsyncFuture<java.lang.Void>, java.util.concurrent.Executor, com.linkedin.alpini.router.api.HostHealthMonitor<H>, com.linkedin.alpini.router.monitoring.ScatterGatherStats.Delta, com.linkedin.alpini.base.misc.Metrics)
will retain the request
every time, and it will try to release the request in the handling function of "_scatterGatherHelper.scatter" in
ScatterGatherRequestHandlerImpl.prepareRetry(com.linkedin.alpini.base.concurrency.AsyncFuture<H>, P, BHS, R, com.linkedin.alpini.base.concurrency.AsyncPromise<java.util.List<HR>>, com.linkedin.alpini.base.concurrency.AsyncFuture<java.lang.Void>, java.util.concurrent.Executor, com.linkedin.alpini.router.api.HostHealthMonitor<H>, com.linkedin.alpini.router.monitoring.ScatterGatherStats.Delta, com.linkedin.alpini.base.misc.Metrics)
.
3. If #1 happens, the handling function mentioned in #2 won't be invoked, which means the release won't happen, and this
is causing the request leaking.
TODO: maybe we should improve DDS lib to catch all kinds of exception in ScatterGatherMode.scatter(com.linkedin.alpini.router.api.Scatter<H, P, K>, java.lang.String, java.lang.String, com.linkedin.alpini.router.api.PartitionFinder<K>, com.linkedin.alpini.router.api.HostFinder<H, R>, com.linkedin.alpini.router.api.HostHealthMonitor<H>, R)
to avoid
this potential leaking issue.-
Field Summary
Fields inherited from class com.linkedin.alpini.router.api.ScatterGatherMode
BROADCAST_BY_PARTITION, BROADCAST_BY_PRIMARY_HOST, GROUP_BY_GREEDY_HOST, GROUP_BY_PARTITION, GROUP_BY_PRIMARY_HOST
-
Constructor Summary
ConstructorDescriptionVeniceDelegateMode
(VeniceRouterConfig config, RouterStats<AggRouterHttpRequestStats> routerStats, RouteHttpRequestStats routeHttpRequestStats) -
Method Summary
Modifier and TypeMethodDescriptionvoid
initHelixGroupSelector
(HelixGroupSelector helixGroupSelector) void
initReadRequestThrottler
(RouterThrottler requestThrottler) <H,
P extends ResourcePath<K>, K, R>
Scatter<H,P, K> scatter
(Scatter<H, P, K> scatter, String requestMethod, String resourceName, PartitionFinder<K> partitionFinder, HostFinder<H, R> hostFinder, HostHealthMonitor<H> hostHealthMonitor, R roles) Deprecated method is compatible to old method signature.Methods inherited from class com.linkedin.alpini.router.api.ScatterGatherMode
asBroadcast, asScatter, equals, hashCode, scatter, toString
-
Constructor Details
-
VeniceDelegateMode
public VeniceDelegateMode(VeniceRouterConfig config, RouterStats<AggRouterHttpRequestStats> routerStats, RouteHttpRequestStats routeHttpRequestStats)
-
-
Method Details
-
initReadRequestThrottler
-
initHelixGroupSelector
-
scatter
@Nonnull public <H,P extends ResourcePath<K>, Scatter<H,K, R> P, scatterK> (@Nonnull Scatter<H, P, throws RouterExceptionK> scatter, @Nonnull String requestMethod, @Nonnull String resourceName, @Nonnull PartitionFinder<K> partitionFinder, @Nonnull HostFinder<H, R> hostFinder, @Nonnull HostHealthMonitor<H> hostHealthMonitor, @Nonnull R roles) Description copied from class:ScatterGatherMode
Deprecated method is compatible to old method signature.- Overrides:
scatter
in classScatterGatherMode
- Throws:
RouterException
-