Skip to content

Commit 078eb22

Browse files
committed
[server] Clamp step-down stamp ack timeout to non-negative at config-read time
Addresses Copilot review comment: a misconfigured negative ack-timeout would make CompletableFuture.get(long, TimeUnit) return immediately or, on some JDKs, throw IllegalArgumentException - neither is what we want in the demotion handler. Clamp the value to Math.max(0, raw) at config-read time so the emit path can call get() unconditionally without a defensive guard at every call site. Zero still works (no-wait poll), which is the operator's choice. Testing Done - testVeniceWriterInProcessConsumerAction passes (3.1 s). - No behavior change for the default 1000 ms value.
1 parent 8a6f7bc commit 078eb22

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

clients/da-vinci-client/src/main/java/com/linkedin/davinci/config/VeniceServerConfig.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,8 +1282,16 @@ public VeniceServerConfig(VeniceProperties serverProperties, Map<String, Map<Str
12821282
serverProperties.getBoolean(SERVER_LEADER_HANDOVER_EMIT_STEPDOWN_STAMP, false);
12831283
this.leaderHandoverConsumeStepDownStamp =
12841284
serverProperties.getBoolean(SERVER_LEADER_HANDOVER_CONSUME_STEPDOWN_STAMP, false);
1285+
/*
1286+
* Clamp to a non-negative value at read time so that the stamp emit path can call
1287+
* CompletableFuture#get(long, TimeUnit) unconditionally without having to defend against a
1288+
* misconfigured negative timeout (which would otherwise either return immediately or, in
1289+
* some JDK versions, throw IllegalArgumentException — neither is desirable in the demotion
1290+
* handler). A zero value still works: get(0, MILLISECONDS) attempts a no-wait poll and
1291+
* times out immediately if the produce hasn't acked, which is the operator's choice.
1292+
*/
12851293
this.leaderHandoverEmitStepDownStampAckTimeoutMs =
1286-
serverProperties.getLong(SERVER_LEADER_HANDOVER_EMIT_STEPDOWN_STAMP_ACK_TIMEOUT_MS, 1000L);
1294+
Math.max(0L, serverProperties.getLong(SERVER_LEADER_HANDOVER_EMIT_STEPDOWN_STAMP_ACK_TIMEOUT_MS, 1000L));
12871295
this.serverIngestionInfoLogLineLimit = serverProperties.getInt(SERVER_INGESTION_INFO_LOG_LINE_LIMIT, 20);
12881296
this.parallelResourceShutdownEnabled =
12891297
serverProperties.getBoolean(SERVER_PARALLEL_RESOURCE_SHUTDOWN_ENABLED, false);

0 commit comments

Comments
 (0)