allegro / allegro/envoy-control

Fix PARALLEL executorGroup to ensure sequential execution for single DiscoveryRequestStreamObserver

オープン
#103 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Kotlin
スター
111
フォーク
35
PR マージ指標
30日以内にマージされた PR はありません

説明

Currently we use one `ThreadPoolExecutor` shared for all `DiscoveryRequestStreamObserver`s as an `ExecutorGroup`: https://github.com/allegro/envoy-control/blob/master/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/ControlPlane.kt#L105
(only when corresponding property is set to `PARALLEL`, which is not the default)

This approach is not valid because it will lead to sending XDS responses out-of-order for given `DiscoveryRequestStreamObserver`.

We should switch our parallel `ExecutorGroup` implementation to multiple, single-threaded `ThreadPoolExecutor`s. This way we will ensure that single `DiscoveryRequestStreamObserver` is running sequentially, but many `DiscoveryRequestStreamObserver`s may run in parallel.

Implementation of such ExecutorGroup may look like this (not tested):

```kotlin
class SequentialExecutorGroup(
threads: Int,
singleThreadedExecutorFactory: (Int) -> ExecutorService
) : ExecutorGroup {

private val executors = (0 until threads).map(singleThreadedExecutorFactory)
private val counter = AtomicInteger(0)

override fun next(): Executor {

val index = counter.getAndUpdate { c ->
val next = c+1
if (next >= executors.size) {
0
} else {
next
}
}

return executors[index]
}
}
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。