Skip to content

Implement TrueTime clock sync and distributed transactions for sharding - #78

Merged
makr-code merged 4 commits into
revert-75-copilot/improve-transactional-reliabilityfrom
copilot/sub-pr-77
Dec 10, 2025
Merged

makr-code merged 4 commits into
revert-75-copilot/improve-transactional-reliabilityfrom
copilot/sub-pr-77

Conversation

Copilot AI commented Dec 10, 2025 •

Copy link
Copy Markdown
Contributor

Implements Phase 3 of the TrueTime integration: clock synchronization with uncertainty bounds, distributed transaction coordination, and cross-shard consistency guarantees.

Core Components

TrueTime Clock (truetime.h/cpp)

  • Time intervals with uncertainty bounds [earliest, latest] similar to Google Spanner
  • NTP-based clock sync with drift compensation
  • waitUntil(timestamp) operation for external consistency

Distributed Transaction Coordinator (distributed_transaction.h/cpp)

  • Two-phase commit: Prepare → Assign timestamp (TT.now().latest) → waitUntil() → Commit
  • Wait-free read-only transactions using snapshot timestamps
  • Cross-shard coordination with automatic rollback

ShardRouter Integration

  • Snapshot reads: router->get(urn, snapshot_ts)
  • Access to transaction coordinator via getTransactionCoordinator()

RaftLog Timestamps

  • Added timestamp_ns field to LogEntry for total ordering across shards

Example Usage

// TrueTime-based transaction
auto txn_id = coordinator->beginTransaction({"shard1", "shard2"});
coordinator->addOperation(txn_id, "shard1", op1);
coordinator->addOperation(txn_id, "shard2", op2);
bool success = coordinator->commit(txn_id);  // 2PC with TT.waitUntil()

// Wait-free snapshot read
auto snapshot_ts = truetime->now().latest;
auto data = router->get(urn, snapshot_ts);

Guarantees

  • External consistency: T1 commits before T2 starts ⇒ commit_ts(T1) < commit_ts(T2)
  • Snapshot isolation: Read-only transactions see consistent snapshots without locks
  • Strict serializability: All transactions appear in timestamp order

Phase 4 (GPS time source, advanced drift compensation, multi-datacenter optimization) tracked separately.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Dec 10, 2025

Copilot AI commented Dec 10, 2025

Copy link
Copy Markdown
Contributor Author

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Revert TrueTime clock sync and transactions changes Implement TrueTime clock sync and distributed transactions for sharding Dec 10, 2025
Copilot AI requested a review from makr-code December 10, 2025 07:52
@makr-code
makr-code marked this pull request as ready for review December 10, 2025 07:52
@makr-code
makr-code merged commit 6fd272f into revert-75-copilot/improve-transactional-reliability Dec 10, 2025
@makr-code makr-code added this to the v1.0.2 milestone Mar 11, 2026
Copilot AI added a commit that referenced this pull request Mar 15, 2026
…ssue #78)

- include/network/raft_load_balancer.h: Full header with Config, Backend, Stats,
  RaftRole and all 5 load-balancing strategies
- src/network/raft_load_balancer.cpp: Production implementation with health-check
  loop, Raft election loop, dynamic weight rebalancing, cross-DC routing
- tests/test_raft_load_balancer.cpp: 26 focused unit tests covering all 14 ACs
- tests/CMakeLists.txt: Add RaftLoadBalancerFocusedTests target + fix 3 pre-existing
  CMake parse errors (interleaved/unclosed blocks)
- .github/workflows/load-balancing-raft-coordination-ci.yml: CI workflow

Co-authored-by: makr-code <[email protected]>
makr-code added a commit that referenced this pull request Mar 15, 2026
…aft-coordination

feat(network): Raft-coordinated load balancer with all 5 routing strategies (v1.8.0, Issue #78)
Copilot AI added a commit that referenced this pull request May 5, 2026
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.

2 participants