924060929 commented on code in PR #70976:
URL: https://github.com/apache/doris/pull/70976#discussion_r4752080610
##########
fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java:
##########
@@ -586,6 +579,24 @@ public TMasterOpResult proxyExecute(TMasterOpRequest
request) throws TException
ctx.setThreadLocalInfo();
StmtExecutor executor = null;
try {
+ // Restore the transaction before validation so an early error
still returns its state to the follower.
+ if (request.isSetTxnLoadInfo()) {
+ TransactionEntry transactionEntry = new TransactionEntry();
+ transactionEntry.setTxnInfoInMaster(request.getTxnLoadInfo());
+ ctx.setTxnEntry(transactionEntry);
+ }
+ // Validate forwarded values inside the error boundary, before
creating the executor.
+ if (request.isSetSessionVariables()) {
+ try {
+
ctx.getSessionVariable().setForwardedSessionVariables(request.getSessionVariables());
+ } catch (IllegalArgumentException e) {
+ throw new DdlException(e.getMessage(),
ErrorCode.ERR_WRONG_VALUE_FOR_VAR);
+ }
+ }
+ // Decode user values after restoring session types such as
DECIMAL256.
+ if (request.isSetUserVariables()) {
+
ctx.setUserVars(userVariableFromThrift(request.getUserVariables()));
+ }
MysqlProtocolAdapter.of(ctx).restoreFromForwardRequest(ctx,
request);
Review Comment:
`[P2]` Move `MysqlProtocolAdapter.of(ctx).restoreFromForwardRequest(ctx,
request)` before forwarded-variable validation (right after restoring
`txnLoadInfo`). It has no dependency on session/user variables, and skipping it
on an early `DdlException` causes `mysqlAdapter.responsePacket(ctx)` and
`result.setClientDeprecatedEofApplied(...)` to use un-restored default
capabilities instead of the forwarded client's capabilities.
##########
fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java:
##########
@@ -483,6 +489,19 @@ private static void setVarInternal(SessionVariable
sessionVariable, SetVar setVa
}
}
+ // Check before changing the session, the global value, or its edit
log. For example,
+ // a cache-block limit of -1 would become a huge unsigned bound in BE.
+ try {
+ NumericRange.check(attr.name(), value, attr.minValue(),
attr.maxValue());
+ if (setVar.getType() == SetType.GLOBAL
+ &&
attr.name().equals(GlobalVariable.AUDIT_PLUGIN_LOAD_TIMEOUT)) {
+ // Only the leader checks its current load bounds. Replay and
followers apply its result.
+ GlobalVariable.checkAuditPluginLoadTimeout(value);
+ }
+ } catch (IllegalArgumentException e) {
+ ErrorReport.reportDdlException(e.getMessage());
Review Comment:
`[P1]` `ErrorReport.reportDdlException(String pattern, Object... objs)`
passes the first argument to `String.format(pattern, objs)` and hardcodes
`ErrorCode.ERR_UNKNOWN_ERROR` (1105). Because `NumericRange.check` and
`Integer.parseInt` include the raw user input in `e.getMessage()`, inputs
containing `%` (e.g., `SET data_queue_max_blocks = '%s'` or `SET GLOBAL
audit_plugin_load_timeout = '%s'`) throw an uncaught `IllegalFormatException`
instead of a `DdlException`.
Use `ErrorReport.reportDdlException("%s", ErrorCode.ERR_WRONG_VALUE_FOR_VAR,
e.getMessage())` (matching `ConnectProcessor.proxyExecute`), and keep
`ERR_WRONG_TYPE_FOR_VAR` for non-numeric parse failures.
##########
fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java:
##########
@@ -6379,10 +6417,14 @@ public void setForwardedSessionVariables(Map<String,
String> variables) {
LOG.debug("set forward variable: {} = {}", varAttr.name(),
val);
}
- // set config field
+ // Older FE nodes can forward values that the current SET
entry rejects.
+ NumericRange.check(varAttr.name(), val, varAttr.minValue(),
varAttr.maxValue());
VariableMgr.setValue(this, val, f, varAttr.name());
}
refreshDerivedSessionVariables();
+ } catch (IllegalArgumentException e) {
Review Comment:
`[P2]` `catch (IllegalArgumentException e)` wraps the entire loop, including
`VariableMgr.setValue` and `refreshDerivedSessionVariables()`. Because
`NumberFormatException` extends `IllegalArgumentException`, any parse failure
in `setValue` (e.g., `"1.5"` on a bounded int or any malformed forwarded value)
leaks a raw message without the variable name (`For input string: "1.5"`).
Failing mid-loop also leaves `this` partially mutated.
Include `varAttr.name()` when reporting per-field parse/validation failures,
and consider validating all entries before mutating `this`.
##########
fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java:
##########
@@ -483,6 +489,19 @@ private static void setVarInternal(SessionVariable
sessionVariable, SetVar setVa
}
}
+ // Check before changing the session, the global value, or its edit
log. For example,
+ // a cache-block limit of -1 would become a huge unsigned bound in BE.
+ try {
+ NumericRange.check(attr.name(), value, attr.minValue(),
attr.maxValue());
Review Comment:
`[P2]` Two issues with the validation placement here:
1. **Runs before type parsing and `VariableVarConverters.encode`:**
- `SET GLOBAL audit_plugin_load_timeout = 'abc'` leaks raw
`NumberFormatException` (`For input string: "abc"`) instead of
`ERR_WRONG_TYPE_FOR_VAR`.
- Bounded integer variables report inconsistent errors across invalid
inputs (`'not_an_integer'` -> `must be a finite number`, `'1.5'` -> `Incorrect
argument type`, `'-1.5'` -> `must be >= 0`).
- Any future bounded variable with a converter (e.g., string aliases)
will break before conversion, and a `double` variable with only `minValue`
would let `'1e309'` pass `BigDecimal` and overflow to `Infinity`.
Parse/convert according to the target field type first (rejecting
non-finite doubles), then check numeric bounds.
2. **Hardcoded variable-name check:** special-casing
`AUDIT_PLUGIN_LOAD_TIMEOUT` inside `setVarInternal` does not scale. Prefer
extending `@VarAttr`'s declarative `checker` mechanism to support static /
statement-time checks (skipped on replay) rather than branching on variable
names here.
##########
fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java:
##########
@@ -3545,64 +3571,76 @@ public void setDetailShapePlanNodes(String
detailShapePlanNodes) {
needForward = true, fuzzy = true)
public boolean enableReserveMemory = true;
- @VarAttrDef.VarAttr(name = SPILL_MIN_REVOCABLE_MEM, needForward = true,
fuzzy = true)
+ // Reject negative values before BE applies its minimum working size.
+ @VarAttrDef.VarAttr(minValue = "0", name = SPILL_MIN_REVOCABLE_MEM,
needForward = true, fuzzy = true)
public long spillMinRevocableMem = 4 * 1024 * 1024;
- @VarAttrDef.VarAttr(name = SPILL_BUFFER_SIZE_BYTES, fuzzy = true,
needForward = true,
+ // Reject negative values before BE applies its minimum working size.
+ @VarAttrDef.VarAttr(minValue = "0", name = SPILL_BUFFER_SIZE_BYTES, fuzzy
= true, needForward = true,
Review Comment:
`[P2]` Adding `minValue = "0"` to the six clamped spill variables
(`spill_buffer_size_bytes`, `spill_aggregation_partition_count`,
`spill_hash_join_partition_count`, `spill_repartition_max_depth`,
`spill_aggregation_sink_mem_limit_bytes`, `spill_sort_merge_mem_limit_bytes`)
conflicts with their `@VarAttr.description` ("out-of-range values are clamped
to the nearest bound") and creates a split contract where `-1` fails while `0`,
`min - 1`, and `max + 1` still clamp. The added comments ("before BE applies
its minimum working size") are also inaccurate since FE already clamps them in
`normalizeIntValue`/`normalizeLongValue`. If rejecting negatives is
intentional, please update their `description` and comments accordingly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]