#31260·scylladb

alternator: BatchWriteItem table metrics count rejected items

Author: dkropachevCreated Aug 25, 2026Updated Sep 16, 2026
Labelsbugarea/alternatorai-assisted

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  # wrong

Expected 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:

https://github.com/scylladb/scylladb/blob/fe679915cd1c32ad56ac0f8740b44703f1722e7b/alternator/executor.cc#L3487-L3493

Per-item validation happens later:

https://github.com/scylladb/scylladb/blob/fe679915cd1c32ad56ac0f8740b44703f1722e7b/alternator/executor.cc#L3502-L3533

Authorization happens after validation:

https://github.com/scylladb/scylladb/blob/fe679915cd1c32ad56ac0f8740b44703f1722e7b/alternator/executor.cc#L3534-L3538

Global batch-item metrics are updated only after those checks:

https://github.com/scylladb/scylladb/blob/fe679915cd1c32ad56ac0f8740b44703f1722e7b/alternator/executor.cc#L3600-L3604