{"record":{"id":"efba252e6b842d58","repo":"apache/cassandra","slug":"unlogged-batch-covering-partitions-detected-aga","errorCode":null,"errorMessage":"Unlogged batch covering {} partitions detected against table{} {}. You should use a logged batch for atomicity, or asynchronous writes for performance.","messagePattern":"Unlogged batch covering (.+?) partitions detected against table(.+?) (.+?)\\. You should use a logged batch for atomicity, or asynchronous writes for performance\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/cql3/statements/BatchStatement.java","lineNumber":487,"sourceCode":"\n            for (IMutation mutation : mutations)\n            {\n                for (PartitionUpdate update : mutation.getPartitionUpdates())\n                {\n                    keySet.add(update.partitionKey());\n\n                    tableNames.add(update.metadata().toString());\n                }\n            }\n\n            // CASSANDRA-11529: log only if we have more than a threshold of keys, this was also suggested in the\n            // original ticket that introduced this warning, CASSANDRA-9282\n            if (keySet.size() > DatabaseDescriptor.getUnloggedBatchAcrossPartitionsWarnThreshold())\n            {\n                NoSpamLogger.log(logger, NoSpamLogger.Level.WARN, 1, TimeUnit.MINUTES, UNLOGGED_BATCH_WARNING,\n                                 keySet.size(), tableNames.size() == 1 ? \"\" : \"s\", tableNames);\n\n                ClientWarn.instance.warn(MessageFormatter.arrayFormat(UNLOGGED_BATCH_WARNING, new Object[]{keySet.size(),\n                                                    tableNames.size() == 1 ? \"\" : \"s\", tableNames}).getMessage());\n            }\n        }\n    }\n\n\n    @Override\n    public ResultMessage execute(QueryState queryState, QueryOptions options, Dispatcher.RequestTime requestTime)\n    {\n        return execute(queryState, BatchQueryOptions.withoutPerStatementVariables(options), requestTime);\n    }\n\n    public ResultMessage execute(QueryState queryState, BatchQueryOptions options, Dispatcher.RequestTime requestTime)\n    {\n        long timestamp = options.getTimestamp(queryState);\n        long nowInSeconds = options.getNowInSeconds(queryState);\n\n        if (options.getConsistency() == null)","sourceCodeStart":469,"sourceCodeEnd":505,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java#L469-L505","documentation":"Cassandra emits this client warning when an UNLOGGED batch spans more partitions than the configured warn threshold (cassandra.unlogged_batch_across_partitions_warn_threshold, default 10). Unlogged batches are not atomic and give no performance benefit when they touch many partitions, so the coordinator warns instead of failing.","triggerScenarios":"Executing a BATCH (or executeBatch via driver) typed as UNLOGGED whose rows span more distinct partition keys than the warn threshold; verifyBatchType in BatchStatement.executeWithoutConditions raises it via ClientWarn.","commonSituations":"Bulk-loading with a single unlogged batch instead of per-partition batching; a client framework that turns all inserts into one batch; misconfigured threshold after upgrades; time-series writes with random partition keys.","solutions":["Use per-partition batching so each batch touches a single partition key","If atomicity is required, switch the batch to LOGGED (plain BATCH without UNLOGGED)","Replace the multi-partition batch with asynchronous individual writes (driver executeAsync)","Raise or disable the threshold via cassandra.unlogged_batch_across_partitions_warn_threshold only after confirming the access pattern"],"exampleFix":"// before\nBatchStatement batch = QueryBuilder.batch(ins1, ins2, ins3); // rows in different partitions, unlogged\n// after\nins1.executeAsync(); ins2.executeAsync(); ins3.executeAsync(); // or one batch per partition key","handlingStrategy":"validation","validationCode":"int distinctPartitions = statements.stream().map(s -> s.partitionKey()).distinct().count();\nif (distinctPartitions > 10) throw new IllegalArgumentException(\"batch spans \" + distinctPartitions + \" partitions; use async writes or logged batch\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Batch only rows sharing one partition key","Use driver executeAsync for multi-partition writes","Track the unlogged batch threshold when changing cluster config"],"tags":["cassandra","batch","performance","client-warning"],"backgroundTag":"deprecated-api-usage","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"}