Skip to content

Commit

Permalink
fix: use a minimal value of 4 for RW_WORKER_THREADS (#663)
Browse files Browse the repository at this point in the history
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
  • Loading branch information
BugenZhao authored May 30, 2024
1 parent 04b2391 commit d7081a7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/factory/risingwave_object_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -1197,11 +1197,14 @@ func basicSetupRisingWaveContainer(container *corev1.Container, component *risin
}, func(env *corev1.EnvVar) bool { return env.Name == envs.RustBacktrace })
}

// Set the RW_WORKER_THREADS to the cpu limit.
// Set the RW_WORKER_THREADS based on the cpu limit.
// Always ensure that the worker threads are at least 4 to reduce the risk of
// unexpected blocking by synchronous operations.
// https://github.com/risingwavelabs/risingwave/issues/16693
if cpuLimit, ok := container.Resources.Limits[corev1.ResourceCPU]; ok {
container.Env = mergeListByKey(container.Env, corev1.EnvVar{
Name: envs.RWWorkerThreads,
Value: strconv.FormatInt(cpuLimit.Value(), 10),
Value: strconv.FormatInt(max(cpuLimit.Value(), 4), 10),
}, func(env *corev1.EnvVar) bool { return env.Name == envs.RWWorkerThreads })
}

Expand Down

0 comments on commit d7081a7

Please sign in to comment.