Skip to content

Counters: replica-level commutative merge (true distributed counter) #518

Description

Context

CefasDB's `AtomicUpdate` serializes all increments through the shard's Raft leader. ScyllaDB allows replicas in different DCs to accept concurrent increments and merge them commutatively (PN-counter / CRDT model).

CefasDB does not need this for a single-DC deployment — Raft already serializes per shard. The motivation is multi-DC writes without round-trip to the global leader.

Goal

For counter columns (depends on schema-level type from sibling issue): allow increments accepted by any local replica, merge via vector clock at quorum time.

Why low priority

This is a major shift in consistency model: weakens linearizability for counter columns. Not blocking any current workload. Open as a roadmap placeholder so the conversation is recorded.

Files (sketch)

  • `pkg/types/types.go` — `CounterReplicaPolicy` per-table option.
  • `internal/storage/adapter/pebble/atomic.go` — vector-clock-keyed counter codec (replaces plain `N` for counter columns).
  • `internal/replication/` — replica merge on apply.

Tier

T4 (multi-PR, schema + storage + replication). Open as roadmap placeholder — not actively planned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreCore engine — storage, query planner, plugin registryenhancementNew feature or requestp2Nice to havestorageStorage layer (pebble, catalog, keys)

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions