{"record":{"id":"15a4db557eaae2e8","repo":"apache/cassandra","slug":"dynamic-warning-no-literal-in-source-built-by-g","errorCode":null,"errorMessage":"<dynamic warning, no literal in source: built by Guardrail.warn via Threshold.errMsg -> ErrorMessageProvider.createMessage(isWarning, what, value, thresholdValue), delivered to the client via ClientWarn>","messagePattern":"<dynamic warning, no literal in source: built by Guardrail\\.warn via Threshold\\.errMsg -> ErrorMessageProvider\\.createMessage\\(isWarning, what, value, thresholdValue\\), delivered to the client via ClientWarn>","errorType":"console","errorClass":"Threshold","httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/db/guardrails/Threshold.java","lineNumber":157,"sourceCode":"            triggerFail(value, failValue, what, containsUserData, state);\n            return;\n        }\n\n        long warnValue = warnValue(state);\n        if (compare(value, warnValue))\n            triggerWarn(value, warnValue, what, containsUserData);\n    }\n\n    private void triggerFail(long value, long failValue, String what, boolean containsUserData, ClientState state)\n    {\n        String fullMessage = errMsg(false, what, value, failValue);\n        fail(fullMessage, containsUserData ? redactedErrMsg(false, value, failValue) : fullMessage, state);\n    }\n\n    private void triggerWarn(long value, long warnValue, String what, boolean containsUserData)\n    {\n        String fullMessage = errMsg(true, what, value, warnValue);\n        warn(fullMessage, containsUserData ? redactedErrMsg(true, value, warnValue) : fullMessage);\n    }\n\n    /**\n     * A function used to build the error message of a triggered {@link Threshold} guardrail.\n     */\n    interface ErrorMessageProvider\n    {\n        /**\n         * Called when the guardrail is triggered to build the corresponding error message.\n         *\n         * @param isWarning Whether the trigger is a warning one; otherwise it is a failure one.\n         * @param what      A string, provided by the call to the {@link #guard} method, describing what the guardrail\n         *                  has been applied to (and that has triggered it).\n         * @param value     The value that triggered the guardrail (as a string).\n         * @param threshold The threshold that was passed to trigger the guardrail (as a string).\n         */\n        String createMessage(boolean isWarning, String what, String value, String threshold);\n    }","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/guardrails/Threshold.java#L139-L175","documentation":"Threshold guardrails (e.g. partition_size_in_kb, collection_size_in_kb, query page size) emit a dynamic warning when a measured value exceeds the configured 'warn' threshold but stays below the 'fail' threshold. The message is built by the threshold's ErrorMessageProvider and delivered to the client via ClientWarn; the operation still succeeds.","triggerScenarios":"Executing a statement whose measured value (e.g. partition size, number of rows in a collection, IN clause size) exceeds the corresponding guardrail's warn threshold in cassandra.yaml.","commonSituations":"Writing very large partitions or huge collections; unbounded row growth over time pushing a table past the warning threshold; after enabling guardrails on an existing cluster with already-oversized data.","solutions":["Reduce the offending value: split large partitions, trim collections, or cap batch/IN sizes in the application.","If the warning threshold is too strict for your workload, raise it via cassandra.yaml or the corresponding guardrails config table and reload config.","Treat the warning as an early signal before the 'fail' threshold starts rejecting writes; migrate data model proactively."],"exampleFix":"// before: unbounded partition growth triggers threshold warning\nINSERT INTO sensor_data (sensor_id, ts, value) ... // millions of rows per sensor\n// after: bucket the partition by time to stay under the threshold\nINSERT INTO sensor_data (sensor_id, day, ts, value) VALUES (?, toUnixTimestamp(now()) bucketed, ...);","handlingStrategy":"validation","validationCode":"// Before writing, estimate the guarded metric, e.g. partition size:\nlong partitionBytes = estimatePartitionSize(key);\nlong warnThresholdKb = readGuardrailWarnThreshold(\"partition_size_in_kb\");\nif (partitionBytes / 1024 > warnThresholdKb) {\n    log.warn(\"Write will exceed partition size guardrail warn threshold\");\n}","typeGuard":null,"tryCatchPattern":"// Non-fatal: consume client warnings\nResultSet rs = session.execute(stmt);\nrs.getExecutionInfo().getWarnings().forEach(w -> {\n    if (w.contains(\"exceeds warn threshold\")) {\n        // reduce partition/collection size or raise threshold\n    }\n});","preventionTips":["Model partitions to stay well under partition size guardrails (time-bucketing, bucket keys).","Cap collection (list/map/set) sizes in application logic.","Set explicit guardrail warn/fail thresholds sized for your workload.","Alert on guardrail warnings in production logs to catch growth before fail thresholds trigger."],"tags":["cassandra","guardrails","threshold","client-warning"],"backgroundTag":"value-out-of-range","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}