Skip to content

Add temporal sharding feature#7801

Draft
PallabPaul wants to merge 3 commits intomicrosoft:mainfrom
PallabPaul:ppaul/temporal_sharding
Draft

Add temporal sharding feature#7801
PallabPaul wants to merge 3 commits intomicrosoft:mainfrom
PallabPaul:ppaul/temporal_sharding

Conversation

@PallabPaul
Copy link
Copy Markdown
Member

Implement temporal sharding for the CCF ledger, allowing completed ledger ranges to be sealed into immutable shards. Sealed shards are archived to read_only_directories via host ring buffer messaging.

Key changes:

  • New KV tables for shard info and shard policy (src/service/tables/shards.h)
  • Shard lifecycle management in node_state.h (seal, auto-seal, initialize)
  • Governance actions: seal_current_shard, set_shard_policy
  • JS bindings: ccf.node.sealShard(), ccf.node.setShardPolicy()
  • Host-side ledger chunk archival to read_only_directories/shards//
  • Ring buffer message type: ledger_shard_sealed
  • Unit tests (src/node/test/sharding.cpp) and e2e test (tests/sharding.py)
  • Documentation (doc/operations/sharding.rst)

Implement temporal sharding for the CCF ledger, allowing completed
ledger ranges to be sealed into immutable shards. Sealed shards are
archived to read_only_directories via host ring buffer messaging.

Key changes:
- New KV tables for shard info and shard policy (src/service/tables/shards.h)
- Shard lifecycle management in node_state.h (seal, auto-seal, initialize)
- Governance actions: seal_current_shard, set_shard_policy
- JS bindings: ccf.node.sealShard(), ccf.node.setShardPolicy()
- Host-side ledger chunk archival to read_only_directories/shards/<id>/
- Ring buffer message type: ledger_shard_sealed
- Unit tests (src/node/test/sharding.cpp) and e2e test (tests/sharding.py)
- Documentation (doc/operations/sharding.rst)
The seal flow was previously synchronous — seal_shard() immediately
transitioned the shard to Sealed and sent the ring buffer message
before the snapshot was actually committed.

Now seal_shard() keeps the shard in Sealing state and
shard_seal_in_progress = true. When the snapshotter commits the
shard-seal snapshot, it fires on_shard_seal_committed which:
- Updates the shard to Sealed in the KV
- Sends the ledger_shard_sealed ring buffer message to the host
- Clears shard_seal_in_progress

This ensures ledger chunks are only archived after the boundary
snapshot is durable, and a crash during sealing leaves the shard
in a recoverable Sealing state.
- Add sharding object to cchost_config.json schema (required for node startup validation)
- Fix -Wshadow: rename last_idx to chunk_last_idx in ledger.h
- Fix -Wshadow: rename to_host to shard_writer in node_state.h
- Fix deadlock: seal callback now sets atomic flag, complete_shard_seal() deferred to tick()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant