{"record":{"id":"61c50528578ed0d7","repo":"apache/cassandra","slug":"threshold-value-for-gc-warn-threshold-must-be-grea","errorCode":null,"errorMessage":"Threshold value for gc_warn_threshold must be greater than or equal to 0","messagePattern":"Threshold value for gc_warn_threshold must be greater than or equal to 0","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/DatabaseDescriptor.java","lineNumber":5041,"sourceCode":"            throw new IllegalArgumentException(\"Threshold value for gc_log*_threshold (\" + logThreshold + \") must be less than gc_warn*_threshold which is currently \"\n                    + warnThreshold);\n    }\n\n    public static EncryptionContext getEncryptionContext()\n    {\n        return encryptionContext;\n\n    }\n\n    public static long getGCWarnThreshold()\n    {\n        return conf.gc_warn_threshold.toMilliseconds();\n    }\n\n    public static void setGCWarnThreshold(long threshold)\n    {\n        if (threshold < 0)\n            throw new IllegalArgumentException(\"Threshold value for gc_warn_threshold must be greater than or equal to 0\");\n\n        if (threshold > Integer.MAX_VALUE)\n            throw new IllegalArgumentException(\"Threshold must be less than Integer.MAX_VALUE\");\n\n        long gcLogThresholdInMs = getGCLogThreshold();\n        if (threshold != 0 && threshold <= gcLogThresholdInMs)\n            throw new IllegalArgumentException(\"Threshold value for gc_warn_threshold (\" + threshold + \") must be greater than gc_log_threshold which is currently \"\n                                               + gcLogThresholdInMs);\n\n        conf.gc_warn_threshold = new DurationSpec.IntMillisecondsBound(threshold);\n    }\n\n    public static int getGCConcurrentPhaseLogThreshold()\n    {\n        return conf.gc_concurrent_phase_log_threshold.toMilliseconds();\n    }\n\n    public static void setGCConcurrentPhaseLogThreshold(int threshold)","sourceCodeStart":5023,"sourceCodeEnd":5059,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/DatabaseDescriptor.java#L5023-L5059","documentation":"Cassandra throws this IllegalArgumentException from setGCWarnThreshold when the threshold is negative. gc_warn_threshold controls the GC pause duration (ms) above which a warning is logged; 0 disables it, but negative values are invalid.","triggerScenarios":"Calling DatabaseDescriptor.setGCWarnThreshold(-1) or any negative long, via JMX runtime config updates or programmatic configuration.","commonSituations":"Automation passing an unvalidated long (e.g. a parsed config with a stray minus), or scripts intending 0 (= disabled) but computing a negative value.","solutions":["Pass a non-negative value; 0 disables warn-threshold GC logging","Keep the value below Integer.MAX_VALUE (the setter throws next if exceeded)","Keep the value greater than gc_log_threshold to avoid the ordering error"],"exampleFix":"// before\nDatabaseDescriptor.setGCWarnThreshold(-500);\n// after\nDatabaseDescriptor.setGCWarnThreshold(1000);","handlingStrategy":"validation","validationCode":"if (threshold < 0 || threshold > Integer.MAX_VALUE)\n    throw new IllegalArgumentException(\"gc_warn_threshold must be >= 0 and <= Integer.MAX_VALUE ms\");","typeGuard":null,"tryCatchPattern":"try {\n    DatabaseDescriptor.setGCWarnThreshold(threshold);\n} catch (IllegalArgumentException e) {\n    logger.warn(\"Invalid gc_warn_threshold; keeping current value\", e);\n}","preventionTips":["Use 0 to disable the warn threshold, never negative values","Keep the value above gc_log_threshold and below Integer.MAX_VALUE","Sanitize numeric input from JMX clients and scripts before applying"],"tags":["configuration","gc","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}