Skip to content

Commit 9b79501

Browse files
committed
fix: keep the shutdown drain inside Kubernetes' grace period, document 0 as auto
Both from dkrizan's review: - awaitTerminationSeconds was 20 per pool, and Spring destroys pools one at a time, so four pools could wait up to 80s. The Tolgee chart does not set terminationGracePeriodSeconds, so pods get Kubernetes' default of 30 and the kubelet would SIGKILL mid-drain — the wait would cost the whole grace period and still lose the work it was protecting. 5s per pool keeps the worst case at 20s. - max-threads treats 0 as "derive it", so someone setting 0 to switch a pool off gets the derived size instead. The property docs now say so for both pools.
1 parent 8af0ae3 commit 9b79501

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

backend/app/src/main/kotlin/io/tolgee/configuration/AsyncExecutorFactory.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,13 @@ class AsyncExecutorFactory(
8383

8484
/** A burst is a burst regardless of how many threads drain it; 3 threads still deserve a buffer. */
8585
const val MIN_QUEUE_CAPACITY = 50
86-
const val SHUTDOWN_DRAIN_SECONDS = 20
86+
87+
/**
88+
* Spring destroys the pools one at a time, so this is paid once per pool. Four pools at 5s stay
89+
* inside Kubernetes' default terminationGracePeriodSeconds of 30, which the Tolgee chart does
90+
* not override — going over it means the kubelet SIGKILLs mid-drain and the wait buys nothing.
91+
*/
92+
const val SHUTDOWN_DRAIN_SECONDS = 5
8793

8894
const val UNBOUNDED_QUEUE = Int.MAX_VALUE
8995

backend/data/src/main/kotlin/io/tolgee/configuration/tolgee/AsyncProperties.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ class StreamingAsyncProperties {
3434
description =
3535
"How many streaming responses this instance can produce at the same time.\n\n" +
3636
"Each one occupies one thread **and one database connection** until the response is " +
37-
"finished, so this must stay well below your database connection pool size.",
37+
"finished, so this must stay well below your database connection pool size.\n\n" +
38+
"There is no way to switch streaming off: `0` and any negative value mean *derive it*, " +
39+
"not *disable it*.",
3840
defaultValue = "-1",
3941
defaultExplanation = "A third of the database connection pool size, never less than 2",
4042
)
@@ -72,7 +74,10 @@ class StreamingAsyncProperties {
7274
)
7375
class BackgroundAsyncProperties {
7476
@DocProperty(
75-
description = "How many background tasks Tolgee runs in parallel on this instance.",
77+
description =
78+
"How many background tasks Tolgee runs in parallel on this instance.\n\n" +
79+
"There is no way to switch background processing off: `0` and any negative value mean " +
80+
"*derive it*, not *disable it*.",
7681
defaultValue = "-1",
7782
defaultExplanation = "A sixth of the database connection pool size, never less than 2",
7883
)

0 commit comments

Comments
 (0)