Class VeniceDelegateMode

java.lang.Object
com.linkedin.alpini.router.api.ScatterGatherMode
com.linkedin.venice.router.api.VeniceDelegateMode

public class VeniceDelegateMode extends ScatterGatherMode
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.