Skip to content

Shard commits collection? #57

Open

Description

@LarsAndreasEk

Hi,

How the the indices and the concept of checkPointId fit sharding of the «commits» collection?

Let’s say I shard on bucketId+streamId for instance (they seem to be prefixes for the unique indices), I guess each shard could accept duplicate checkpointIds?

Please correct me if I’m wrong :)

Activity

  1. AGiorgetti commented on Oct 23, 2026

    @AGiorgetti
    Member

    Review update against 286c0ae (rechecked 2026-10-23).

    This remains a design/support gap rather than a configuration-only question.

    The current indexes do not all have {BucketId, StreamId} as a prefix: the unique checkpoint index begins {BucketId, CheckpointNumber}. Also, CheckpointNumber is the BSON _id.

    MongoDB's sharded unique-index rules require the shard-key prefix for non-_id unique indexes; when _id is not the shard key its uniqueness is only enforced per shard. Consequently, max-plus-one allocation and retry-on-duplicate cannot simply be assumed to provide the existing global checkpoint uniqueness/order contract across shards.

    A supportable design needs to specify:

    • Global versus bucket-local checkpoint ordering and uniqueness.
    • A shard key compatible with every required uniqueness constraint.
    • Concurrent writers, global scans, migration/resharding and recycled-stream routing. Deletion rewrites BucketId to :rb, so a BucketId-based shard key also needs explicit treatment.
    • Topology-backed tests showing no checkpoint collisions or missed polling results.

    The new validation used one standalone MongoDB 7.0.45 instance, not a sharded cluster, so it does not validate sharding. The independent cross-bucket recycling defect is now tracked in #87; fixing it alone would not establish sharding support.

    Co-authored by Alessandro Giorgetti and Codex (OpenAI).

  2. AGiorgetti commented on Dec 2, 2026

    @AGiorgetti
    Member

    Tracking this as a deferred design/implementation follow-up to #118. Replica-set support with an unsharded Commits collection is required for #118 and is not blocked by this issue. This issue concerns actually sharding the Commits collection, not merely connecting through mongos.

    The current schema relies on globally unique checkpoint _id values and unique stream/commit keys that start with BucketId. With a bucket-prefixed shard key, _id alone may be unique only per shard; choosing _id as shard key conflicts with the existing stream uniqueness indexes. MongoDB's unique index rules.

    A future implementation must preserve both stream concurrency and cross-bucket polling correctness across shards. Cover concurrent writes to different shards, delayed visibility, saved-checkpoint resume, failover, recycling/cleanup, and migration from existing storage; do not assume globally unique IDs alone also guarantee safe visibility order.

    Co-authored by Alessandro Giorgetti and Codex (OpenAI).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions