alternator: BatchWriteItem table metrics count rejected items
Problem
BatchWriteItem increments per-table batch-item totals and histograms immediately after table resolution. These updates happen before per-item validation and MODIFY authorization. Global batch-item metrics are updated later.
A request rejected because of duplicate keys or missing authorization can therefore affect per-table item metrics without affecting matching global metrics.
Current behavior
For a rejected two-item request:
global operation +1
table operation +1
global batch_item_count +0
table batch_item_count +2 # wrong
global histogram unchanged
table histogram observes 2 # wrongExpected behavior
The operation counters should record the attempted operation. Batch-item totals and histograms should count only items that have passed validation and authorization, consistently at global and per-table scope.
Impact
- Table metrics report items that never passed validation or authorization.
- Invalid or unauthorized traffic looks like accepted workload.
- Per-table item count can exceed global item count.
- Per-table histograms include batches that never reached execution accounting.
- Monitoring gives different answers depending on metric scope.
Code references
Per-table operation, item total, and histogram are incremented immediately after table resolution:
Per-item validation happens later:
Authorization happens after validation:
Global batch-item metrics are updated only after those checks:
Source: scylladb/scylladb